J
Jonathan Bromley
Guest
On Fri, 18 Sep 2009 04:10:43 -0700 (PDT), Kenneth Brun Nielsen wrote:
reg [3:0] a, b;
reg clk;
// Make a stream of 5 clock pulses.
initial begin
clk = 0;
repeat (10) #5 clk = ~clk;
end
// Generate stimulus on a, b. It could
// come from a file, but let's use a count
// to keep the example simple.
initial begin
a = 0;
b = 0;
forever @(posedge clk) begin
$display("Detected a clock at time=%0d, $time);
a = a + 1; // should be synchronous with the clock
b <= #4 b - 1; // should be #4 later
$display("Done with the clock at time=%0d, $time);
end
end
always @(b)
$display ("b changed to %0d at time %0d", b, $time);
Try that and make sure it works the way you expect.
Now, here's the really important thing: If you change
"b <= #4 ...." to "b = #4 ..." you should find
that the second $display is postponed to 4 time units
after each clock. That's the difference between <=
and =. But if you change "b <= #4" to "b <= #14" then,
even though #14 is longer than a clock period, the
loop will execute on each clock edge as normal. It's the
updates on b that will be delayed.
unlikely that is the problem.
--
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.
In very short: I don't believe you.In short: making the assignment non-blocking did not change anything.
So, try this simple test to see whether it does what you want:In longer terms:
I have a for loop, that runs through a command file. When the read
command equals an input stimuli, the read values (which is a part of
the command) should be assigned to the inputs. The assignments should
happen while the test clock toggles (called cycleNo in previous post)
except for one assignment, which should be delayed 4 time units.
reg [3:0] a, b;
reg clk;
// Make a stream of 5 clock pulses.
initial begin
clk = 0;
repeat (10) #5 clk = ~clk;
end
// Generate stimulus on a, b. It could
// come from a file, but let's use a count
// to keep the example simple.
initial begin
a = 0;
b = 0;
forever @(posedge clk) begin
$display("Detected a clock at time=%0d, $time);
a = a + 1; // should be synchronous with the clock
b <= #4 b - 1; // should be #4 later
$display("Done with the clock at time=%0d, $time);
end
end
always @(b)
$display ("b changed to %0d at time %0d", b, $time);
Try that and make sure it works the way you expect.
Now, here's the really important thing: If you change
"b <= #4 ...." to "b = #4 ..." you should find
that the second $display is postponed to 4 time units
after each clock. That's the difference between <=
and =. But if you change "b <= #4" to "b <= #14" then,
even though #14 is longer than a clock period, the
loop will execute on each clock edge as normal. It's the
updates on b that will be delayed.
Icarus generally gets the basic Verilog stuff right. It'sUnfortunately I am not able to implement this delay. Neither with the
code posted earlier, OR with a non-blocking assignment (SCK <= #4
SCKi. I think the problem is related to the combination of @
(cycleNo) and the delayed assignment.
I simulate in Icarus Verilog.
unlikely that is the problem.
--
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.