Please format your code making your code easier for others to read. I have done that for you.
Nonblocking assignments are used to prevent race conditions between synchronous logic blocks. NBAs have higher overhead compared to regular blocking assignments, so they should only be used when absolutely necessary.
The clock signal is not in a race with any other process so regular blocking assignment should be used.
The reason initial/forever
is used instead of always
is when there are multiple clocks, as it’s easier to introduce a skew.
initial begin
clk1 = 1;
#2 forever #5 clk1 = ! clk1;
end
initial begin
clk2 = 0;
#4 forever #5 clk2 = ! clk2;
end