Before running VCS the tool environment file must be source. If you have not done this please go back to the environment setup page. Steps 1 through 5 may be done on in a telnet window from anywhere to any department linux machine. Steps 6 on require the user be seated at a departement linux machine.
This code implements a simple four bit counter.You may also copy the file from here.module counter ( out, clk, reset ) ; input clk, reset; output [3:0] out; reg [3:0] out; wire [3:0] next; // This statement implements reset and increment assign next = reset ? 4'b0 : (out + 4'b1); // This implements the flip-flops always @ ( posedge clk ) begin out <= #1 next; end endmodule // counter
// This stuff just sets up the proper time scale and format for the // simulation, for now do not modify. `timescale 1ns/10ps module timeunit; initial $timeformat(-9,1," ns",9); endmodule // Here is the testbench proper: module counter_testbench ( ) ; // Test bench gets wires for all device under test (DUT) outputs: wire [3:0] out; // Regs for all DUT inputs: reg clk; reg reset; counter dut (// (dut means device under test) // Outputs .out (out[3:0]), // Inputs .reset (reset), .clk (clk)); // Setup clk to automatically strobe with a period of 20. always #10 clk = ~clk; initial begin // First setup up to monitor all inputs and outputs $monitor ("time=%5d ns, clk=%b, reset=%b, out=%b", $time, clk, reset, out[3:0]); // First initialize all registers clk = 1'b0; // what happens to clk if we don't // set this?; reset = 1'b0; @(posedge clk);#1; // this says wait for rising edge // of clk and one more tic (to prevent // shoot through) reset = 1'b1; @(posedge clk);#1; reset = 1'b0; // Lets watch what happens after 7 cycles @(posedge clk);#1; @(posedge clk);#1; @(posedge clk);#1; @(posedge clk);#1; @(posedge clk);#1; @(posedge clk);#1; @(posedge clk);#1; // At this point we should have a 4'b0110 coming out out because // the counter should have counted for 7 cycles from 0 if (out != 4'b0110) begin $display("ERROR 1: Out is not equal to 4'b0110"); $finish; end // We got this far so all tests passed. $display("All tests completed sucessfully\n\n"); $finish; end // This is to create a dump file for offline viewing. initial begin $dumpfile ("counter.dump"); $dumpvars (0, counter_testbench); end // initial begin endmodule // counter_testbench
You may download a copy of this file from here .counter_testbench.v counter.v
pgratz@desk workingdir $ vcs -o counter -Mupdate -f counter_filelist
Chronologic VCS (TM) Version X-2005.06-SP2 -- Thu Sep 14 11:59:11 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 'counter_testbench.v' Parsing design file 'counter.v' Top Level Modules: timeunit counter_testbench TimeScale is 1 ns / 10 ps Starting vcs inline pass... 2 modules and 0 UDP read. recompiling module timeunit recompiling module counter_testbench Both modules done. if [ -x ../counter ]; then chmod -x ../counter; fi g++ -o ../counter 5NrI_d.o 5NrIB_d.o IV5q_1_d.o blOS_1_d.o SIM_l.o /projects/cad/sy nopsys/vcs/vcs-mx_vX-2005.06-SP2/redhat30/lib/libvirsim.a /projects/cad/synopsys/vc s/vcs-mx_vX-2005.06-SP2/redhat30/lib/libvcsnew.so /projects/cad/synopsys/vcs/vcs-mx _vX-2005.06-SP2/redhat30/lib/ctype-stubs_32.a -ldl -lc -lm -ldl ../counter up to date CPU time: .080 seconds to compile + 2.588 seconds to link
pgratz@desk workingdir $ ./counter
Chronologic VCS simulator copyright 1991-2005 Contains Synopsys proprietary information. Compiler version X-2005.06-SP2; Runtime version X-2005.06-SP2; Sep 14 12:23 2006 time= 0 ns, clk=0, reset=0, out=xxxx time= 10 ns, clk=1, reset=0, out=xxxx time= 11 ns, clk=1, reset=1, out=xxxx time= 20 ns, clk=0, reset=1, out=xxxx time= 30 ns, clk=1, reset=1, out=xxxx time= 31 ns, clk=1, reset=0, out=0000 time= 40 ns, clk=0, reset=0, out=0000 time= 50 ns, clk=1, reset=0, out=0000 time= 51 ns, clk=1, reset=0, out=0001 time= 60 ns, clk=0, reset=0, out=0001 time= 70 ns, clk=1, reset=0, out=0001 time= 71 ns, clk=1, reset=0, out=0010 time= 80 ns, clk=0, reset=0, out=0010 time= 90 ns, clk=1, reset=0, out=0010 time= 91 ns, clk=1, reset=0, out=0011 time= 100 ns, clk=0, reset=0, out=0011 time= 110 ns, clk=1, reset=0, out=0011 time= 111 ns, clk=1, reset=0, out=0100 time= 120 ns, clk=0, reset=0, out=0100 time= 130 ns, clk=1, reset=0, out=0100 time= 131 ns, clk=1, reset=0, out=0101 time= 140 ns, clk=0, reset=0, out=0101 time= 150 ns, clk=1, reset=0, out=0101 time= 151 ns, clk=1, reset=0, out=0110 time= 160 ns, clk=0, reset=0, out=0110 time= 170 ns, clk=1, reset=0, out=0110 All tests completed successfully $finish at simulation time 171.0 ns V C S S i m u l a t i o n R e p o r t Time: 171000 ps CPU Time: 0.040 seconds; Data structure size: 0.0Mb Thu Sep 14 12:23:44 2006
Modified by Paul Gratz, pgratz@cs.utexas.edu