- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am developing a fsm to latch on to incoming data and compute its average in verilog, but my fsm seems to be just stuck at one state.
Although the simulation shows it did shifted perfectly in previous states, but it is stuck at "filter_data_64" state . See complete code below :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have nextstate in your case statement, but state never updates to nextstate.
Fix it by adding a sequential block to update state at every clock edge.
always @(posedge clk) begin
if (~rst)
state <= idle;
else
state <= nextstate;
end
I would recommend to checkout 'Two Always Block FSM coding style' from the article below.
It uses two separate always blocks:
- State Register Block: A sequential (always_ff ) block that updates the current state (state_reg) on the clock edge.
- Next State & Output Logic Block: A combinational (always_comb) block that determines the next state and the outputs based on the current state and inputs.
http://www.sunburst-design.com/papers/CummingsSNUG2019SV_FSM1.pdf
Regards,
Richard Tan
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the simulation results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have nextstate in your case statement, but state never updates to nextstate.
Fix it by adding a sequential block to update state at every clock edge.
always @(posedge clk) begin
if (~rst)
state <= idle;
else
state <= nextstate;
end
I would recommend to checkout 'Two Always Block FSM coding style' from the article below.
It uses two separate always blocks:
- State Register Block: A sequential (always_ff ) block that updates the current state (state_reg) on the clock edge.
- Next State & Output Logic Block: A combinational (always_comb) block that determines the next state and the outputs based on the current state and inputs.
http://www.sunburst-design.com/papers/CummingsSNUG2019SV_FSM1.pdf
Regards,
Richard Tan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI Richard,
Yes changed the fsm to have two separate always block :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dropping a note to ask if my last reply was helpful to you.
Do you able to resolve the issue?
Regards,
Richard Tan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for acknowledging the solution provided. I'm pleased to know that your question has been addressed.
Now, I will transitioning this thread to community support. If you have any further questions or concerns, please don't hesitate to reach out. Please login to https://supporttickets.intel.com/s/?language=en_US , view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support.
The community users will be able to help you on your follow-up questions.
Thank you and have a great day!
Best Regards,
Richard Tan

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page