projectx100
Newbie level 3
- Joined
- Aug 6, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 21
Howdy all,
We've wrritten the following code which implements a finite state machine:
We ran a simulation on that module and it looks like vc_state_ps doesn't sample vc_state_ns on clk rising on certain situations.
We've attached the waveform showing the problem. Using the $display command we see in the log that the values used are the values after the clk risen and not before..
Do you have any idea where is the problem?
Thanks,
ProjectX.
We've wrritten the following code which implements a finite state machine:
Code:
always_comb // vc global state transition implementation
begin
case (vc_state_ps)
IDLE : vc_state_ns = idle_2_cred ? CRED : (idle_2_active ? ACTIVE : (idle_2_route ? ROUTE : vc_state_ps));
ROUTE : vc_state_ns = route_2_va ? VA : vc_state_ps;
VA : vc_state_ns = va_2_cred ? CRED : (va_2_active ? ACTIVE : vc_state_ps);
ACTIVE : vc_state_ns = active_2_cred ? CRED : (active_2_idle ? IDLE : vc_state_ps);
CRED : vc_state_ns = cred_2_active ? ACTIVE : vc_state_ps;
default: vc_state_ns = IDLE;
endcase
end
logic [2:0] vc_state_prev;
always_ff @(posedge clk or posedge reset)
begin
if (reset)
begin
vc_state_ps <= IDLE;
vc_state_prev <= IDLE;
end
else
begin
$display("Updated VC state %t for %d: %b, %b", $time, MY_VC, vc_state_ns, vc_state_ps);
vc_state_ps <= vc_state_ns;
vc_state_prev <= vc_state_ps;
end
end
We ran a simulation on that module and it looks like vc_state_ps doesn't sample vc_state_ns on clk rising on certain situations.
We've attached the waveform showing the problem. Using the $display command we see in the log that the values used are the values after the clk risen and not before..
Do you have any idea where is the problem?
Thanks,
ProjectX.