From: Michael McNamara (mac@surefirev.com)
Date: Tue Jul 13 1999 - 13:16:01 PDT
You get 4 right and 4 wrong, a grade of 50%.
However this is the ninetys, so we have to wait to see how your raw
score falls on the curve... :-)
Clifford E. Cummings writes:
> Dear BTF -
>
> In order to accurately complete the BNF I have a few questions.
>
> delay_or_event_control ::=
> delay_control
> | event_control
> | repeat ( expression ) event_control
> delay_control ::=
> # delay_value
> | # ( mintypmax_expression )
> event_control ::=
> @ event_identifier
> | @ ( event_expression )
> 1999 B08> | @*
> 1999 B08> | @ (*)
>
> Are the following legal and what do they mean?
>
> sum = @* a + b;
> sum <= @* a & b;
>
> Looks like redundant event controls to me (whenever a or b change, do the
> respective blocking or nonblocking assignment)
Nope.
As presented (without an assign) they are evidently procedural
statements. The correct interpretation is:
sum = @(a or b) a+b;
sum <= @(a or b) a+b;
The first calculates the current sum of 'a' and 'b' into a
temp, then blocks further execution until 'a' or 'b' changes, then
assigns the value of the temp to 'sum'.
Then (and only then) the next statement is executed; it
calculates the value of 'a' and 'b' into a temp, and schedules a non
blocking assign event to occur at some point in the future when a or b
changes. At that time the value of the temp will be scheduled as a
NBA update to the value of sum.
Given:
module foo;
reg [7:0] a,b,sum;
initial begin
#100;
$display($stime,,"Waiting; a is %d b is %d a+b is %d ",a,b,a+b);
sum = @(a or b) a+b;
$display($stime,,"OK 1, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
sum <= @(a or b) a+b;
$display($stime,,"OK 2, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
@(a or b);
#10 $display($stime,,"OK 3, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
end
initial begin
a = 3;
b = 5;
#200;
a = 15;
#100;
b = 20;
#100;
b = b + 1;
end
endmodule // foo
we see:
100 Waiting; a is 3 b is 5 a+b is 8
200 OK 1, a is 15 b is 5 a+b is 20; sum is 8
200 OK 2, a is 15 b is 5 a+b is 20; sum is 8
310 OK 3, a is 15 b is 20 a+b is 35; sum is 20
If you meant to ask about:
assign sum = @* a + b;
assign sum <= @* a & b;
Then these are simply illegal syntax; one cannot use a non
blocking assign, or a blocking delay in an continuous assign
statement.
Try:
assign sum = @(a or b) a + b;
assign sum <= @(a or b) a & b;
to see what I mean.
You might be thinking about
assign #(10) sum = a + b;
but for these only delays (variable or fixed) are allows; not
event_control
<p><p> >
> Is the following legal?
>
> sum <= repeat (3) @* a + b;
Yeap.
>
> Wait for three events on a or b?
Yeap.
Consider:
module foo;
reg [7:0] a,b,sum;
initial begin
#100;
$display($stime,,"Waiting; a is %d b is %d a+b is %d ",a,b,a+b);
sum = @(a or b) a+b;
$display($stime,,"OK 1, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
sum <= @(a or b) a+b;
$display($stime,,"OK 2, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
@(a or b);
#10 $display($stime,,"OK 3, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
sum <= repeat (3) @(a or b) a + b;
#1000 $display($stime,,"OK 4, a is %d b is %d a+b is %d; sum is %d", a,b,a+b,sum);
end
integer i;
initial begin
a = 3;
b = 5;
#200;
a = 15;
#100;
b = 20;
#100;
b = b + 1;
for (i = 0; i < 10; i= i + 1)begin
#100 a = a +1;
$display($stime,,"a is %d",a);
end
end
endmodule // foo
I see:
100 Waiting; a is 3 b is 5 a+b is 8
200 OK 1, a is 15 b is 5 a+b is 20; sum is 8
200 OK 2, a is 15 b is 5 a+b is 20; sum is 8
310 OK 3, a is 15 b is 20 a+b is 35; sum is 20
500 a is 16
600 a is 17
700 a is 18
800 a is 19
900 a is 20
1000 a is 21
1100 a is 22
1200 a is 23
1300 a is 24
1310 OK 4, a is 24 b is 21 a+b is 45; sum is 35
1400 a is 25
>
> Is the following legal?
>
> repeat (3) @(posedge clk) y = a + 1; // execute y = a+1 three times on the
> next three posedge clks
Sorry. It's legal, but Nope, you have the meaning
wrong. Correct meaning is:
evaluate a + 1 into a temp. block until the occurance of 3
posedges on clk. Assign temp to y.
> repeat (3) @(posedge clk); y = a + 1; // wait for three posedge clks and
> then execute y = a+1
Yeap.
> repeat (3) @(*) y = a + 1; // execute y = a+1 three times on the next
> three changes on "a"??
Nope. Right answer is:
Evaluate a+1 into a temp.
Wait for three changes on 'a'.
Assign temp to y.
> repeat (3) @*; y = a + 1; // No wait (wasted repeat statement with @*) but
> execute y = a+1 ????
Yeap.
>
> Wait for three events on a or b?
Nope.
>
> - Cliff
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> //********************************************************************//
> // Cliff Cummings E-mail: cliffc@sunburst-design.com //
> // Sunburst Design, Inc. Phone: 503-579-6362 / FAX: 503-579-7631 //
> // 15870 SW Breccia Dr., Beaverton, OR 97007 //
> // //
> // Verilog & Synthesis Training //
> // Verilog, VHDL, Synopsys, LMG, FPGA, Consulting and Contracting //
> //********************************************************************//
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:53:28 PDT
and
sponsored by Boyd Technology, Inc.