------------------------------------------------------------ -- Entity and architecture for a simple controller -- -- This controller supports only multiplication of -- UNSIGNED numbers -- of unknown precision (MODE 3) ------------------------------------------------------------ library ieee; use ieee.std_logic_1164.all; entity controller is port (clock, nReset : in std_logic; Start : in std_logic; LsbB, EmptyB, FullB : in std_logic; UpdateA, UpdateB, UpdateP, Shift, ZeroP, Subtract, EnableP: out std_logic ); end entity controller; architecture behaviour of controller is signal state : std_logic_vector( 2 downto 0 ); begin state_machine: process(clock, nReset) is begin if (nReset = '0' ) then state <= (others => '0'); elsif rising_edge(clock) then if state="000" then if Start='1' then state <= "001"; end if; elsif state="001" then state <= "010"; elsif state="010" then state <= "011"; elsif state="011" then if EmptyB='1' then state <= "100"; end if; else state <= "000"; end if; end if; end process state_machine; UpdateA <= '1' when ( state="001" or state="011") else '0'; UpdateB <= '1' when ( state="010" or state="011") else '0'; Shift <= '1' when state="011" else '0'; ZeroP <= '1' when state="001" else '0'; EnableP <= '1' when state="100" else '0'; Subtract <= '0'; UpdateP <= '1' when (state="001" or (state="011" and LsbB='1')) else '0'; end architecture behaviour;