Modelsim初使用

Modelsim初使用

choose-and-click的使用方式这里就不记录了,因为那不是我的使用习惯。接下来介绍如何在Transcript窗口使用modelsim进行基本的仿真。

首先介绍几个普通命令

l  file     Tcl command: Manipulate file names and attributes.

file mkdir demo 新建文件夹demo

file delete -force demo      删除文件夹demo

file delete demo.v   删除文件demo.v

file isfile/isdir demo.v   判断是文件还是目录

l  ls -help

ls -l   %List 1 file per line

ls -p  %Append indicators to the ends of names

l  cd F:/Shihao      进入特定盘的特定目录

接下来介绍仿真相关的步骤和命令

  1. 创建目录project,并进入。这里可以使用file命令和cd命令,或者其他方法。
  2. 编写模块文件,如test.v, midsquare.v,test为top module
  3. 仿真

    vlib work

    vmap work work

    vlog test.v midsquare.v

    vsim -novopt work.test

    add wave -recursive /test/*

    run 1ms

    quit -sim

  1. 将上面运行代码写入run.tcl文件,便可实现批处理

    do run.tcl

命令解释如下

help vlib

# The vlib command creates a design library. You must use vlib rather than operating system commands to create a library directory or index file.

help vmap

# The vmap command defines a mapping between a logical library name and a directory by modifying the modelsim.ini file.

help vlog

# The vlog command compiles Verilog source code and SystemVerilog extensions into a specified working library (or to the work library by default). Type 'vlog -help' for complete syntax

help vsim

# The vsim command invokes the VSIM simulator or displays the results of a previous simulation run (when invoked with the -view switch). Type 'vsim -help' for complete syntax.

-novopt     Force incremental mode (pre-6.0 behavior)

-vopt       Run vopt optimization before elaborating the simulator

help add wave

# The add wave command adds the following objects to the Wave window:  VHDL signals and variables, Verilog nets and registers, and SystemC primitive channels (signals).

# Usage: add wave [-allowconstants] [-clampanalog [0|1]] [-color <standard_color_name>] [-depth <level>] [-divider <divider_name>...] [-expand <signal_name>] [-<format>] [-group <group_name> [<sig_name1>...]] [-height <pixels>] [[-in] [-out] [-inout] | [-ports]] [-internal] [-label <name>] [-max <real_num>] [-min <real_num>] [-mvcall] [-mvcovm] [-mvcreccomplete] [-noupdate] [-optcells] [-position] [-radix <type> | <radix_type>] [-radixenumnumeric | -radixenumsymbolic] [-recursive] [-time] [-window <wname>] [<object_name>...] [{<object_name> {sig1 sig2 sig3 ...}}]

help run

# The run command advances the simulation by the specified number of timesteps.

# Usage: run <timesteps>[<time_units>] | -all | -continue | -finish | -init | -next | -step | -over

help quit

# The quit command exits the simulator.

# Usage: quit [-f | -force] [-sim] [-code <integer>]

有两点需要强调

vsim -novopt work.test

其中参数-novopt使得可以通过add wave找到变量,否则变量会被优化掉,从而无法查看对应波形。

add wave -recursive /test/*

其中参数-recursive表示将test模块下的变量以及子模块中的变量都加入波形窗口。

posted @ 2021-01-26 16:23  史昊  阅读(449)  评论(0)    收藏  举报