Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

simulation tricks using modelsim

Status
Not open for further replies.

pwq1999

Member level 2
Joined
Mar 2, 2008
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,578
modelsim expanded time

i write test bench using verilog,my input signals change at the same time with the rising edge of clock. now question is , my clock's rising edge detect the signals' value which is after the clock's rising edge, but i think the input signals' value should be before the the clock's rising edge.

any tricks can be suggested when simulating with modelsim ?

thanks!
 

I assume that you are doing simple behavioral simulation of synchronous logic, and not concerned about actual input setup and hold times.

Here's one technique. When you generate the clock in your testbench, use that same clock to generate the synchronous control signals for your module being tested.

For example, this testbench generates a 50 MHz clock and a "down" control signal to the up/down counter in the "top" module.

Code:
`timescale 1 ns / 1 ps

module testbench;
  reg               clk = 1;
  reg         [4:0] count = 0;

  top top (.clk(clk), .down(count[4]));

  always #10 clk = ~clk;

  always @ (posedge clk) begin
    count <= count + 1;
  end
endmodule


module top (clk, down, count);
  input             clk;
  input             down;
  output reg  [3:0] count = 0;

  always @ (posedge clk) begin
    count <= down ? count-1 : count+1;
  end
endmodule
 

yes, i am doing behavioral simulation of synchronous logic,but why some signal change with the clock concurrently, the clock sometimes can detect the right value and sometimes it doesn't ?

thanks!
 

If you closely examine the simulated waveforms, the registers may appear to change simultaneously with the clock, but they actually change after an infinitesimal delay. When posedge occurs, the Verilog simulator schedules the register change events so they occur simultaneously, so your design should behave sensibly.

(By the way, ModelSim 6.4 provides a new "Expanded Time" feature that shows you those individual events, even though they occur over zero time.)

If you are still having difficulty with your project, you can upload your code here, and someone may help you debug it.
Also, be sure you've installed the latest service packs for your simulator.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top