Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active January 3, 2016 16:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mic92/8488639 to your computer and use it in GitHub Desktop.
Save Mic92/8488639 to your computer and use it in GitHub Desktop.
Ein paar Tipps beim Ausführen von Testbenches.

Hier mein Script was ich benutze um den Testbench zu starten. (da mir die Gui zu langsamer über SSH ist und gerade wackeligen eduroam WLAN-Netz) Ihr müsst nur die Variablen an euer Projekt anpassen. Vor dem Ausführen sollte man auf jeden Fall 1 Mal Verilog-NC gestartet haben, sodass das Testbenchverzeichnis erzeugt wird.

Mein Setup ist folgendes:

  • über rsync aktualisiere ich die Verilog-Dateien (sshfs tut es eventuell auch).

  • dann starte ich über ssh mein Skript (eeets2 habe ich den Server in meiner ssh config genannt):

    $ ssh eeets2 <PROJECT_ROOT>/df2/run-testbench.sh

  • ich lasse im Testbench ein Dumpfile erzeugen, welche es nach der Simulation herunter laden lasse.

  • danach lädt sich gtkwave den Dump und zeigt ihn an.

Noch ein paar Dinge zum Benchmark:

Um zu verhindern, das die Simulation ewig läuft und das Dumpfile immer größer wird, habe ich eine zeitliche Begrenzung eingebaut:

  for (i = 0; i < 1000; i = i + 1) begin
    if (ready != 0) begin
      $display("%c[32mSUCCESS: tests bench finished;%c[0m", 27, 27);
      $finish;
    end
    #(CYCLE) ;
  end
  $display("%c[31mFAILED: tests timeout!%c[0m", 27, 27);
  $finish(1);

Mit folgenden Marko kann man Unit-Test ähnlich Bedingungen während der Simulation überprüfen:

`define ASSERT(c, msg) if (!c) begin $display("%c[31mAssertion Failed: %s%c[0m", 27, msg, 27); $finish(2); end

// Beispiel
`ASSERT(state == `IDLE, "state != IDLE")
#!/usr/bin/env bash
PROJECT_NAME=heron #<-- Ändern
PROJECT_ROOT=$HOME/ICPRO/ice/${PROJECT_NAME}
TESTBENCH_NAME=${PROJECT_NAME}_top_tb_run1 # <-- Eventuell ändert
TESTBENCH_ROOT=${PROJECT_ROOT}/units/${PROJECT_NAME}/df2/${TESTBENCH_NAME}
cd $TESTBENCH_ROOT
source /cad/Modules/init/bash
module load gcc # gcc env
module load local # /usr/local path settings
module load openwin # openwindows env
module load tools # /cad/Tools env
module load icpro/1.0.3 # integrated circuit design env
module load firefox # browser
module load cds_ldv/6.11_USR3
module load cds_soc/6.2_USR2
module load cds_ic/5.1.41_USR5
module load syn_leda/4.2.0
module load syn_dc/2008.09
# I love candy
green='\e[0;32m'
red='\e[0;31m'
endColor='\e[0m'
echo -e "${green}Compiling...${endColor}"
ncxlmode \
+delay_mode_path \
+typdelays \
-l simout.tmp \
${TESTBENCH_ROOT}/testfixture.template \
-f ${TESTBENCH_ROOT}/verilog.inpfiles \
-f ${PROJECT_ROOT}/resources/ams_hk/verilog/c35b4/vxl.inc \
+nocopyright \
+elaborate \
+ncvlogargs+" -neverwarn -nostdout -nocopyright" \
+ncelabargs+" -neg_tchk -nonotifier -sdf_NOCheck_celltype -access +r -pulse_e 100 -pulse_r 100 -neverwarn -timescale 1ns/1ps -nostdout -nocopyright"
res=$?
cat simout.tmp
if [ $res -eq 0 ]
then
echo -e "${green}Run simulation...${endColor}"
ncsim -cdslib INCA_libs/cds.lib -batch worklib.test
else
echo -e "${red}Compilation failed, skip running simulation...${endColor}" >&2
exit 1
fi
# Hier mein Makefile, falls jemand damit etwas anfangen kann.
# ich habe ein lokales Verzeichnis namens "cadence", welches das Verzeichnis "cdslib" vom Server enthält.
# Dazu habe ich rsync in meinem Home-Verzeichnis kompiliert, da dortige auf der Maschine zu alt war, eventuelle könnte man es auch scp benutzen.
PROJECT_ROOT=/home2/vlsi13/joth13/ICPRO/ice/heron/units/heron
TB_ROOT=$(PROJECT_ROOT)/df2/heron_top_tb_run1
VERILOG_FILES=${shell find . -name verilog.v -type f}
sync:
cd cadence; rsync --relative --verbose --rsync-path=~/rsync-3.1.0/rsync -e ssh $(VERILOG_FILES:./cadence/%=%) eeets2:$(PROJECT_ROOT)/cdslib/heron/
testbench:
ssh eeets2 $(PROJECT_ROOT)/df2/run-testbench.sh
rsync -av --inplace --rsync-path=~/rsync-3.1.0/rsync -avHz -e ssh eeets2:$(TB_ROOT)/heron_top_tb.vcd .
gtkwave heron_top_tb.gtkw
0000 IDLE
0001 LD_N_1
0011 LD_N_2
0010 I_GT_ZERO
0110 LD_S_1
0111 LD_S_2
0101 S_GT_ONE
0100 X_1
1100 DIV_1
1101 DIV_2
1111 DIV_3
1110 DIV_4
1010 OLD_X_LTE_X_1
1011 OLD_X_LTE_X_2
1001 STORE_X
1000 DEC_I
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment