I have tried many different ways to get my code to change states, but no matter
ID: 3624710 • Letter: I
Question
I have tried many different ways to get my code to change states, but no matter how I manipulate the code my simulation just remains in state SO and does not change. I have a portion of my code for the state diagram below. Where C, TL, and TS are inputs and ST is an output. Could someone please help as to what I might be doing wrong. Please keep in mind that this is not my entire code just a sample of the state coding followed by a sample of the output assignment.type state_type is (S0, S1, S2, S3, S4, S5);
signal PS, NS: state_type;
begin
process (C, TS, TL, PS, NS)
begin
case PS is
when S0 =>
if (C = '1') then
NS <= S1;
else
NS <= S0;
end if;
when S1 =>
if (TL = '1') then
NS <= S2;
else
NS <= S1;
end if;
with PS select --output logic
ST <= '0' when S0,
'1' when S1,
'1' when S2,
'0' when S3,
'1' when S4,
'1' when S5,
'0' when others;
Explanation / Answer
Ok so I realize this is not all of your code but one of the problems you may be having is that you need to make sure to end your case statement before you use the with statement. This is because cases are sequential and with is concurrent. But if you want everything to be sequential wou can put the output into the case statement as follows: