文档库 最新最全的文档下载
当前位置:文档库 › VCS教程

VCS教程

VCS教程
VCS教程

SAN JOSE STATE UNIVERSITY

College of Engineering

DEPARTMENT OF ELECTRICAL ENGINEERING

EE271

Tutorial on Using Synopsys Verilog Compiler Simulator This tutorial basically describes how to use the Synopsys Verilog Compiler Simulator (vcs) to simulate a Verilog description of a design and how to display graphical waveforms.

Apply for An Account

If you already have an account on Cadence lab then use it. There is no need for having multiple accounts. If you’re an engineering student or are taking an engineering class, you already have one UNIX account. You can (re)set your password by following the instruction at https://www.wendangku.net/doc/2918026778.html,

Once you have already had an account, you can login to your account from workstations in room ENGR289 and room ENGR291. You can remote login to your account from you PC by using SSH remote Secure Shell together with the X-Server for Window software, the Exceed Hummingbird.

The Synopsys VCS Simulator

VCS (Verilog Compiler Simulator) is a tool suite from Synopsys. It includes VirSim, a graphical user interface to VCS for debugging and viewing waveforms.

The methodology of debugging your project design involves three steps:

1) Compiling your verilog source code,

2) Running the simulation, and

3) Viewing the generated waveforms.

The VCS tools will allow you to combine these steps to debug your design interactively. VCS works by compiling your Verilog source code into object files, or translating them into C source files. VCS invokes a C compiler (cc, gcc, or egcs) to create an executable file that will simulate your design. This simulator can be executed on the command line, and can create a waveform file. Alternately, the design can be simulated interactively using VirSim, and the waveforms can be viewed as you step through the simulation.

The rest of this document will give a brief overview of the tools and show you how to compile and simulate a down-counter example.

Initial Setup

The VCS package is installed at /apps/synopsys/X-2005.06-SP2/bin/vcs. For convenience, set the following environment variables to your .cshrc file. Remember that anytime you changed/modified .cshrc file, you must source it (by command “source .cshrc”) or by logging-out and then logging back in.

setenv MYPATH $PATH

setenv SYNOPSYS /apps/synopsys

setenv SNPSLMD $SYNOPSYS/Y-2006.06-SP1

setenv VCS_ARCH_OVERRIDE redhat30

setenv SYNOPSYS_SIM $SYNOPSYS/X-2005.06-SP2

setenv CLS_CSD_COMPATIBILITY_LOCKING NO

setenv SKIP_CDS_DIALOG

setenv VCS_HOME $SYNOPSYS_SIM

set path=($path $SNPSLMD/linux/bin )

set path=($path $SYNOPSYS )

set path=($path $SYNOPSYS/Y-2006.06-SP1/linux/syn/bin )

source $SYNOPSYS_SIM/bin/environ.csh

Create a directory where you want to do the tutorial and create the following three text files named count.v, test_count.v, and main_count.f in that directory. Listings of count.v and test_count.v are at the end of this tutorial. The main_count.f file has only 1 line as shown below:

test_count.v count.v

Compiling and Simulating in post-processing mode

1. Change to tutorial directory that contains count.v, test_count.v, and

main_count.f (in this tutorial it is tutorial)

2. Compile the verilog source code by typing the following at the machine prompt

/export/home/staff/thuyle/tutorial> vcs -f main_count.f option means that the file specified (

-f main_count.f

The ) contains a list of command line options for vcs. In this case, the command-line options are just a list of file names and note that the testbench is listed first. The following command line would have the same effect:

/export/home/staff/thuyle/tutorial> vcs test_count.v count.v

/export/home/staff/thuyle/tutorial> vcs -f main_count.f

Chronologic VCS (TM)

Version X-2005.06-SP2 -- Wed Oct 11 20:20:03 2006

Copyright (c) 1991-2005 by Synopsys Inc.

ALL RIGHTS RESERVED

