You are getting an "out-of-memory" error because it is an non-blocking infinite loop adding future events to the scheduler.
always
is functionally equivalent to initial while(1)
(an infinite loop). <= #5
doesn't consume time, it schedules an update in the future. There is no time blocking delays in the loop.
Without a time blocking delay the simulator keeps executing the same loop in the same time step. The simulate will not move to the next time step until all operations in the current time step are complete or suspended. Eventually the simulator will run out of memory and error out. Some simulators may exit out early if an infinite loop is detected.
Typically, clocks are generated with LHS delays and with blocking statements. Examples:
reg clk = 1'b1; // or 1'b0
always #5 clk = !clk;
or
reg clk;
initial begin
clk = 1'b1; // or 1'b0
forever #5 clk = !clk;
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…