|
| 1 | +# SPDX-FileCopyrightText: © 2024 JSilicon |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# Makefile for UVM testbench with VCS |
| 5 | + |
| 6 | +# Simulator selection (default: VCS) |
| 7 | +SIM ?= vcs |
| 8 | + |
| 9 | +# Test selection |
| 10 | +TEST ?= jsilicon_full_test |
| 11 | + |
| 12 | +# Verbosity level |
| 13 | +VERBOSITY ?= UVM_MEDIUM |
| 14 | + |
| 15 | +# Directories |
| 16 | +SRC_DIR = ../src |
| 17 | +SIM_DIR = . |
| 18 | +TEST_DIR = ../test |
| 19 | + |
| 20 | +# Source files |
| 21 | +RTL_FILES = \ |
| 22 | + $(SRC_DIR)/alu.v \ |
| 23 | + $(SRC_DIR)/fsm.v \ |
| 24 | + $(SRC_DIR)/inst.v \ |
| 25 | + $(SRC_DIR)/pc.v \ |
| 26 | + $(SRC_DIR)/regfile.v \ |
| 27 | + $(SRC_DIR)/switch.v \ |
| 28 | + $(SRC_DIR)/uart.v \ |
| 29 | + $(SRC_DIR)/jsilicon.v |
| 30 | + |
| 31 | +# UVM files |
| 32 | +UVM_FILES = \ |
| 33 | + jsilicon_if.sv \ |
| 34 | + jsilicon_pkg.sv \ |
| 35 | + jsilicon_tb_top.sv |
| 36 | + |
| 37 | +# VCS compilation options |
| 38 | +VCS_OPTS = \ |
| 39 | + -full64 \ |
| 40 | + -sverilog \ |
| 41 | + -timescale=1ns/1ps \ |
| 42 | + -ntb_opts uvm-1.2 \ |
| 43 | + -debug_access+all \ |
| 44 | + -kdb \ |
| 45 | + -lca \ |
| 46 | + -CFLAGS -DVCS |
| 47 | + |
| 48 | +# VLOGAN options for analysis |
| 49 | +VLOGAN_OPTS = \ |
| 50 | + -full64 \ |
| 51 | + -sverilog \ |
| 52 | + -timescale=1ns/1ps \ |
| 53 | + -ntb_opts uvm-1.2 |
| 54 | + |
| 55 | +# Runtime options |
| 56 | +SIMV_OPTS = \ |
| 57 | + +UVM_TESTNAME=$(TEST) \ |
| 58 | + +UVM_VERBOSITY=$(VERBOSITY) \ |
| 59 | + -l simv.log |
| 60 | + |
| 61 | +# GUI options (Verdi) |
| 62 | +VERDI_OPTS = \ |
| 63 | + -ssf jsilicon.fsdb \ |
| 64 | + -nologo |
| 65 | + |
| 66 | +# Simulation executable |
| 67 | +SIMV = ./simv |
| 68 | + |
| 69 | +# Default target |
| 70 | +all: compile |
| 71 | + |
| 72 | +# Compile with VCS |
| 73 | +compile: |
| 74 | + @echo "===================================" |
| 75 | + @echo "Compiling with VCS..." |
| 76 | + @echo "===================================" |
| 77 | + vcs $(VCS_OPTS) \ |
| 78 | + $(RTL_FILES) \ |
| 79 | + $(UVM_FILES) \ |
| 80 | + -top jsilicon_tb_top \ |
| 81 | + -o simv |
| 82 | + |
| 83 | +# Simulate |
| 84 | +simulate: compile |
| 85 | + @echo "===================================" |
| 86 | + @echo "Running UVM test: $(TEST)" |
| 87 | + @echo "===================================" |
| 88 | + $(SIMV) $(SIMV_OPTS) |
| 89 | + |
| 90 | +# Run with Verdi GUI |
| 91 | +verdi: compile |
| 92 | + @echo "===================================" |
| 93 | + @echo "Running with Verdi GUI: $(TEST)" |
| 94 | + @echo "===================================" |
| 95 | + $(SIMV) $(SIMV_OPTS) -gui=verdi |
| 96 | + |
| 97 | +# Interactive mode |
| 98 | +interactive: compile |
| 99 | + @echo "===================================" |
| 100 | + @echo "Running in interactive mode: $(TEST)" |
| 101 | + @echo "===================================" |
| 102 | + $(SIMV) $(SIMV_OPTS) -ucli |
| 103 | + |
| 104 | +# Run specific tests |
| 105 | +test_manual: |
| 106 | + @$(MAKE) TEST=jsilicon_manual_test simulate |
| 107 | + |
| 108 | +test_cpu: |
| 109 | + @$(MAKE) TEST=jsilicon_cpu_test simulate |
| 110 | + |
| 111 | +test_full: |
| 112 | + @$(MAKE) TEST=jsilicon_full_test simulate |
| 113 | + |
| 114 | +test_random: |
| 115 | + @$(MAKE) TEST=jsilicon_random_test simulate |
| 116 | + |
| 117 | +# View waveform with Verdi |
| 118 | +wave: |
| 119 | + @if [ -f "jsilicon.fsdb" ]; then \ |
| 120 | + echo "Opening Verdi..."; \ |
| 121 | + verdi $(VERDI_OPTS) & \ |
| 122 | + else \ |
| 123 | + echo "Error: jsilicon.fsdb not found. Run simulation first."; \ |
| 124 | + exit 1; \ |
| 125 | + fi |
| 126 | + |
| 127 | +# Post-process waveform |
| 128 | +wave_dump: |
| 129 | + @echo "Opening existing FSDB with Verdi..." |
| 130 | + verdi -ssf jsilicon.fsdb -nologo & |
| 131 | + |
| 132 | +# Coverage report |
| 133 | +cov: |
| 134 | + @echo "Generating coverage report..." |
| 135 | + urg -dir simv.vdb -report urgReport |
| 136 | + |
| 137 | +# Clean |
| 138 | +clean: |
| 139 | + @echo "Cleaning generated files..." |
| 140 | + rm -rf simv* csrc DVEfiles |
| 141 | + rm -rf *.log *.vpd *.fsdb *.vcd |
| 142 | + rm -rf urgReport |
| 143 | + rm -rf work.lib++ |
| 144 | + rm -rf verdiLog novas* *.conf |
| 145 | + rm -rf AN.DB |
| 146 | + rm -rf .vlogansetup.args .vcs* |
| 147 | + rm -rf *.key |
| 148 | + |
| 149 | +# Help |
| 150 | +help: |
| 151 | + @echo "==========================================" |
| 152 | + @echo "UVM Testbench Makefile for VCS & Verdi" |
| 153 | + @echo "==========================================" |
| 154 | + @echo "" |
| 155 | + @echo "Targets:" |
| 156 | + @echo " all - Compile with VCS (default)" |
| 157 | + @echo " compile - Compile RTL and UVM files with VCS" |
| 158 | + @echo " simulate - Compile and run simulation" |
| 159 | + @echo " verdi - Run simulation with Verdi GUI" |
| 160 | + @echo " interactive - Run simulation in interactive mode (UCLI)" |
| 161 | + @echo " test_manual - Run manual mode test" |
| 162 | + @echo " test_cpu - Run CPU mode test" |
| 163 | + @echo " test_full - Run full test (manual + CPU)" |
| 164 | + @echo " test_random - Run random test" |
| 165 | + @echo " wave - View waveform with Verdi" |
| 166 | + @echo " wave_dump - Open existing FSDB file" |
| 167 | + @echo " cov - Generate coverage report" |
| 168 | + @echo " clean - Remove generated files" |
| 169 | + @echo " help - Show this help message" |
| 170 | + @echo "" |
| 171 | + @echo "Variables:" |
| 172 | + @echo " TEST - Test to run (default: jsilicon_full_test)" |
| 173 | + @echo " VERBOSITY - UVM verbosity (default: UVM_MEDIUM)" |
| 174 | + @echo " SIM - Simulator to use (default: vcs)" |
| 175 | + @echo "" |
| 176 | + @echo "Examples:" |
| 177 | + @echo " make - Compile with VCS" |
| 178 | + @echo " make simulate - Compile and run" |
| 179 | + @echo " make TEST=jsilicon_manual_test simulate - Run manual test" |
| 180 | + @echo " make verdi - Run with Verdi GUI" |
| 181 | + @echo " make wave - View waveform" |
| 182 | + @echo " make VERBOSITY=UVM_HIGH simulate - Run with high verbosity" |
| 183 | + @echo " make clean all - Clean and rebuild" |
| 184 | + |
| 185 | +.PHONY: all compile simulate verdi interactive test_manual test_cpu test_full test_random wave wave_dump cov clean help |
| 186 | + |
0 commit comments