This program is proprietary and confidential information of Synopsys Inc.

and may be used and disclosed only as authorized in a license agreement controlling such use and disclosure.

Parsing design file 'test_count.v'

Parsing design file 'count.v'

Top Level Modules:

test_count

No TimeScale specified

Starting vcs inline pass...

1 module and 0 UDP read.

recompiling module test_count

if [ -x ../simv ]; then chmod -x ../simv; fi

g++ -o ../simv -melf_i386 -m32 5NrI_d.o 5NrIB_d.o wx0S_1_d.o SIM_l.o /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvirsim.a /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvcsnew.so /apps/synopsys/X-2005.06-SP2/redhat30/lib/ctype-stubs_32.a -ldl -lc -lm -ldl

/usr/bin/ld: warning: libstdc++.so.5, needed by /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvcsnew.so, may conflict with libstdc++.so.6

../simv up to date

CPU time: .053 seconds to compile + .226 seconds to link

You should now have an executable file called in your working directory.

simv

3. Execute simv on the command line with no arguments. You should see output

from both vcs and the simulation and it should produce a waveform file called count.dump in your working directory.

/export/home/staff/thuyle/tutorial> simv

Chronologic VCS simulator copyright 1991-2005

Contains Synopsys proprietary information.

Compiler version X-2005.06-SP2; Runtime version X-2005.06-SP2; Oct 11 20:24 2006

$finish at simulation time 136

V C S S i m u l a t i o n R e p o r t

Time: 136

CPU Time: 0.040 seconds; Data structure size: 0.0Mb

Wed Oct 11 20:24:53 2006

/export/home/staff/thuyle/tutorial>

4. We are now going to re-invoke vcs to view the waveform. At the prompt, type:

/export/home/staff/thuyle/tutorial> vcs -RPP count.v

/export/home/staff/thuyle/tutorial> vcs -RPP count.v

VirSim X-2005.06-SP1-12 Virtual Simulator Environment

Copyright (C) 1993-2005 by Synopsys, Inc.

Licensed Software. All Rights Reserved.

Use "virsim [help_arg]" for usage information.

help_arg: -help or -verilog_help or -vhdl_help or -epic_help

-RPP

The option tells vcs that we are opening it in post-processing mode. This should open up a new window as below:

5. In this window, click on open under the File menu option. Change the file type that

you want to open to VCD (not VCD+). (VCD has .dump file extension and VCD+ has .vcd file extension). They are both waveform files but VCD files are text files, and VCD+ are condensed binary files.

count.dump

6. Select and open the file and then click OK (also click O.K. on the

information pop-up screen). Click on the test_count button, and you should see all signals instantiated in the signal window: clock, dec, in[3:0],load, and

zero.

New Waveform Window to open a waveform window as below: 7. Click

on

8. In the Hierarchy window, highlight all signals in the signal list with the left mouse

button. Then with the middle mouse button, drag the selected signals over to the black space in the waveform window. At this point, you should see the waveforms starting at time 0 of the simulation.

9. In the waveform window, the menu option Display -> Time Scale can be used to

change the display unit and the display precision. You can also use Zoom on the menu to change the appearance as shown below:

10. Because we used the system command in our

$dumpvars (0, test_count) verilog simulation, we should be able to view all signals at any hierarchical level of the design. Hence if you go back to the hierarchy window and click on the green arrow next to the test_count button, you can traverse down the hierarchy and select more signals to view. Before exiting the waveform viewer, you can save your settings in a configuration file under the File -> Save Configurations option. Compiling and Simulating in interactive mode

1. Now we are going to simulate the design again but in interactive mode. First let's

exit VirSim if you have not already done so. Recompile your source code with the following command line:

vcs -RI -Mupdate -f main.f

The

-Mupdate is a compile-time option that tells vcs to compile incrementally.

