-- *********************************************************************** -- -- DESCRIPTION -- -- Controller for MULTIPLIER 8 bits. -- -- REQUIRED COMPONENTS -- -- None. -- -- PORTS -- -- (I) Start: Start (1 bit) -- (I) Reset: Reset (1 bit) -- (I) Clk: Clock (1 bit) -- (O) Done: Done (1 bit) -- (O) Load_Multiplicand: Load Multiplicand (1 bit) -- (O) Load_Multiplier: Load Multiplier (1 bit) -- (O) Shift_Multiplier: Shift Multiplier (1 bit) -- (O) Reset_Product: Reset Product Register (1 bit) -- (O) Load_Product: Load Product Register (1 bit) -- (O) Shift_Product: Shift Product Register (1 bit) -- -- AUTHORS -- -- 14.12.2001 - Xavier Perseguers & Tadeusz Senn -- 11.01.2002 - Xavier Perseguers & Tadeusz Senn -- -- *********************************************************************** -- Declarations ---------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; -- Entity ---------------------------------------------------------------- entity controller is port (Start, Reset, Clk: in std_logic; Done, Load_Multiplicand, Load_Multiplier, Shift_Multiplier, Reset_Product, Load_Product, Shift_Product: out std_logic); end controller; -- Architecture ---------------------------------------------------------- architecture comportemental of controller is type State_Type is (S0, S1, S2, S3); signal Current_State, Next_State : State_Type; signal Counter, Counter_Next: integer range 0 to 8; begin -- comportemental process (Clk, Reset) begin if Reset = '1' then Current_State <= S0; elsif (Clk'event and Clk = '1') then Current_State <= Next_State; Counter <= Counter_Next; end if; end process; process (Current_State, Start) begin Shift_Multiplier <= '0'; Load_Product <= '0'; Shift_Product <= '0'; Done <= '0'; Load_Multiplicand <= '0'; Load_Multiplier <= '0'; Reset_Product <= '0'; Next_State <= Current_State; case Current_State is when S0 => if Start = '1' then Next_State <= S1; Load_Multiplicand <= '1'; Load_Multiplier <= '1'; Reset_Product <= '1'; Counter_Next <= 0; end if; when S1 => Load_Product <= '1'; Counter_Next <= Counter + 1; Next_State <= S2; when S2 => Shift_Product <= '1'; Shift_Multiplier <= '1'; if Counter = 8 then Next_State <= S3; else Next_State <= S1; end if; when S3 => Done <= '1'; Next_State <= S0; end case; end process; end comportemental;