diff --git a/hardware/signal_processing/add.vhd b/hardware/signal_processing/add.vhd index 3e7315a..21a4c67 100644 --- a/hardware/signal_processing/add.vhd +++ b/hardware/signal_processing/add.vhd @@ -26,11 +26,43 @@ entity add is end entity add; architecture rtl of add is + + component float_add is -- # + port ( -- # + A : in std_logic_vector( 31 downto 0 ); -- # + B : in std_logic_vector( 31 downto 0 ); -- # + clk : in std_logic; -- # + reset : in std_logic; -- # + start : in std_logic; -- # + done : out std_logic; -- # + sum : out std_logic_vector( 31 downto 0 ) -- # + ); -- # + end component float_add; -- # + signal current_task_state : work.task.State; signal next_task_state : work.task.State; signal index : integer range 0 to work.task.STREAM_LEN; + type AddState is ( ADD_IDLE, ADD_WAIT_DONE, ADD_WRITE ); -- # + signal current_add_state : AddState; -- # + + signal add_start : std_logic; -- # + signal add_done : std_logic; -- # + signal add_sum : std_logic_vector( 31 downto 0 ); -- # + begin + + float_add_inst : float_add -- # + port map ( -- # + A => signal_a_readdata, -- # + B => signal_b_readdata, -- # + clk => clk, -- # + reset => reset, -- # + start => add_start, -- # + done => add_done, -- # + sum => add_sum -- # + ); -- # + task_state_transitions : process ( current_task_state, task_start, index ) is begin next_task_state <= current_task_state; @@ -54,24 +86,60 @@ begin begin if ( reset = '1' ) then current_task_state <= work.task.TASK_IDLE; - index <= 0; + current_add_state <= ADD_IDLE; -- # + index <= 0; + signal_a_read <= '0'; -- # + signal_b_read <= '0'; -- # + signal_write <= '0'; -- # + signal_writedata <= ( others => '0' ); -- # + add_start <= '0'; -- # elsif ( rising_edge( clk ) ) then current_task_state <= next_task_state; + + signal_a_read <= '0'; -- # + signal_b_read <= '0'; -- # + signal_write <= '0'; -- # + case next_task_state is - when work.task.TASK_IDLE => - index <= 0; - signal_write <= '0'; - when work.task.TASK_RUNNING => - index <= index + 1; - signal_write <= '1'; - signal_writedata <= ( others => '0' ); - when work.task.TASK_DONE => - index <= 0; - signal_write <= '0'; + when work.task.TASK_IDLE => + index <= 0; + current_add_state <= ADD_IDLE; -- # + add_start <= '0'; -- # + signal_write <= '0'; + + when work.task.TASK_RUNNING => + case current_add_state is -- # + when ADD_IDLE => -- # + add_start <= '1'; -- # + current_add_state <= ADD_WAIT_DONE; -- # + + when ADD_WAIT_DONE => -- # + if ( add_done = '1' ) then -- # + add_start <= '0'; -- # + signal_write <= '1'; -- # + signal_writedata <= add_sum; -- # + signal_a_read <= '1'; -- # + signal_b_read <= '1'; -- # + current_add_state <= ADD_WRITE; -- # + end if; -- # + + when ADD_WRITE => -- # + index <= index + 1; -- # + current_add_state <= ADD_IDLE; -- # + + when others => -- # + current_add_state <= ADD_IDLE; -- # + end case; -- # + + when work.task.TASK_DONE => + index <= 0; + current_add_state <= ADD_IDLE; -- # + add_start <= '0'; -- # + signal_write <= '0'; end case; end if; end process sync; task_state <= current_task_state; -end architecture rtl; +end architecture rtl; \ No newline at end of file