Guest
Hi
I am doing a testbench on a design that has multiple sub-blocks. Each
sub-block has a "trig" input, a "done" output and a "data" output. When
trig is asserted for one clock cycle, the done is asserted for one
cycle after a variable number of cycles. During that cycle, "data" has
a valid data. I need to trigger each sub-block multiple times and I am
expecting a fixed sequence of data. I want to verfiy that I am getting
that data.
My plan is to write a generic task that will work for all the
sub-blocks. I want to pass on the hierarchial name e.g
u_subblock1.trig, u_subblock1.done into the following task.
task checkdata;
input trig;
inout(??) done;
inout (??) data;
input refdata;
begin
force trig = 1;
@ ( posedge clk );
force trig = 0;
@ ( posedge clk );
while (!done) @ ( posedge clk );
if ( data !== refdata )
$display ("test failed");
else
$display ("test ok");
end
endtask
I am calling this task from the testbench as follows
checkdata (u_subblock1.trig, u_subblock1.done, u_subblock1.data,
subblk1_refdata1 );
checkdata (u_subblock1.trig, u_subblock1.done, u_subblock1.data,
subblk1_refdata2 );
....
....
checkdata (u_subblock2.trig, u_subblock2.done, u_subblock2.data,
subblk2_refdata1 );
checkdata (u_subblock2.trig, u_subblock2.done, u_subblock2.data,
subblk2_refdata2 );
....
....
Is something like this possible with verilog? Can I use some form of
`define or parameter to achieve this?
Thanks.
-Dipankar
I am doing a testbench on a design that has multiple sub-blocks. Each
sub-block has a "trig" input, a "done" output and a "data" output. When
trig is asserted for one clock cycle, the done is asserted for one
cycle after a variable number of cycles. During that cycle, "data" has
a valid data. I need to trigger each sub-block multiple times and I am
expecting a fixed sequence of data. I want to verfiy that I am getting
that data.
My plan is to write a generic task that will work for all the
sub-blocks. I want to pass on the hierarchial name e.g
u_subblock1.trig, u_subblock1.done into the following task.
task checkdata;
input trig;
inout(??) done;
inout (??) data;
input refdata;
begin
force trig = 1;
@ ( posedge clk );
force trig = 0;
@ ( posedge clk );
while (!done) @ ( posedge clk );
if ( data !== refdata )
$display ("test failed");
else
$display ("test ok");
end
endtask
I am calling this task from the testbench as follows
checkdata (u_subblock1.trig, u_subblock1.done, u_subblock1.data,
subblk1_refdata1 );
checkdata (u_subblock1.trig, u_subblock1.done, u_subblock1.data,
subblk1_refdata2 );
....
....
checkdata (u_subblock2.trig, u_subblock2.done, u_subblock2.data,
subblk2_refdata1 );
checkdata (u_subblock2.trig, u_subblock2.done, u_subblock2.data,
subblk2_refdata2 );
....
....
Is something like this possible with verilog? Can I use some form of
`define or parameter to achieve this?
Thanks.
-Dipankar