When you use this option, it will create a sub-directory called csrc. This directory will contain a Makefile and object files for each module that is compiled. When you compile incrementally, only the modules that change between compilations will need to be recompiled. The -RI means we are going to simulate in interactive mode. As soon as the code is compiled, VirSim will be invoked and the simulation will start.

/export/home/staff/thuyle/tutorial> vcs -RI -Mupdate -f main_count.f

Chronologic VCS (TM)

Version X-2005.06-SP2 -- Thu Oct 12 13:23:01 2006

Copyright (c) 1991-2005 by Synopsys Inc.

ALL RIGHTS RESERVED

This program is proprietary and confidential information of Synopsys Inc.

and may be used and disclosed only as authorized in a license agreement controlling such use and disclosure.

***** Warning: ACC/CLI capabilities have been enabled for the entire design.

For faster performance enable module specific capability in pli.tab file Parsing design file 'test_count.v'

Parsing design file 'count.v'

Top Level Modules:

test_count

No TimeScale specified

Starting vcs inline pass...

1 module and 0 UDP read.

recompiling module test_count because:

Some compilation options have been changed.

if [ -x ../simv ]; then chmod -x ../simv; fi

g++ -o ../simv -melf_i386 -m32 5NrI_d.o 5NrIB_d.o wx0S_1_d.o SIM_l.o /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvirsim.a /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvcsnew.so /apps/synopsys/X-2005.06-SP2/redhat30/lib/ctype-stubs_32.a -ldl -lm -lc -ldl

/usr/bin/ld: warning: libstdc++.so.5, needed by /apps/synopsys/X-2005.06-SP2/redhat30/lib/libvcsnew.so, may conflict with libstdc++.so.6

../simv up to date

VirSim X-2005.06-SP1-12 Virtual Simulator Environment

Copyright (C) 1993-2005 by Synopsys, Inc.

Licensed Software. All Rights Reserved.

Use "virsim [help_arg]" for usage information.

help_arg: -help or -verilog_help or -vhdl_help or -epic_help

Interactive window of VirSim should have popped up by now. In the History The

panel, it says $stop at time 0. Whenever you invoke vcs with the -RI option, the simulation will always be paused at time 0.

2. Now you can open the Hierarchy window, open the Waveform window, either load

your configuration file (using Ctrl-L) or browse through the hierarchy to select signals to view as in GUI part described above. The time scale can be changed by Step Time button in the Simulator Control panel in the Interactive window. When you simulate interactively, the waveforms are only recorded for the signals that appear in the Waveform Window. Hence you should select any signals of interest before the simulation time that you want to view them. If at any time you want to restart the simulation, select Re-exec or Invoke Sim under the Sim option in the Interactive window.

3. You can also view your source code in the following manner. Select Source under

Window menu of the Interactive window to open a Source Window and Select Hierarchy under Window menu of the Interactive window to open a Hierarchy window. Then in the Hierarchy window, select a module instance, say text_count, and drag it (using the middle mouse button) to the large black panel in the Source window as shown below. If you want to edit your code, VCS will then invoke a text editor.

module test_count;

reg clock;

reg load, dec;

reg [3:0] in;

wire zero;

initial

begin

$dumpfile("count.dump"); // save waveforms in this file

$dumpvars (0, test_count); // saves all waveforms

clock = 0; load = 0; dec = 0;

in = 4'b0110;

#16 load = 1; // switch to 1 after the clock edge to reduce confusion #10 load = 0; // wait for 1 clock cycle

#10 dec = 1;

#100 $finish;

end

always #5 clock = ~clock; // Make 10ns clock

counter u1 (clock, in, load, dec, zero);

endmodule

/* downcounter with zero flag */

module counter (clock, in, load, dec, zero);

input clock;

input [3:0] in;

input load;

input dec;

output zero;

reg [3:0] value;

wire zero;

assign zero = ~|value;

always @ (posedge clock)

begin

if (load) value <= in;

else if (dec && !zero) value <= value - 1'b1;

end

endmodule

相关文档