Non-Block and Block in Verilog
Non-Block and Block in Verilog
// Nonblocking assignments
module block_nonblock();
initial begin
reg a, b, c, d , e, f ; d <= #10 1'b1;// The simulator
assigns 1 to d at time 10
// Blocking assignments
e <= #20 1'b0;// The simulator
initial begin assigns 0 to e at time 20
a = #10 1'b1;// The simulator assigns 1 to a at time 10
f <= #40 1'b1;// The simulator
b = #20 1'b0;// The simulator assigns 0 to b at time 30 assigns 1 to f at time 40
c = #40 1'b1;// The simulator assigns 1 to c at time 70 End
end
endmodule
Blocking
module blocking (clk,a,c);
input clk; always @ (posedge
input a; clk )
output c; begin
b = a;
wire clk; c = b;
wire a;
end
reg c;
reg b;
endmodule
Non-Blocking
• module nonblocking (clk,a,c); always @ (posedge
• input clk; clk )
• input a; begin
• output c; b <= a;
• c <= b;
• wire clk; end
• wire a;
• reg c; endmodule
• reg b;
LCD Control
module lcdverilog(input clk, output data, output lcd_e, output
lcd_rw,output lcd_rs, input reset);
else if (count > 1000000 && count < 2000000) begin count = count + 1; lcd_e = 1; end // delay
else if (count >= 2000000) begin count = 0; data_comand = data_comand +1; end