Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

WireFrame FPGA Board, Validating counter modules with ModelSim Tutorial

WireFrame FPGA Board, Validating counter modules with ModelSim Tutorial
this article is second part of creating  your first design with FPGA and verilogHDL, in particular WireFrame FGPA Board Xilinx XC3S250E board.

have created and implemented a basic counter module so that we can blink few leds. now we will verify that counter module with the help of a test-bench module and Altera ModelSim Software, there are many software which you can you to simulate your design none of the component we use are platform dependent.

so lets start , first of all we are going to need a testbench module , testbench module is nothing but a simple verilog module which feeds the inputs to our counter module , monitor the output and ultimately validates that the under test module is working as it should be, to achieve this testbench modules have few extra features or you can call them have extra powers , like you can specify initialization block  and specify time when a instruction will execute due to testbench module never ever get synthesize  , they just run in the simulation software that is all.

lets start writing a test bench ,

  1. you need a module ,
  2. few reg and wire declaration  for ports of the module under test,
  3. an instance of the module inter test,
  4. and  a initial block to do one time events,
  5. and finally a always block to generate clock for the module under test.
`timescale 1ns/1ps  // simmulation happen in picosecond time base ,
                    // we have up scaled it it to ns 
                    // when we say #5 it will mean 5 ns , and when we say #1000 it will 1000ns, 1us

module counter_testbench();

reg clock_tb,reset;       //mapped with ports of the module under test 
wire [32:0]out_tb;
counter t0(reset,clock_tb,out_tb);  //create an instance of the counter module which is under test 
  initial 
  begin 
$monitor(“%g,out_tb=%d,reset=%b”,$time,out_tb,reset); // these values will be visible in the transcript window at the bottom
clock_tb=0;
reset=1;  //enable the counter module ,reset is active low input
#100      // right here we should have (200/5)/2 = 20 in the cout output  value
reset=0; //reset the timer module for a while
#300
reset=1;
#1000
$stop(); // right here we will have (1000/5)2=100 in the count output
end 

 always #5 clock_tb=~clock_tb;  //generate clock by toggling Clock line ever 5 unit of time

endmodule

Read more Here







 

More Articles to Read

Blinking Christmas Lights
Blinking Christmas Lights
Wrist thrusters let you fly through the water effortlessly
Wrist thrusters let you fly through the water effortlessly
Bertan/Spellman 225-20R HV power supply teardown
Bertan/Spellman 225-20R HV power supply teardown
Blinking Christmas Lights
Blinking Christmas Lights
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adding an “extra sense” with rangefinders
Adding an “extra sense” with rangefinders
This wireless game controller looks like a rug
This wireless game controller looks like a rug
How to run your ESP8266 for years on a battery
How to run your ESP8266 for years on a battery
Calibration of a 3-Phase Energy Meter Board on the ADE7754
Calibration of a 3-Phase Energy Meter Board on the ADE7754
Making beats on a tiny Arduino DJ controller
Making beats on a tiny Arduino DJ controller
Qinsi-QS5100 Sn63Pb37 solder profile
Qinsi-QS5100 Sn63Pb37 solder profile
Water Detection System
Water Detection System
Professional Hi-Fi 15W Tube Amplifier circuit
Professional Hi-Fi 15W Tube Amplifier circuit
This Arduino machine will judge how sick your ollies are
This Arduino machine will judge how sick your ollies are
Turn an old payphone into a boombox for ’90s hits
Turn an old payphone into a boombox for ’90s hits
Big F’n 3D printer build
Big F’n 3D printer build
Temperature alarm for boiling milk
Temperature alarm for boiling milk
QuadBot is a 3D-printable walking robot for everyone
QuadBot is a 3D-printable walking robot for everyone
MicroConverter I2C Compatible Interface
MicroConverter I2C Compatible Interface
An Arduino tachometer for your older vehicle
An Arduino tachometer for your older vehicle

Top


Shares