Hi,
I wrote the following piece of code.
module assert_one_hot_three_states_fsm
(
input bit clk,
input bit reset,
input bit a,
input bit b,
input bit c
);
typedef enum bit [2:0] {st0 = 3'b001, st1 = 3'b010, st2 = 3'b100} assert_state_t;
assert_state_t assert_state;
always @(posedge clk) begin
if (reset == 1'b1) begin
assert_state <= st0;
end
else begin
case (assert_state)
st0 : begin
case ({c,b,a})
3'b000 : begin
assert_state <= st0;
end
3'b001 : begin
assert_state <= st0;
end
3'b010 : begin
assert_state <= st1;
end
default : begin
assert_state <= st0;
`uvm_error("assert_one_hot_three_states_fsm", "Description => Combination of input signals is not correct \n");
end
endcase
end
st1 : begin
case ({c,b,a})
3'b001 : begin
assert_state <= st0;
end
3'b010 : begin
assert_state <= st1;
end
3'b100 : begin
assert_state <= st2;
end
default : begin
assert_state <= st0;
`uvm_error("assert_one_hot_three_states_fsm", "Description => Combination of input signals is not correct \n");
end
endcase
end
st2 : begin
case ({c,b,a})
3'b001 : begin
assert_state <= st0;
`uvm_error("assert_one_hot_three_states_fsm", "Description => Loss of alignment \n");
end
3'b010 : begin
assert_state <= st0;
`uvm_error("assert_one_hot_three_states_fsm", "Description => Invalid FMS transition \n");
end
3'b100 : begin
assert_state <= st2;
end
default : begin
assert_state <= st0;
`uvm_error("assert_one_hot_three_states_fsm", "Description => Combination of input signals is not correct \n");
end
endcase
end
default : begin
assert_state <= st0;
end
endcase
end
end
ERROR_B_STABLE_WHEN_A_FALLS:
assert property (@(posedge clk) disable iff ((reset) | (!assert_state[0])) ($fell(a) |-> $rose(b)))
else begin //fail block
`uvm_error("assert_one_hot_three_states_fsm", "Description => a 1-> 0, then b is stable\n");
end;
ERROR_C_STABLE_WHEN_B_FALLS:
assert property (@(posedge clk) disable iff ((reset) | (!assert_state[1])) ($fell(b) |-> $rose(c)))
else begin //fail block
`uvm_error("assert_one_hot_three_states_fsm", "Description => b 1-> 0, then c is stable\n");
end;
ERROR_C_LOW:
assert property (@(posedge clk) disable iff ((reset) | (!assert_state[2])) (c))
else begin //fail block
`uvm_error("assert_one_hot_three_states_fsm", "Description => c = 0 \n");
end;
endmodule : assert_one_hot_three_states_fsm
The last assertion works properly but the other two do not activate at all.
Is there anything wrong with them?
Question: is it legal to declare a concurrent assertion within a procedural code like always@?
Thanks and regards
/Dario