diff --git a/docs/img/FSM.drawio.png b/docs/img/FSM.drawio.png new file mode 100644 index 0000000000000000000000000000000000000000..618ffae164ba6814971dc3cbb620f6e60e05693d Binary files /dev/null and b/docs/img/FSM.drawio.png differ diff --git a/docs/img/controlUnitTest1.png b/docs/img/controlUnitTest1.png new file mode 100644 index 0000000000000000000000000000000000000000..b4f55997c993d8ba61859ae08b63cc2d354e14b7 Binary files /dev/null and b/docs/img/controlUnitTest1.png differ diff --git a/docs/img/controlUnitTest2.png b/docs/img/controlUnitTest2.png new file mode 100644 index 0000000000000000000000000000000000000000..1b9258a3269625f138d795f0f82a4e3459dd2b43 Binary files /dev/null and b/docs/img/controlUnitTest2.png differ diff --git a/src/hdl/controlUnit.vhd b/src/hdl/controlUnit.vhd index 705905d8efbad8482d22e650f8cce92ef78290f4..3057bbaeb48c3a7a349496552fe12487075a97b3 100644 --- a/src/hdl/controlUnit.vhd +++ b/src/hdl/controlUnit.vhd @@ -49,33 +49,92 @@ architecture archi_operativeUnit of controlUnit is begin - process (_BLANK_) is + process (I_reset, I_clock) is begin if I_reset = '1' then -- asynchronous reset (active high) - SR_presentState <= _BLANK_ + SR_presentState <= WAIT_SAMPLE; elsif rising_edge(I_clock) then -- rising clock edge - _BLANK_ + SR_presentState <= SR_futurState; end if; end process; - process (_BLANK_) is + process (SR_presentState, I_inputSampleValid, I_processingDone) is begin case SR_presentState is when WAIT_SAMPLE => - _BLANK_ + O_loadShift <= '0'; + O_initAddress <= '0'; + O_incrAddress <= '0'; + O_initSum <= '0'; + O_loadSum <= '0'; + O_loadY <= '0'; + + if(I_inputSampleValid = '1')then + SR_futurState <= STORE; + else + SR_futurState <= WAIT_SAMPLE; + end if; + + when STORE => + O_loadShift <= '1'; + O_initAddress <= '1'; + O_incrAddress <= '0'; + O_initSum <= '1'; + O_loadSum <= '0'; + O_loadY <= '0'; + + SR_futurState <= PROCESSING_LOOP; + + when PROCESSING_LOOP => + O_loadShift <= '0'; + O_initAddress <= '0'; + O_incrAddress <= '1'; + O_initSum <= '0'; + O_loadSum <= '1'; + O_loadY <= '0'; + + if(I_processingDone = '1')then + SR_futurState <= OUTPUT; + else + SR_futurState <= PROCESSING_LOOP; + end if; + + when OUTPUT => + O_loadShift <= '0'; + O_initAddress <= '0'; + O_incrAddress <= '0'; + O_initSum <= '0'; + O_loadSum <= '0'; + O_loadY <= '1'; + + SR_futurState <= WAIT_END_SAMPLE; + + when WAIT_END_SAMPLE => + O_loadShift <= '0'; + O_initAddress <= '0'; + O_incrAddress <= '0'; + O_initSum <= '0'; + O_loadSum <= '0'; + O_loadY <= '0'; + + if(I_inputSampleValid = '0')then + SR_futurState <= WAIT_SAMPLE; + else + SR_futurState <= WAIT_END_SAMPLE; + end if; when others => null; end case; end process; - O_loadShift <= '1' when _BLANK_ ; - O_initAddress <= '1' when _BLANK_ ; - O_incrAddress <= '1' when _BLANK_ ; - O_initSum <= '1' when _BLANK_ ; - O_loadSum <= '1' when _BLANK_ ; - O_loadY <= '1' when _BLANK_ ; - O_FilteredSampleValid <= '1' when _BLANK_ ; +-- O_loadShift <= '1' when SR_presentState = STORE else '0'; +-- O_initAddress <= '1' when _BLANK_ ; +-- O_incrAddress <= '1' when _BLANK_ ; +-- O_initSum <= '1' when _BLANK_ ; +-- O_loadSum <= '1' when _BLANK_ ; +-- O_loadY <= '1' when _BLANK_ ; +-- O_FilteredSampleValid <= '1' when _BLANK_ ; diff --git a/src/hdl/operativeUnit.vhd b/src/hdl/operativeUnit.vhd index 1286aff5a65b975b333b4136df7781bb98c0742e..19d2e1f65abda588cda120e3f78f3f13d09e0fd0 100644 --- a/src/hdl/operativeUnit.vhd +++ b/src/hdl/operativeUnit.vhd @@ -85,12 +85,17 @@ begin to_signed(2, 8) ); - shift : process (_BLANK_) is + shift : process (I_reset, I_clock) is begin -- process shift if I_reset = '1' then -- asynchronous reset (active high) SR_shiftRegister <= (others => (others => '0')); - elsif _BLANK_ - + elsif rising_edge(I_clock) then + if(I_loadShift = '1')then + SR_shiftRegister <= I_inputSample; + else + SR_shiftRegister(6 downto 0) <= SR_shiftRegister(7 downto 1); + SR_shiftRegister(7) <= I_inputSample; + end if; end if; end process shift;