Forum Discussion
Altera_Forum
Honored Contributor
15 years agohey guys homework help
i have the following program which makes a finite state machine.it compiles but doesnt simulate what could be wrong?this is the code i came up with for he question This is an exercise in using fin...
Altera_Forum
Honored Contributor
15 years agoIf I understood correctly what you want to obtain, your code is a mess.
In particular: Why that 9bit register for a single output? You can do it with this much simpler code, involving a simple shift register.
module part1a(clk, in, reset, out);
input clk, in, reset;
output out;
reg out;
reg shifter;
always @(posedge clk or posedge reset)
begin
if (reset)
begin
out <= 1'b0;
shifter <= 4'b0101;
end
else
begin
if (shifter == 4'b0000)
out <= 1'b0;
else if (shifter == 4'b1111)
out <= 1'b1;
shifter <= { shifter , in };
end
end
This is only sort of template; check syntax and operation. Regards