blob: bf3381127e160b21c135c58890d6674ef8ad2722 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-- Copyright (C) 2002 Morgan Kaufmann Publishers, Inc
-- This file is part of VESTs (Vhdl tESTs).
-- VESTs is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; either version 2 of the License, or (at
-- your option) any later version.
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details.
-- You should have received a copy of the GNU General Public License
-- along with VESTs; if not, write to the Free Software Foundation,
-- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-- Pendulum example. Look at velocity quantity, phi_dot, to see effects of
-- discontinuity. Run simulation for about 20 sec.
library IEEE_proposed;
use IEEE_proposed.mechanical_systems.all;
library ieee; use ieee.math_real.all;
entity pendulum_wa is
end entity pendulum_wa;
-- ======================================================================================
-- constrained architecture
-- ======================================================================================
architecture constrained of pendulum_wa is
constant mass : real := 10.0;
constant arm_length : real := 5.0;
constant pin_angle : real := 0.25*math_pi;
constant pin_distance : real := 2.5;
constant damping : real := 1.0;
constant gravity : real := 9.81;
constant short_length : real := arm_length-pin_distance;
quantity phi : real := -0.5*math_pi;
signal current_length : real := arm_length;
quantity acceleration, velocity : real;
quantity phi_dot : real;
signal pin_thresh : boolean;
signal phi_dot_at_pin_thresh : real := 0.0;
signal transition : boolean := false;
begin
if domain = quiescent_domain use
phi == -0.5*math_pi;
phi'dot == 0.0;
elsif transition and pin_thresh use
phi == pin_angle;
phi'dot == phi_dot_at_pin_thresh*arm_length/short_length;
elsif transition and not pin_thresh use
phi == pin_angle;
phi'dot == phi_dot_at_pin_thresh*short_length/arm_length;
else
mass*acceleration == -mass*gravity*sin(phi)-damping*velocity;
velocity == current_length*phi'dot;
end use;
acceleration == velocity'dot;
phi_dot == phi'dot;
pin_thresh <= phi'above(pin_angle);
process
begin
wait on pin_thresh;
phi_dot_at_pin_thresh <= phi_dot;
if pin_thresh = true then
current_length <= short_length;
transition <= true;
else
current_length <= arm_length;
transition <= true;
end if;
wait for 1 us;
transition <= false;
end process;
break on pin_thresh;
break on transition;
end architecture constrained;
|