I have a question about blocking commands in an always block in verilog.
For the simple code snippet below:
1 | always @(posedge clk) begin
|
2 |
|
3 | address <= address + 1;
|
4 |
|
5 | end
|
6 |
|
7 |
|
8 | always @(address) begin
|
9 |
|
10 | data = data | 8'h04;
|
11 |
|
12 | end
|
My question is:
How can I guarantee that the "data = data | 8'h04;" is completed before
the "address" changes on the next positive edge of the clock?
My solution (But with question about it):
1 | always @(posedge clk) begin
|
2 | //Only increase the address if the computation is complete
|
3 | if(!computingFlag) begin
|
4 | address <= address + 1;
|
5 | end
|
6 | end
|
7 |
|
8 |
|
9 | always @(address) begin
|
10 | computingFlag = 1'b1;
|
11 | data = data | 8'h04;
|
12 | computingFlag = 1'b0
|
13 |
|
14 | end
|
In the above I set a flag telling the address to not increment until the
computation is done.
Questions:
1) But is it guaranteed that the blocking statements will execute one
after another? The next will never execute till the first is over?
2) What if the "data = data | 8'h04;" statment was a computation that
completed so fast that the computing flag did not have enough time to
actually rise and fall? I'm talking about the physical limitation of the
hardware (it's speed). Or does the synthesizer guarantee that the
"computingFlag" will get to steady state before the next line is
implemented?
3) How can you tell if an always block will be executed one after
another instead of synthesizing into combinational logic?
Thank you for the insight
Matt