questions on task in interface in systemverilog

J

JoshforRefugee

Guest
I have a interface defined like this

interface my_if (input bit clk);
bit valid;

clocking clk_bg @(posedge clk);
output valid;
endclocking;

function void write(bit in_value)
valid = in_value; ???? SHOULD I USE BLOCKING ON NON-BLOCKING
HERE?????
endfunction;

modport mp (clocking clk_bg, import write);

endinterface: my_if

Should I use blocking or non-blocking statment in my write task? and
why? thank you.
 
On 23 Feb 2007 02:04:23 -0800, "JoshforRefugee" <ankitks@yahoo.com>
wrote:

I have a interface defined like this

interface my_if (input bit clk);
bit valid;

clocking clk_bg @(posedge clk);
output valid;
endclocking;

function void write(bit in_value)
valid = in_value; ???? SHOULD I USE BLOCKING ON NON-BLOCKING
HERE?????
endfunction;

modport mp (clocking clk_bg, import write);

endinterface: my_if
I suspect this is not doing what you want.

Your function writes directly to "valid", and does NOT go through the
clocking block.

If you want to use the clocking block for synchronisation and timing,
you must write not to the variable itself but to the "clockvar" - the
version of the variable that is made available through the clocking.
Like this:

function void write_via_clocking(bit in_value);
clk_bg.valid <= in_value;
endfunction

Note that this is not a nonblocking assignment. It's a synchronous
clocking drive, which is rather different (even though it uses the
same syntax).

--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
function void write_via_clocking(bit in_value);
clk_bg.valid <= in_value;
endfunction
Thanks Jonathan for clearing this for me.


Note that this is not a nonblocking assignment. It's a synchronous
clocking drive, which is rather different (even though it uses the
same syntax).
all right..so synchronous clocking drive..that just means that you are
driving with condition specified by clocking block (setup and hold)
right?

Thanks again
 
On 24 Feb 2007 11:01:56 -0800, "JoshforRefugee"
<ankitks@yahoo.com> wrote:

synchronous clocking drive..that just means that you are
driving with condition specified by clocking block (setup and hold)
right?
Pretty much. There are a few other kinks, many of which were not
100% clear in the 1800-2005 LRM and are currently being straightened
out by the SV-EC group. The most important issue to note is that
synchronous drives are just that - synchronous with the clocking's
event, though delayed by the clocking output skew - so you need
to be careful if you do a clocking drive at a time that is not the
moment of a clocking event. If you do so, the drive statement
evaluates its right-hand side expression immediately, and
goes on to the next statement (nonblocking behaviour); but
driving the clocking output is postponed until the next clocking
event, so that the drive is truly synchronous.

Generally it's a smart move to execute your synchronous drives
at the moment of the clock edge. Something like this:

initial begin....
repeat (N) begin
@cb; // wait for the next clock edge
cb.out_signal <= expression; // synchronous
end

--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
thanks Jonathan..is there any twist for reading also?

task tx read();
tx my_tx;
my_tx.valid = cb.valid;
my_tx.data = cb.data;
return tx;
endtask: tx_read
 

Welcome to EDABoard.com

Sponsor

Back
Top