Mudanças entre as edições de "Seguindo o tutorial da ALTERA para o MODELSIM"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Linha 25: Linha 25:
 
* select '''[Compile > Compile All]'''. A green check mark will appear to the right of the serial.vhd file in the Project tab.
 
* select '''[Compile > Compile All]'''. A green check mark will appear to the right of the serial.vhd file in the Project tab.
  
;Simulation:
+
;Preparing Simulation:
 
* Put Modelsim in simulation mode by selecting '''[Simulate > Start Simulation...]'''
 
* Put Modelsim in simulation mode by selecting '''[Simulate > Start Simulation...]'''
 
* The window to start simulation consists of many tabs. For the purposes of the functional simulation, we only need to look at the '''Design tab'''.
 
* The window to start simulation consists of many tabs. For the purposes of the functional simulation, we only need to look at the '''Design tab'''.
Linha 33: Linha 33:
 
: See the equivalent tcl command in Transcript window:
 
: See the equivalent tcl command in Transcript window:
 
  vsim tutorial.serial
 
  vsim tutorial.serial
* Using the '''sim''' tab and the '''Objects''' window we can select signals for simulation. To add a signal to simulation, rightclick on the signal name in the Objects window and '''[select Add > To Wave > Selected Signals]'''. Add signals '''A, B, resetn, start, clock, sum''', and current_state to the simulation,  
+
* Using the '''sim''' tab and the '''Objects''' window we can select signals for simulation. To add a signal to simulation, rightclick (with shift key) on the signals names in the Objects window and '''[select Add > To Wave > Selected Signals]'''. Add signals '''A, B, resetn, start, clock, sum'''from serial entity,  
 
  add wave  \
 
  add wave  \
 
  sim:/serial/A \
 
  sim:/serial/A \
Linha 41: Linha 41:
 
  sim:/serial/clock \
 
  sim:/serial/clock \
 
  sim:/serial/sum
 
  sim:/serial/sum
 +
* Add signal '''current_state''' and '''counter''' from my_control component.
 +
add wave  \
 +
sim:/serial/my_control/current_state \
 +
sim:/serial/my_control/counter
 
* There are two ways to run a simulation in ModelSim: manually or by using scripts. In this tutorial, we perform the simulation manually.
 
* There are two ways to run a simulation in ModelSim: manually or by using scripts. In this tutorial, we perform the simulation manually.
 +
;Manual Simulation:
 
* To set the '''clock''' period, right-click on the clock signal and select '''Clock...''' from the pop-up menu.  
 
* To set the '''clock''' period, right-click on the clock signal and select '''Clock...''' from the pop-up menu.  
 
: '''[clock period = 100 ps]''', '''[first edge = falling edge]''' and click '''[OK]'''.
 
: '''[clock period = 100 ps]''', '''[first edge = falling edge]''' and click '''[OK]'''.
Linha 63: Linha 68:
 
  force -freeze sim:/serial/resetn 1 0
 
  force -freeze sim:/serial/resetn 1 0
 
* Change the radix of '''A''' and '''B''' signal. Highlight them in the simulation window and select '''[Format > Radix > Unsigned]'''.  Change the radix of the '''sum''' signal to unsigned as well.
 
* Change the radix of '''A''' and '''B''' signal. Highlight them in the simulation window and select '''[Format > Radix > Unsigned]'''.  Change the radix of the '''sum''' signal to unsigned as well.
* Press the '''Run'''.
+
* To complete the operation, the circuit will require 9 clock cycles. run 900 ps using the Transcript command.
run
+
  run 900 ps [enter] (or)
* To complete the operation, the circuit will require 9 clock cycles. Instead of run 8 more times type in the Transcript window.
+
  run 900 [enter]
  run 800 ps [enter] (or)
 
  run 800 [enter]
 
  
 
=PASSO 3=
 
=PASSO 3=

Edição das 20h15min de 16 de setembro de 2015

