This is supposed to be an if statement. What really matters here is the byte_count
. When it reaches 6, it is going to execute the instructions in the elsif
. However, the problem is that the if
statement is within a process, so the transition to the next state will occur only on the next clock cycle. The state will remain in the preamble state, and it will enter the if
statement again, sending the PREAMBLE_PATTERN
again before transitioning to STREAM
. How can I handle that?
when PREAMBLE =>
S_TREADY <= '0';
crc_enable <= '0';
-- PREAMBLE State: Send the Ethernet preamble
if byte_count < 6 then
M_TDATA(7 downto 0) <= PREAMBLE_PATTERN;
M_TVALID <= '1';
M_TLAST <= '0';
byte_count <= byte_count + 1;
elsif byte_count = 6 then
M_TDATA(7 downto 0) <= SFD_PATTERN;
M_TVALID <= '1';
M_TLAST <= '0';
S_TREADY <= '1';
-- After sending 7 preamble bytes, transition to SFD state
next_state <= STREAM;
byte_count <= 0;
-- Reset the counter
end if;
This is supposed to be an if statement. What really matters here is the byte_count
. When it reaches 6, it is going to execute the instructions in the elsif
. However, the problem is that the if
statement is within a process, so the transition to the next state will occur only on the next clock cycle. The state will remain in the preamble state, and it will enter the if
statement again, sending the PREAMBLE_PATTERN
again before transitioning to STREAM
. How can I handle that?