Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

ModelSim undefined initial value

Hello, I am trying to do some simple simulation using modelsim-altera and am seeing undefined value for output "result" and it stays like that until 10ns or so into the simulation. Here is the example:

counter.v

module counter (clk, reset, result);
input clk;
input reset;
output reg  result;
initial# 0 result = 0;
always @(posedge clk or posedge reset)
begin
   if (reset)
      result   <= 0;
   else
      result   <= result + 1'b1;
end
endmodule

counter_tb


`timescale 1ns/1ps
module counter_tb ();
reg clk;
reg reset;
wire  result;
counter u_count (clk, reset, result);
initial
begin
  # 0 clk   = 0;
   
  # 0 reset = 1;
  # 100 reset = 0;
end
always# 2.5 clk = ~clk;
endmodule

The waveform is shown in the attached jpeg. This happens when I select Gate Level Simulation. Any ideas why "result" is undefined?

Thank you

15 Replies