0
\$\begingroup\$

I am learning VHDL. I have doubt regarding execution of If Else inside process statement. My code is :

entity test is
port(
 clk : in std_logic;
 reset : in std_logic;
 enable : in std_logic;
 a :in std_logic_vector(15 downto 0);
 b :out std_logic_vector(15 downto 0)
 ); 
 end test;
 
 architecture test_behave of test is 
 signal temp1:std_logic_vector(15 downto 0);
 type states is (state1,state2);
 signal present_state:states;
 
 begin 
 process(clk,reset)
 begin
 if(reset='1') then
 
 temp1<=(others=>'0');
 present_state<=state1;
 
 elsif(rising_edge(clk)) then 
 case present_state is
 
 when state1=> 
 if(enable='1') then--- if fir_enable='1' then NLMS block is enabled 
 temp1<=a; 
 present_state<=state2;
 else
 present_state<=state1;
 end if;
 
 when state2=>
 
 b<=temp1;
 present_state<=state1;
 end case;
 end if;
 end process;
 end test_behave;

Then I have added a testbench for evaluating this module. In that testbench, reset is high for first clock cycle and enable is low. At that time, present state is state1. Then in the next clock cycle, reset is made low and enable is made high and input data is given to a. The present state became state2. However temp1 variable didn't get the value of a in the same clock cycle even though both temp1 and present state are both signals.

enter image description here

toolic
10.8k11 gold badges31 silver badges35 bronze badges
asked Oct 27, 2021 at 8:28
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Temp is assigned on the first clock edge where all three of:

  • Enable = true
  • A has a value
  • Present_state = state1

exactly as the code specifies.

answered Oct 27, 2021 at 14:14
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.