-- Copyright Mentor Graphics Corporation 2001 -- Confidential Information Provided Under License Agreement for Internal Use Only -- Simple Digital-Controlled Two-position Switch Model -- Switch position 1 ('0') or switch position 2 ('1') LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; use IEEE.std_logic_arith.all; use IEEE.math_real.all; -- Use proposed IEEE natures and packages LIBRARY IEEE; USE IEEE.electrical_systems.ALL; ENTITY switch_dig_2in is GENERIC (r_open : RESISTANCE := 1.0e6; -- Open switch resistance r_closed : RESISTANCE := 0.001; -- Closed switch resistance trans_time : real := 0.00001); -- Transition time to each position PORT (sw_state : in std_logic; -- Digital control input TERMINAL p_in1, p_in2, p_out : ELECTRICAL); -- Analog output END ENTITY switch_dig_2in; ARCHITECTURE ideal OF switch_dig_2in IS SIGNAL r_sig1 : RESISTANCE := r_closed; -- Variable to accept switch resistance SIGNAL r_sig2 : RESISTANCE := r_open; -- Variable to accept switch resistance QUANTITY v1 ACROSS i1 THROUGH p_in1 TO p_out; -- V & I for in1 to out QUANTITY v2 ACROSS i2 THROUGH p_in2 TO p_out; -- V & I for in2 to out QUANTITY r1 : RESISTANCE; -- Time-varying resistance for in1 to out QUANTITY r2 : RESISTANCE; -- Time-varying resistance for in2 to out BEGIN PROCESS (sw_state) -- Sensitivity to digital control input BEGIN IF (sw_state = '0') THEN -- Close sig1, open sig2 r_sig1 <= r_closed; r_sig2 <= r_open; ELSIF (sw_state = '1') THEN -- Open sig1, close sig2 r_sig1 <= r_open; r_sig2 <= r_closed; END IF; END PROCESS; r1 == r_sig1'ramp(trans_time, trans_time); -- Ensure resistance continuity r2 == r_sig2'ramp(trans_time, trans_time); -- Ensure resistance continuity v1 == r1*i1; -- Apply Ohm's law to in1 v2 == r2*i2; -- Apply Ohm's law to in2 END ARCHITECTURE ideal;