Home
Welcome
Information


FPGA projects - Basic
Music box
LED displays
Pong game
R/C servos
Text LCD module
Quadrature decoder
PWM and one-bit DAC
Debouncer
Crossing clock domains
The art of counting
External contributions

Interfaces
RS-232
JTAG
I2C
EPP
SPI
PCI
PCI Express
Ethernet
HDMI
SDRAM

Advanced
Digital oscilloscope
Graphic LCD panel
Direct Digital Synthesis
CNC steppers
Spoc CPU core

Hands-on
A simple oscilloscope


FPGA introduction
What are FPGAs?
How FPGAs work
Internal RAM
FPGA pins
Clocks and global lines
Download cables
Configuration
Learn more

FPGA software
Design software
Design-entry
Simulation
Pin assignment
Synthesis and P&R

FPGA electronic
SMD technology
Crystals and oscillators

HDL info
HDL tutorials
Verilog tips
VHDL tips

Quick-start guides
ISE
Quartus-II

Site
Links
HDL tutorials
Forum


FPGA simulation

Once the hardware design entry is completed (using either a schematic or an HDL), you may want to simulate your design on a computer to gain confidence that it works correctly before running it in an FPGA. Simulation requires a form of input stimulus and then FPGA simulator software can determine the corresponding outputs.

There are two ways to create input stimulus:

Interactive waveform editor

Using an interactive waveform editor, you enter the shape of the inputs (with a few clicks of your computer mouse), and the simulator software draws the shape of the outputs.

Interactive waveform editors were nice for beginners (easy to learn) but are now a dying breed (as much for their limitations than marketing reasons) so you will probably have to do it the hard way...

Testbench

A testbench is a non-synthesizable HDL design that creates stimulus for another (usually synthesizable) design. It is a bit harder to setup than an interactive waveform editor but a lot more powerful.

For example, let's assume that this synthesizable "gates" circuit needs to be exercised.

module gates(a, b, q, r);
input a, b;
output q, r;

assign q = a & b;    // one AND gate
assign r = a | b;     // one OR gate
endmodule

A testbench could be:

module testbench_for_gates;

// we create some stimulus by toggling the signals "a" and "b" every 50 time-units
reg a, b;
initial
begin
  a = 0; b = 0;
  #50 a = 1;
  #50 a = 0; b = 1;
  #50 a = 1;
  #50 $finish;
end

// and we apply the stimulus to "gates". In response, "gates" drives "q" and "r" signals
wire q, r;
gates my_gates(a, b, q, r);

// and we can verify that "q" and "r" have the right values
always @(a or b) if(q != (a & b)) $display("ERROR in signal q");
always @(a or b) if(r != (a | b)) $display("ERROR in signal r");
endmodule

The testbench is usually written in the same language (VHDL or Verilog) than your circuit under test.

FPGA software provide HDL simulators, like ISim and ModelSim. Or check the List of Verilog simulators from Wikipedia.



>>> NEXT - part 4: FPGA pin assignment >>>



This page was last updated on May 21 2013.