Docsity

Mentor Graphics for Mixed Hardware Software Simulation | COMPE 475, Study Guides, Projects, Research of Engineering

Toggle sidebar
bg1
CompE 475: Microprocessors
Mentor Graphics Tutorial 2 – Mixed Hardware-Software Simulation
Created by: Dr. Khurram Waheed
Last Modification: Spring 2004
Objective
This tutorial describes how to create designs that have a QuickSim II model at the top level that contains
both ModelSim and QuickSim II parts or viewpoints. QuickSim Pro (QSPro) supports mixed designs
with a QuickSim II (also referred to as Electronic Design Data Model (EDDM)) model as the design root.
Figure 1 shows examples of possible design hierarchies that can or cannot be simulated with
QSPro. In Figure 1, ModelSim models (VHDL and Verilog) are noted as “HDL,” and QuickSim II
models are noted as “QSIM.”
Figure 1. Possible QuickSim II-on-Top Design Hierarchies
Creating a QuickSim II-on-Top Design
This section provides a summary of the basic steps to create a design with a mix of ModelSim
and QuickSim II models, with a QuickSim II model at the top (root) level. Most of these steps
are elaborated in the tutorial example below.
Design Creation Summary
1. Conceptualize and organize your overall design. Determine which pieces of the design will
be represented as QuickSim II models and which pieces will be represented as ModelSim
models.
2. Determine the directory structure for the overall design. You should determine where you
will create your top-level schematic, where you will store related VHDL and Verilog source
code, where the compiled VHDL objects go, and where any existing schematics or symbols
are stored.
3. Verify that all lower-level schematics are finished and that all required VHDL and/or Verilog
models are compiled.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Mentor Graphics for Mixed Hardware Software Simulation | COMPE 475 and more Study Guides, Projects, Research Engineering in PDF only on Docsity!

CompE 475: Microprocessors

Mentor Graphics Tutorial 2 – Mixed Hardware-Software Simulation

Created by: Dr. Khurram Waheed

Last Modification: Spring 2004

Objective

This tutorial describes how to create designs that have a QuickSim II model at the top level that contains both ModelSim and QuickSim II parts or viewpoints. QuickSim Pro (QSPro) supports mixed designs with a QuickSim II (also referred to as Electronic Design Data Model (EDDM)) model as the design root. Figure 1 shows examples of possible design hierarchies that can or cannot be simulated with QSPro. In Figure 1, ModelSim models (VHDL and Verilog) are noted as “HDL,” and QuickSim II models are noted as “QSIM.”

Figure 1. Possible QuickSim II-on-Top Design Hierarchies

Creating a QuickSim II-on-Top Design

This section provides a summary of the basic steps to create a design with a mix of ModelSim

and QuickSim II models, with a QuickSim II model at the top (root) level. Most of these steps

are elaborated in the tutorial example below.

Design Creation Summary

1. Conceptualize and organize your overall design. Determine which pieces of the design will

be represented as QuickSim II models and which pieces will be represented as ModelSim

models.

2. Determine the directory structure for the overall design. You should determine where you

will create your top-level schematic, where you will store related VHDL and Verilog source

code, where the compiled VHDL objects go, and where any existing schematics or symbols

are stored.

3. Verify that all lower-level schematics are finished and that all required VHDL and/or Verilog

models are compiled.

a. If you do not have symbols for the VHDL portions of the design, create them using

Generate Æ Symbol Æ Entity within Design Architect (DA).

b. If you do have symbols for the VHDL portions of the design but have not created them

using the Generate Æ Symbol Æ Entity , you must select File Æ Import VHDL Entity

from the DA Symbol Editor on each symbol at least once to configure it properly for

QSPro.

4. Use Design Architect (DA) to create the top-level design.

5. Use QSPro to simulate the top-level design.

Directory Structure of Electronic Design Data Model (EDDM)) model

In a design made up of QuickSim II and ModelSim models, design pieces are located in various

locations within a directory structure. You will have VHDL or Verilog source code, compiled

VHDL and Verilog libraries, symbol and schematic libraries, and the top-level component

directory. You must be aware of where the existing pieces are stored, and you must decide where

to put any new pieces that you create.

Figure 2. Proposed EDDM Quicksim-on-top hierarchical structure