Este tutorial ensina como utilizar o Modelsim para realizar a simulação funcional e também temporal. É requisito para a realização do tutorial o acesso ao software Quartus II e Modelsim ou Modelsim-ALTERA.

PASSO 1

/opt/altera/13.0sp1/modelsim_ase/bin/vsim
  • Para usar o ModelSim 10.1d no LabProg abra um terminal e digite:
/opt/altera/13.0/quartus/modelsim_ase/linux/vsim

PASSO 2 - Functional Simulation with ModelSim

Creating a Project
  • To create a project in ModelSim, select [File > New > Project...]
project name = serial_adder,
project location <= <subdiretorio do usuário>/Using_ModelSim/functional
default library name <= tutorial
copy settings field.
click [OK]
  • Since the file for this tutorial exists, click Add Existing File and select serial.vhd file.
  • Once the file is added to the project, it will appear in the Project tab
  • click [Close]
Compiling a Project

Compilation in ModelSim checks if the project files are correct and creates intermediate data that will be used during simulation.

  • select [Compile > Compile All]. A green check mark will appear to the right of the serial.vhd file in the Project tab.
Preparing Simulation
  • Put Modelsim in simulation mode by selecting [Simulate > Start Simulation...]
  • The window to start simulation consists of many tabs. For the purposes of the functional simulation, we only need to look at the Design tab.
  • In the Design tab you will see a list of libraries and entities you can simulate. In this tutorial, simulate a entity called serial.
  • To select this entity, scroll down and locate the tutorial library and click on the plus (+) sign.
  • You will see three entities available for simulation: FSM, serial, and shift_reg. Select the serial entity (Design Unit(s) = tutorial.serial) and click [OK] to begin simulation.
See the equivalent tcl command in Transcript window:
vsim tutorial.serial
  • Using the sim tab and the Objects window we can select signals for simulation. To add a signal to simulation, rightclick (with shift key) on the signals names in the Objects window and [select Add > To Wave > Selected Signals]. Add signals A, B, resetn, start, clock, sumfrom serial entity,
add wave  \
sim:/serial/A \
sim:/serial/B \
sim:/serial/start \
sim:/serial/resetn \
sim:/serial/clock \
sim:/serial/sum
  • Add signal current_state and counter from my_control component.
add wave  \
sim:/serial/my_control/current_state \
sim:/serial/my_control/counter
  • There are two ways to run a simulation in ModelSim: manually or by using scripts. In this tutorial, we perform the simulation manually.
Manual Simulation
  • To set the clock period, right-click on the clock signal and select Clock... from the pop-up menu.
[clock period = 100 ps], [first edge = falling edge] and click [OK].
  • To reset the circuit, set the resetn signal low by right-clicking on it and selecting the Force... from the pop-up menu.
[Value = 0] and [OK].
  • Set the value of the start signal to 0.
[Value = 0] and [OK].
force -freeze sim:/serial/clock 0 0, 1 {50 ps} -r 100
force -freeze sim:/serial/resetn 0 0
force -freeze sim:/serial/start 0 0
  • To run a simulation for 100 ps, set the value in the text field to 100 ps (default) and press the [Run] button.
run 
  • To test the serial adder we will add numbers A=143 and B=57 => sum=200.
  • To specify a value for A (B) in decimal, right-click on it, and choose Force... from the pop-up menu.
A [Value = 10#143] and [OK].
B [Value = 10#57] and [OK].
  • Set resetn to 1 to stop the circuit from resetting. Then set start to 1 to begin serial addition,
force -freeze sim:/serial/A 10#143 0
force -freeze sim:/serial/B 10#57 0
force -freeze sim:/serial/start 1 0
force -freeze sim:/serial/resetn 1 0
  • Change the radix of A and B signal. Highlight them in the simulation window and select [Format > Radix > Unsigned]. Change the radix of the sum signal to unsigned as well.
  • To complete the operation, the circuit will require 9 clock cycles. run 900 ps using the Transcript command.
run 900 ps [enter] (or)
run 900 [enter]

PASSO 3