--------------------------------------------- --Project Gump --Marc Binette --Ralph Nevins --Lambert Lo ---------------------------------------------- --servo_controller_comparator.vhd --This is a 12 bit comparator that first adds on --"0001" to the reg_in befor comparing it to --cnt_in. --input=>reg_in(8bits), cnt_in(12bits) --ouput=>compare_out(1bit) LIBRARY ieee; USE ieee.std_logic_1164.ALL; --entity declaration for a comparator that takes --in two value, where reg_in is four bits shorter --than cnt_in ENTITY servo_controller_comparator IS GENERIC(data : positive := 12); PORT(reg_in : IN std_logic_vector(data-5 DOWNTO 0); cnt_in : IN std_logic_vector(data-1 DOWNTO 0); compare_out : BUFFER std_logic); END servo_controller_comparator; --behavioural discription of the comparator ARCHITECTURE behavioural OF servo_controller_comparator IS --signal used for the reg_in with bit stream "0001" added to --the front SIGNAL extended_reg_in : std_logic_vector(data-1 DOWNTO 0); BEGIN --adding "0001" to front of reg_in extended_reg_in(data-1 DOWNTO data-4) <= "0001"; extended_reg_in(data-5 DOWNTO 0) <= reg_in; compare : PROCESS IS BEGIN --compare_out goes high if cnt_in is smaller than --reg_in with "0001" added to its front IF extended_reg_in > cnt_in THEN compare_out <= '1'; --otherwise compare_out is low. ELSE compare_out <= '0'; END IF; END PROCESS compare; END behavioural;