CPU: RTL Simulation 349
CPU Simulation
Simulating the CPU design is different from most other entities because
the CPU design doesn’t need much outside stimulus. The memory device
provides the input data for the CPU much as a stimulus file would for
other entities. The CPU reads its program from the memory device. The
CPU need only have the clksignal and resetsignal stimulated properly,
and the CPU reads and executes instructions from that point forward.
The only stimulus needed to start the operation of the CPU is a uniform
signal applied to the clkinput and a pulse applied to the resetinput for
at least 2 clock cycles. This starts the CPU into the reset sequence. After
the reset sequence has been started, the CPU is initialized and starts
executing the CPU instructions from the mementity.
The CPU is simulated as stimulus only initially to verify that the device
seems to be functioning. More complex testbenches need to be created that
include comparison against a known good result to verify correctness. The
simplest method for doing this is to manually verify the results the first
time, capture the output results, and then use them for comparison later.
The first step in simulating the CPU is to compile all the files that
make up the design into a format that the simulator can use. The com-
piled format is loaded into the simulator, and the simulation is executed.
The ModelSim simulator from Model Technology is used for the simu-
lation process.
The first step in compiling all of the files in the design is to create one
or more libraries to store the compiled data. The default library to store
the compiled data is a library called work. The name workis the logical
name of the library; the physical location of the library can be anywhere.
To create a library, the VLIBcommand is used as shown here:
vlib work
This creates the worklibrary in the current working directory of the
current disk. After the library has been created, the VHDL source files for
the design can be compiled into the target library. To compile each of the
files, the VCOMcommand must be run either from the GUI (Graphical User
Interface) or from the command line. Most of the operations of the simu-
lator have a GUI method of performing the command line command. This
allows casual users as well as expert users to effectively use the simula-
tor. Normally, casual users use the GUI and experts use the command line
and script interface.