Forum Discussion
Altera_Forum
Honored Contributor
14 years agoLatch Inferrence
Hey guys,
Lets say you have a simple state machine output assignment block like the one below:
always @(pstate)
begin
case(pstate)
s0:
begin
out1<=0;
out2<=1;
end
s1:
begin
out1<=1;
out2<=0;
end
default:
begin
out1<=0;
out2<=0;
end
endcase
end
When you compile the above code, you get infered latches for the outputs, which are bad. How can I get around this? I don't want to use simple assign statements for the outputs, because the idea is to keep the value of a signal until a different state arrives. For example, if I am in state 0, I want out2 to remain high until s1 is reached. Of course, this requires memory. But I don't want to infer latches. And if I use a posedge clock in the sensitivity list, I get unexpected results. Any ideas would be greatly appreciated.3 Replies
- Altera_Forum
Honored Contributor
This is a address I think it will help you!
http://www.alterawiki.com/w/index.php?title=special%3asearch&search=+state+machine&go=go - Altera_Forum
Honored Contributor
In the present case, no latches are inferred. You get latches, if the variables are not assigned in all branches of the case construct.
- Altera_Forum
Honored Contributor
Yes in this code you cant get a latch...