A simulator accepts inputs that you specify and displays what the design's anticipated outputs will be. In this tutorial, we will be doing rtl-level simulation, where rtl is an acronym for register transfer level, in which the input to the simulator is the compiled Verilog HDL source code. Verilog HDL is a programming language for defining the structural and behavioral description of digital circuits. In rtl-level simulation, since no delay information is present, the simulation has no delays in it. The simulator that you will be using is the ModelSim simulator, which is available in the Mentor Graphics toolset.
Synthesis is the process of taking human-readable input such as Verilog HDL source code files and creating a low-level description which describes the design in terms of simple gates. The synthesis tool you will be using is Synopsys. A TSMC (Taiwan Semiconductor Manufacturing Corporation) ASIC (application-specific integrated circuit) library will be used in Synopsys.
Verilog source code is plain text contained in a single file or a group of files. Verilog text files use the file extension, .v .
The testbench module in tb_h4ba.v contains three sets of test vectors. Test vectors are different combinations of input values to test whether your design outputs the expected values. For example, addend_one<="1011"; addend_two<="1000"; carry-in<='1'; would be one possible combination of inputs.
In Modelsim vsim,
You may want to occasionally print out the simulation results that appear in the wave window.  You can use the zoom feature from the wave menu to obtain the proper zoom. To print the wave, from the wave menu, select File | Print Postscript... When the Write Postscript window opens, click File name: and type in a name for the file name, i.e., wave1.ps, and click ok.. Only the portion of the wave that is presently viewable will be printed out. If the waveform is long, you will have to use more than one page.  To set the laser printer destination, in an xterm window, use the command, setenv PRINTER laser44 if you are in EBUI 3327/3329, or setenv PRINTER laser65 if you are in EBUII 313. To view and print out a postscript file, you can use ghostview by typing the command, ghostview wave1.ps in an xterm window, where wave1.ps is the name of your postscript file. To print out the postscript file in ghostview, choose File | Print..., type in laser44 if you are in EBU1 3327/3329 or laser65 if you are in EBU2 313 in the popup window and click ok.
Note: Simulation can also be performed on the output of the synthesis tool. This is called gate level simulation as opposed to rtl level simulation performed in this tutorial. Gate level simulation is more accurate, but takes longer than rtl level simulation. Gate level simulation will not be performed in this tutorial.
The Verilog description of a 4-bit adder using a process with a sensitivity list is p4ba.v. The sensitivity list is to the right of always@. Signals that are read in the always construct should be placed in the sensitivity list. Since the signals, addend_one, addend_two, and carry_in are read in the process, they are included in the sensitivity list. Whenever one of the signals in the sensitivity list changes value, the always block will be executed. The assignment statements in the unclocked process use the blocking assignment operator, =. Signals written to with the blocking assignment operator are updated instantaneously. Combinational logic (unclocked always block) should be described using the blocking assignment operator. The other type of Verilog assignment operator is the non-blocking assignment operator, <=. When a signal is written to with the non-blocking assignment operator, it is scheduled to be assigned the new value at the end of the current time unit. Sequential logic (clocked always block) should be described using the nonblocking assignment operator. In the Verilog module, sum, carry_out, and carry are declared to be of type reg because they are assigned to in the always block. No registers will be synthesized as no edge is specified in the event specification list (sensitivity list).
A sample Verilog testbench for the moore state machine is provided:
tb_moore.v.
Suppose that you want to view on the wave timing diagram the six signals: RESET, X, CLK, Z, NEXT_STATE,
and CURRENT_STATE.
One method to do this is to use a .do macro file. Another method is to use the window menus.
A synthesis script file for the moore state machine is moore.scr.