1 2-- Copyright (C) 2002 Morgan Kaufmann Publishers, Inc 3 4-- This file is part of VESTs (Vhdl tESTs). 5 6-- VESTs is free software; you can redistribute it and/or modify it 7-- under the terms of the GNU General Public License as published by the 8-- Free Software Foundation; either version 2 of the License, or (at 9-- your option) any later version. 10 11-- VESTs is distributed in the hope that it will be useful, but WITHOUT 12-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14-- for more details. 15 16-- You should have received a copy of the GNU General Public License 17-- along with VESTs; if not, write to the Free Software Foundation, 18-- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 20library ieee; use ieee.math_real.all; 21 22entity pendulum is 23end entity pendulum; 24 25---------------------------------------------------------------- 26 27architecture constrained of pendulum is 28 29 constant mass : real := 10.0; 30 constant arm_length : real := 5.0; 31 constant pin_angle : real := 0.25 * math_pi; 32 constant pin_distance : real := 2.5; 33 constant damping : real := 1.0; 34 constant gravity : real := 9.81; 35 constant short_length : real := arm_length - pin_distance; 36 quantity phi : real := -0.5*math_pi; 37 quantity current_length : real := arm_length; 38 39begin 40 41 if phi'above(pin_angle) use 42 current_length == short_length; 43 else 44 current_length == arm_length; 45 end use; 46 47 break phi'dot => phi'dot * arm_length/short_length 48 when phi'above(pin_angle); 49 50 break phi'dot => phi'dot * short_length/arm_length 51 when not phi'above(pin_angle); 52 53 mass * current_length * phi'dot'dot 54 == - mass * gravity * sin(phi) - damping * current_length * phi'dot; 55 56end architecture constrained; 57