The directory structure shown in Figure 2 shows how an EDDM-ontop design is organized under $MGC_WD (where MGC_WD defines the current Mentor Graphics Work Directory and typically points to the top design in a hierarchy. The dashed-line shapes indicate structures you will create in later steps in the design creation process.

Mixed Quicksim-VHDL Design Creation Steps

In order to demonstrate the methodology for performing such a simulation, we create a design for a mixed_counter where we create a counter in VHDL and use it in tandem with a standard chip 4-bit counter (74LS161). The steps involved in performing suych a design are implemented below:

  1. Create a folder mixed_counter in your home directory folder reserved for Mentor Graphics designs.

13. Create its -subfolder components , src etc.

  1. Create the VHDL code. This can be done using the design architect (da), which may be invoked either directly from the commandline or using the design manager (dmgr) design environment (as discussed in other Mentor Graphics tutorials).

$MGC_WD

Folder contains all compiled or created components

Folder contains all QSPro & Quicksim II data

Folder contains all HDL source code

Folder contains all Modelsim compiled data

components

src vhdl_lib

qspro_lib

if (icount = "1111") then rco <= '1'; else rco <= '0'; end if; end if; end if; qa <= icount(0); qb <= icount(1); qc <= icount(2); qd <= icount(3); END PROCESS count; END behave1;

Figure 4. VHDL code for counter_4bit.vhd

Note, that you may also define your entity and architecture in separate files. Then at the time of simulation (in case of several defined architectures) you may choose which architecture is to be actually used.

  1. Before you compile the my_dff code, you need to use vlib to create a library (vhdl_lib) in which to place the compiled HDL codes. You will also create a library (qspro_lib) where QSPro will place code later in the design process. Type the following command on the unix commandline. vlib vhdl_lib vlib qspro_lib
  2. In order for vhdl_lib to be properly used by Modelsim, it must be logically referenced in the modelsim.ini file. This new reference is added using the commandline below vmap vhdl_lib $MGC_WD/vhdl_lib The vmap utility creates a copy of the default modelsim.ini file in your working directory and then modifies it to add the work mapping you just specified. Note: The modelsim.ini file also enables the creation of a transcript file by including the following line: TranscriptFile = transcript If any problems occur when using QuickSim Pro, the errors are saved in to the specified transcript file (called transcript in this example) that you can examine later.
  3. In order to compile the VHDL/verilog code, use the vcom commandlinegiven below (in case of separate entity and architecture both will need to be compiled) vcom -qspro_syminfo -93 -work vhdl_lib src/counter_4bit.vhd Note
  • The -qspro_syminfo switch is used to compile VHDL objects that you will later create symbols for (to add these VHDL instanced to a QuickSim II schematic). When this option is used, the compiler saves information required to generate or update a symbol using Design Architect. If the -qspro_syminfo switch is not used, the Design Architect functions, generate_symbol and import_vhdl_info , will not be able to create or modify a symbol for the VHDL entity. Failure to use this switch will force you to create a symbol manually, in order to instantiate the VHDL entity in a schematic.
  • The switch –work vhdl_lib defines that the compiled HDL code should be placed in

vhdl_lib directory. The default directory which Modelsim searches otherwise is labeled

work.

  • The switch -93 invokes libraries compilations consistent with VHDL 93 standard.
  1. Correct for any errors reported by Modelsim compiler. Once compiled you can individually simulate your VHDL design to ensure its proper operability. Note:If you are unfamiliar with the vcom compiler options, refer to the online manual ModelSim SE/EE Command Reference.
  2. Simulate the VHDL/Verilog design using the modelsim compiler which may be invoked using the command vsim –lib vhdl_lib counter_4bit For more information on using Modelsim, viewing design hierarchy, variables & signals, lists and wave windows and simulation using force files see online Modelsim references available on class website or use ModelSim SE/EE Command Reference and User Guide.
  3. Next you need to generate symbols for counter_4bit that work with QSPro. From within the $MGC_WD directory, invoke Design Architect (da &)

a. With the DA session active, execute the $generate_symbol() function by selecting the File Æ

Generate Æ Symbol menu item. Make the Generate Symbol dialog box look like this:

Figure 5. Generate Symbol dialog box in Design Architect

b. In the Generate symbol dialog box, choose the Module Tab (if the VHDL code has integrated entity and architecture), else choose the Entity tab. Ensure that the references to the Modelsim Initfile, Library Logical Name, Entity name and Default Architecture, Component directory selections are done properly. c. The shape of the symbol can be selected using Choose Shape tab. However, for convenience we use the default box shape for the symbol. d. Press OK. A symbol for the counter_4bit will be generated and displayed as shown below.

  1. Navigate to the components folder and choose the counter_4_bit symbol. The earlier generated symbol appears in the schematic window
  2. Now click on the Libraries in the top menu bar and select Logic Modeling Smartmodel Library.

18. A new palette replaces the current palette. Navigate to Gen Purpose Logic Æ Counter Æ TI Æ 161 –

Synchronous 4 bit … The second symbol appears in the schematics window.

  1. Now interconnect and complete the schematics as shown below

Figure 8. Complete mixed_counter schematics

20. After completing the schematics, select Check Æ Schematics or Sheet , and correct errors (if any).

21. Save the completed schematics using File Æ Save Æ Default Registration. You may close the design

architect at this instant of time.

  1. Now we are ready to simulate this hardware-software co-design.
  2. Invoke the QSPro simulator using the commandline qspro -lib vhdl_lib mixed_counter A QSPro(QuickSim II) window and a QSPro(HDL)/Modelsim window appear on the screen.
  1. In the QSPro(QuickSim II) window, click the Open Sheet button in the File menu. The mixed_counter schematic appears. This window is the same as the Quicksim II window you have worked on in other tutorials.
  2. Add all the signals to the trace window and perform the following simulation. You have to define a dofile (or stimulus file) which does the following

CLK: Time Period: 10ns; Simulate for 1200ns

IN(7:0): Value of 00 at 0ns and F0 at 800ns

CLR: 0 at 0ns and 1 at 30ns

LOAD: 1 at 0ns 0 at 800ns and 1 at 820ns

  1. Simulate your design for 1200 ns (or more) and turn in your completed VHDL code, VHDL code simulation, completed schematics, dofile (or force file), and mixed_counter simulations. Observe the operation of the two counters in tandem. Are they behaving as you expected?

27. When done, exit the QSPro simulator by typing exit or choosing File Æ Exit. For your reference,

different time scale simulation results are given below in Figure 9.

Figure 9. mixed_counter simulation results

Project

  • Write a design unit in VHDL which transforms the 8-bit output of the counter you simulated

above to the equivalent display code for a pair of Seven Segment LED diplays. Note that the

two LED displays should be able to display correct LED-code values for 00h – FFh.

  • Create a symbol for the VHDl code that you have developed
  • Create an augmented schematics in which you will add this new component to the existing

schematics and make appropriate connections

  • Re-simulate the complete design and show all the outputs (including the 7-segment HEX

codes generated by your augmented design.