Hi all,
This my first post for SystemVerilog code. Being a beginner I have written a simple code for counter and I want to display the start_time and end_time for each count data, more precisely I am trying to monitor the change and get the start and end time for that particular data.
The issue that I am facing is that “@(count)” is skipping the display of “count=01” and directly displaying “count=10” after “count=00”. Is there anything wrong with the coding constructs. Any solution will be of great help.
Please see the code and results of simulation below:
module counter(
input logic clk,
input logic rstn,
input logic start,
output logic[1:0] count
);
logic[1:0] prev_count;
time start_time;
always @(posedge clk)begin
if (rstn)begin
count <= '0;
end
if(start)begin
count = count + 1;
end else begin
count = count;
end
end
always @* begin
prev_count = count;
start_time = $time;
@(count)
$display("count= %b\t", prev_count, "<start_time=%0t\tend_time=%0t>", start_time,$time);
end
endmodule
The solution as of now is:
xcelium> run
count= 00 <start_time=0 end_time=10>
count= 10 <start_time=20 end_time=40>