Hi,
I try to simulate the following code, but it hangs forever, don't know why?
Could you please help me out. But it runs when forever block got removed.
class timer_control;
//function timer_load (input bit cpu_timer_ld_dn, gate_rise_edge,
task timer_load (input bit cpu_timer_ld_dn, gate_rise_edge,
input bit [ 2:0] timer_modes,
ref bit load_timer_reg);
case (timer_modes)
3'd0 : load_timer_reg = cpu_timer_ld_dn;
3'd1 : load_timer_reg = gate_rise_edge;
3'd2 : load_timer_reg = (cpu_timer_ld_dn | gate_rise_edge);
3'd3 : load_timer_reg = (cpu_timer_ld_dn | gate_rise_edge);
3'd4 : load_timer_reg = cpu_timer_ld_dn;
3'd5 : load_timer_reg = gate_rise_edge;
//3'd0 : return (load_timer_reg = cpu_timer_ld_dn);
//3'd1 : return (load_timer_reg = gate_rise_edge);
//3'd2 : return (load_timer_reg = (cpu_timer_ld_dn | gate_rise_edge));
//3'd3 : return (load_timer_reg = (cpu_timer_ld_dn | gate_rise_edge));
//3'd4 : return (load_timer_reg = cpu_timer_ld_dn);
//3'd5 : return (load_timer_reg = gate_rise_edge);
//default: return (load_timer_reg = 1'b0);
default: load_timer_reg = 1'b0;
endcase
endtask
//endfunction
endclass
module test;
bit cpu_timer_ld_dn, gate_rise_edge;
bit [ 2:0] timer_modes;
bit load_timer_reg;
initial
begin
cpu_timer_ld_dn = 1'b0;
gate_rise_edge = 1'b0;
timer_modes = 3'd0;
#40;
cpu_timer_ld_dn = 1'b1;
#40;
cpu_timer_ld_dn = 1'b0;
#40;
$stop;
$finish;
end
initial
begin
timer_control control;
control = new();
forever
begin
control.timer_load(cpu_timer_ld_dn, gate_rise_edge, timer_modes, load_timer_reg);
end
end
endmodule