In the code below, I want to pull out statements surrounding the the ** asterisks ** below.
stateS0 = 1' and o_done = '1'
and
o_done = '1' and stateS0 = '0'
into separate comparisons using if or elseif.
I am struggling at how to pull out and compare if I am in state S0 and o_done = 1 and I am in state 1 and o_done = 1 into seperate if, then, else, elsif statements.
process begin
wait until rising_edge(clk);
if (reset = '1') then
stuff;
else
**if( StateS0 = '1' AND o_done = '1' ) then**
stuff;
elsif( ...stuff... ) then
stuff;
end if;
end if;
end process;
process begin
wait until rising_edge(clk);
if (reset = '1') then
o_done <= '0';
else
if ( ...stuff ...) then
o_done <= '1';
**elsif ( o_done = '1' AND StateS0 = '0' ) then**
o_done <= '1';
else
o_done <= '0';
end if;
end if;
end process;
I was thinking something like:
if stateS0=0 then if
o_done='1' then...
if o_done='1' then if
stateS0='1' then...
but can you do...
process begin
wait until rising_edge(clk);
if (reset = '1') then
stuff;
else
if( state0 = '1') then
if o_done='1' then
stuff;
end if;
end if;
elsif( stuff ) then
stuff;
end if;
end process;
is that legal code ?
Or is this legal ?
process begin
wait until rising_edge(clk);
if (reset = '1') then
o_done <= '0';
else
if ( stuff ) then
o_done <= '1';
elsif ( o_done = '1') then
if state0 = '0' ) then
o_done <= '1';
else
o_done <= '0';
end if;
end if;
end process;
But I am not sure about if I am nesting these right. Can you nest an:
if
if
end if
end if
within after an elsif or else ?
Can you nest elseif in if, then else statements ? Or elseif only check 0 or 1 conditions and not combinatorial conditions like if then else can ?