Hello
Could someone elaborate on the following please?
What would be the difference in functionality in the following two codes?
(the only difference is the blocking vs non-blocking assignments)
Versus
Q1)In the first version won't there be a danger that when the counter does go over that big number (3rd if statement) and led_d will be assigned to 1'b0 and if the switch is simultaneously pressed and the led_d will be assigned to 1'b1 . What would happen then? That's a conflict of drivers.
Q2)Also if I used blocking assignments in those if statements then would execute sequentially right?
Q3)Does it make sense to put a blocking and non-blocking assignment in an if statement? Won't they be executed synchronously anyway? (if it's just one bl and one non-bl)
Could someone elaborate on the following please?
What would be the difference in functionality in the following two codes?
(the only difference is the blocking vs non-blocking assignments)
Rich (BB code):
always @ (posedge clk) // counter
begin
if(switch == 1'b1) // switch is input
begin
led_d = 1'b1; // led_d is an led output
end
if(led_d == 1'b1)
begin
counter = counter + 1'b1;
end
if(counter > 26'd100000000)
begin
counter = 26'd0;
led_d = 1'b0;
end
end
Rich (BB code):
always @ (posedge clk) // counter
begin
if(switch == 1'b1) // switch is input
begin
led_d <= 1'b1; // led_d is an led output
end
if(led_d == 1'b1)
begin
counter <= counter + 1'b1;
end
if(counter > 26'd100000000)
begin
counter <= 26'd0;
led_d <= 1'b0;
end
end
Q2)Also if I used blocking assignments in those if statements then would execute sequentially right?
Q3)Does it make sense to put a blocking and non-blocking assignment in an if statement? Won't they be executed synchronously anyway? (if it's just one bl and one non-bl)
Last edited: