Subject: Re: end of simulation
From: Adam Krolnik (krolnik@lsil.com)
Date: Fri Mar 22 2002 - 10:44:03 PST
Hi Harry;
>Did the SUPERLOG finish block
Superlog has a 'finish' block?
Like:
initial begin
clk = 0;
forever #10 clk = ~clk;
end
finish begin
$display("We are exiting now...");
$display("We ran %d cycles today.", cycle);
end
Does this get called when $finish() is executed? That would be
nice. I have (too many times) implemented something similar to
this. And I have used it to show statistics, etc. before the
simulation actually closes up...
E.g. shutting_down is a signal asserted when we are going to say
$finish()...
forever @(posedge `clk or posedge scp.shutting_down)
begin
// When ending, check all registers.
if (scp.shutting_down)
begin
ctrl1mask = 16'hffff;
ctrl2mask = 16'hfdfb; // Don't check smode.
ctrl3mask = 16'hffff;
ctrl4mask = 16'hfffc; // Don't check timers
loopmask = 16'hffff;
end
Having this kind of statement allows one to have a standard
way to perform cleanup, reporting, extra checking, etc.
While we are on the end of simulation, here is what I was thinking
that would make the assertions most portable to different
environments, companies, etc. (e.g. IP with portable/useable
assertions.)
$error_count() - System function that returns the number of
errors that have occurred [when a error does occur?].
Having this, I could do the following:
module myIP(
...
);
// Input assertions (to protect myself from mistaken users code.)
always @(posedge clk)
begin
legal_stuff: assert_strobe (...)
@@(posedge clk)
else $error("Section 2.2.1 violation, 'Illegal command was
presented. cmd=%h", cmd);
...
end
endmodule
I use this IP in my design and in my testbench code, I say:
module testbench (...
initial begin
#0; // Allow for others to override.
if (!$value$plusargs("error_limit=%d", error_limit)
&& error_limit === 32'bx)
error_limit = 1;
wait($error_count() >= error_limit);
// Oops, we got too many errors, let's quit.
# shutdown_delay;
if (stop_instead) $stop;
else $finish; // And run the finish blocks...
end
Now, I can detect errors, assertions, etc. from my companies code
and from the IP that I bought from someone else. I don't need
to go and instrument their code to put my specific error handling
into there. I have a method of detecting assertion failures and
handling them - be it to continue, stop, return an error code,
write a file, etc.
If I could override the $error(), $warning(), etc system tasks
with my own equivalent + extra functionality, I could then do
this myself. But it may be that I can't directly get the original
functionality easily... So adding something like this would
provide a standard way to work with the assertions people will add.
$error_count(), $warning_count() both should be provided.
Adam Krolnik
Verification Mgr.
LSI Logic Corp.
Plano TX. 75074
This archive was generated by hypermail 2b28 : Fri Mar 22 2002 - 10:46:23 PST