SystemVerilog Repeat with no Begin

Status
Not open for further replies.

forkconfig

Member level 1
Joined
Jan 28, 2013
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,655
I am trying to learn SV on my own and came accross this piece of code:

task reset();
##1 fifo_io.cb.resetb <= 1'b1;
##1 fifo_io.cb.resetb <= 1'b0;
fifo_io.cb.in_vld <= 1'b0;
fifo_io.cb.out_rdy <= 1'b0;
##1 fifo_io.cb.resetb <= 1'b1;
repeat (2) @(fifo_io.cb);
endtask: reset

What I am curious about is what repeat does since there is no begin or end, so what's it repeating? And what does "@(fifo_io.cb)" do?

- - - Updated - - -

Actually one more question, for the code bellow I don't understand what "@(design_io.cb);" is doing.
Essentially it is saying @(clocking block)...so I am assuming it is similar to @(posedge clk), but not sure?
Also just as important, I am not sure what the statement applies to (again with no

task push(input int num = 1);
for (int i = 0; i < num; i++) begin
<stuff>
@(design_io.cb);
end

<more stuff>
@(design_io.cb);
endtask: push
 

begin/end works like { } in C. Where ever one procedural statement is allowed, you can use begin statement; statement; end. begin/end comes from the Pascal programming language, which was popular at the time Verilog was invented. Many people like to use begin/end around a single statement just for readability.

Code:
if (expr)
     statement1;
     statement2;
if (expr2) 
   begin
     statement3;
   end
     statement4;
Only statements 1 and 3 are conditional, but it is much clearer for statement3.

Also, any procedural statement maybe proceeded by one or more event controls, and that statement can be the null statement which is blank.
The syntax for the repeat statement is

repeat ( expression ) statement;

So your expression is 2, and the statement is null, and the event control is @(fifo_io.cb)
That code could also be written as
Code:
repeat(2) 
  begin 
    @(fifo_io.cb);
  end

or
repeat(2) 
  @(fifo_io.cb) 
  begin 
    ;
  end
it's all the same.
 

Thanks for the helpful explanation.
So for this particular example:

task reset();
##1 fifo_io.cb.resetb <= 1'b1;
##1 fifo_io.cb.resetb <= 1'b0;
fifo_io.cb.in_vld <= 1'b0;
fifo_io.cb.out_rdy <= 1'b0;
##1 fifo_io.cb.resetb <= 1'b1;
repeat (2) @(fifo_io.cb);
endtask: reset


It is repeating "@(fifo_io.cb)" twice. But what does "@(fifo_io.cb)" do exactly?
Understanding that will probably help me understand the second example better as well.

task push(input int num = 1);
for (int i = 0; i < num; i++) begin
<stuff>
@(design_io.cb);
end

<more stuff>
@(design_io.cb);

Thanks
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…