| 1 |
6 |
julius |
######################################################################
|
| 2 |
|
|
#### ####
|
| 3 |
|
|
#### ORPSoCv2 Testbenches Makefile ####
|
| 4 |
|
|
#### ####
|
| 5 |
|
|
#### Description ####
|
| 6 |
|
|
#### ORPSoCv2 Testbenches Makefile, containing rules for ####
|
| 7 |
|
|
#### configuring and running different tests on the current ####
|
| 8 |
|
|
#### ORPSoC(v2) design. ####
|
| 9 |
|
|
#### ####
|
| 10 |
|
|
#### To do: ####
|
| 11 |
|
|
#### * Test if each software test file gets made properly ####
|
| 12 |
|
|
#### before it's run in whatever model we're using ####
|
| 13 |
|
|
#### * Expand software test-suite (uClibc, ecos tests, LTP?) ####
|
| 14 |
|
|
#### ####
|
| 15 |
|
|
#### Author(s): ####
|
| 16 |
|
|
#### - jb, jb@orsoc.se ####
|
| 17 |
|
|
#### ####
|
| 18 |
|
|
#### ####
|
| 19 |
|
|
######################################################################
|
| 20 |
|
|
#### ####
|
| 21 |
|
|
#### Copyright (C) 2009 Authors and OPENCORES.ORG ####
|
| 22 |
|
|
#### ####
|
| 23 |
|
|
#### This source file may be used and distributed without ####
|
| 24 |
|
|
#### restriction provided that this copyright statement is not ####
|
| 25 |
|
|
#### removed from the file and that any derivative work contains ####
|
| 26 |
|
|
#### the original copyright notice and the associated disclaimer. ####
|
| 27 |
|
|
#### ####
|
| 28 |
|
|
#### This source file is free software; you can redistribute it ####
|
| 29 |
|
|
#### and/or modify it under the terms of the GNU Lesser General ####
|
| 30 |
|
|
#### Public License as published by the Free Software Foundation; ####
|
| 31 |
|
|
#### either version 2.1 of the License, or (at your option) any ####
|
| 32 |
|
|
#### later version. ####
|
| 33 |
|
|
#### ####
|
| 34 |
|
|
#### This source is distributed in the hope that it will be ####
|
| 35 |
|
|
#### useful, but WITHOUT ANY WARRANTY; without even the implied ####
|
| 36 |
|
|
#### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ####
|
| 37 |
|
|
#### PURPOSE. See the GNU Lesser General Public License for more ####
|
| 38 |
|
|
#### details. ####
|
| 39 |
|
|
#### ####
|
| 40 |
|
|
#### You should have received a copy of the GNU Lesser General ####
|
| 41 |
|
|
#### Public License along with this source; if not, download it ####
|
| 42 |
|
|
#### from http://www.opencores.org/lgpl.shtml ####
|
| 43 |
|
|
#### ####
|
| 44 |
|
|
######################################################################
|
| 45 |
|
|
|
| 46 |
|
|
# Usage:
|
| 47 |
|
|
#
|
| 48 |
|
|
# make rtl-tests
|
| 49 |
|
|
#
|
| 50 |
|
|
# Run the software tests in the RTL model of the ORPSoC being
|
| 51 |
55 |
julius |
# simulated with an event-driven simulator like Icarus. It's also
|
| 52 |
|
|
# possible to use Modelsim's vsim and Cadence's Verilog simulators.
|
| 53 |
6 |
julius |
#
|
| 54 |
|
|
# make vlt-tests
|
| 55 |
|
|
#
|
| 56 |
|
|
# Run all the software tests in the RTL model which has been
|
| 57 |
|
|
# converted into a cycle-accurate SystemC model with Verilator.
|
| 58 |
|
|
#
|
| 59 |
|
|
# make sim-tests
|
| 60 |
|
|
#
|
| 61 |
|
|
# Run all the software tests in the architectural simulator
|
| 62 |
|
|
#
|
| 63 |
40 |
julius |
#
|
| 64 |
|
|
# Debugging modes:
|
| 65 |
|
|
#
|
| 66 |
|
|
# make rtl-debug
|
| 67 |
|
|
#
|
| 68 |
|
|
# Enable a GDB stub integrated into the simulation via VPI. This will
|
| 69 |
|
|
# start a simulation, then the GDB server, and allow the user to connect
|
| 70 |
|
|
# using the OpenRISC GDB port. It should provide the same functionality
|
| 71 |
|
|
# as GDB to a physical target, although a little slower.
|
| 72 |
|
|
# It is provided here as an example of how to compile and run an OpenRISC
|
| 73 |
|
|
# model at RTL level with support for debugging from GDB.
|
| 74 |
|
|
# UART output from printf() is enabled by default. The model loads with
|
| 75 |
|
|
# the dhrystone test running as default, but can be changed by defining
|
| 76 |
|
|
# VPI_TEST_SW at the command line. Logging of the processor's execution
|
| 77 |
|
|
# is also disabled by default to speed up simulation.
|
| 78 |
|
|
#
|
| 79 |
6 |
julius |
|
| 80 |
|
|
# Simulation results:
|
| 81 |
|
|
#
|
| 82 |
|
|
# The results and output of the event-driven simulations are in the
|
| 83 |
|
|
# results path, in parallel to the simulation run and bin paths.
|
| 84 |
|
|
|
| 85 |
|
|
# Specific tests:
|
| 86 |
|
|
#
|
| 87 |
|
|
# To run an individual test, specify it in the variable TESTS when
|
| 88 |
|
|
# calling make, eg:
|
| 89 |
|
|
#
|
| 90 |
|
|
# make rtl-tests TESTS="mmu-nocache mul-idcd-O2"
|
| 91 |
|
|
|
| 92 |
|
|
# UART printf:
|
| 93 |
|
|
#
|
| 94 |
|
|
# It is possible to enable printf to the console via the UART when
|
| 95 |
|
|
# running the event-driven simulators. To do this define UART_PRINTF=1
|
| 96 |
|
|
# when calling make. The SystemC cycle-acccurate model uses this by
|
| 97 |
|
|
# default.
|
| 98 |
|
|
# Also note when switching between runs with and without UART printf
|
| 99 |
|
|
# enabled, run a clean-sw so the library files are recompiled when
|
| 100 |
|
|
# the tests are run - this is not done automatically.
|
| 101 |
|
|
|
| 102 |
|
|
# VCDs:
|
| 103 |
|
|
#
|
| 104 |
|
|
# VCD (value change dumps, usable in a waveform viewer, such as gtkwave
|
| 105 |
|
|
# to inspect the internals of the system graphically) files can be
|
| 106 |
|
|
# generated by defining a variable VCD, eg.
|
| 107 |
|
|
#
|
| 108 |
|
|
# make rtl-tests VCD=1
|
| 109 |
|
|
#
|
| 110 |
|
|
# and a dump file will be created in the simulation results directory,
|
| 111 |
|
|
# and named according to the test run which generated it. This is
|
| 112 |
|
|
# possible for both event-driven and cycle-accurate simulations.
|
| 113 |
|
|
# However the cycle-accurate
|
| 114 |
|
|
|
| 115 |
|
|
# NO_SIM_LOGGING:
|
| 116 |
|
|
#
|
| 117 |
|
|
# It is possible to speed up the event-driven simulation slightly by
|
| 118 |
|
|
# disabling log output of the processor's state to files by defining
|
| 119 |
|
|
# NO_SIM_LOGGING, eg:
|
| 120 |
|
|
#
|
| 121 |
|
|
# make rtl-tests TESTS=except-icdc NO_SIM_LOGGING=1
|
| 122 |
|
|
#
|
| 123 |
|
|
|
| 124 |
|
|
# Cleaning:
|
| 125 |
|
|
# A simple "make clean" cleans everything - software and all temporary
|
| 126 |
|
|
# simulation files and directories. To clean just the software run:
|
| 127 |
|
|
#
|
| 128 |
|
|
# make clean-sw
|
| 129 |
|
|
#
|
| 130 |
|
|
# and to clean just the temporary simulation files (including VCDs,
|
| 131 |
|
|
# results logs - everything under, and including, sim/results/, run
|
| 132 |
|
|
#
|
| 133 |
|
|
# make clean-sim
|
| 134 |
|
|
#
|
| 135 |
|
|
|
| 136 |
|
|
# Note:
|
| 137 |
|
|
#
|
| 138 |
|
|
# The way each of the test loops is written is probably a bit overly complex
|
| 139 |
|
|
# but this is to save maintaining, and calling, multiple files.
|
| 140 |
|
|
#
|
| 141 |
|
|
|
| 142 |
|
|
# Model configuration:
|
| 143 |
|
|
#
|
| 144 |
|
|
# Currently, the ORPSoCv2, by default, contains an internal SRAM (configurable
|
| 145 |
|
|
# size - check the defparam in rtl/verilog/orpsoc_top.v), standard OR1200 (check
|
| 146 |
|
|
# the config in rtl/verilog/or1200_defines.v) and UART.
|
| 147 |
|
|
# Switches can be passed to enable certain parts of the design if testing with
|
| 148 |
|
|
# these is desired.
|
| 149 |
|
|
#
|
| 150 |
|
|
# SDRAM and controller
|
| 151 |
|
|
#
|
| 152 |
|
|
# To enable the use of SDRAM, define USE_SDRAM when calling the sim -this
|
| 153 |
|
|
# only has an effect in the event-driven simulators as the external SDRAM model
|
| 154 |
|
|
# is not availble in SystemC format. eg:
|
| 155 |
|
|
#
|
| 156 |
|
|
# make rtl-tests USE_SDRAM=1
|
| 157 |
|
|
#
|
| 158 |
|
|
# This not only enables SDRAM but also enables the booting from external SPI
|
| 159 |
|
|
# interfaced flash memory. This causes significant increase in the time taken
|
| 160 |
|
|
# for simulation as the program to test is first loaded out of SPI flash memory
|
| 161 |
|
|
# and into SDRAM before it is executed. Although this more closely mimics the
|
| 162 |
|
|
# behaviour of the hardware, for simulation purposes it is purely time-consuming
|
| 163 |
|
|
# however it may be useful to track down any problems with this boot-loading
|
| 164 |
43 |
julius |
# process. Therefore, becuase it enables SDRAM memory, it also enables the flash
|
| 165 |
6 |
julius |
# memory model and SPI controller inside ORPSoC.
|
| 166 |
|
|
#
|
| 167 |
|
|
# Ethernet
|
| 168 |
|
|
#
|
| 169 |
|
|
# Ethernet is disabled by default. This is due to the fact that it is not
|
| 170 |
|
|
# supported in the verilator/systemC model. Also, there is currently no software
|
| 171 |
|
|
# which tests it in any meaningful way.
|
| 172 |
|
|
#
|
| 173 |
|
|
|
| 174 |
|
|
#
|
| 175 |
|
|
# Event-driven simulation compilation
|
| 176 |
|
|
#
|
| 177 |
|
|
# The way the event-driven simulations are compiled is simply using the
|
| 178 |
|
|
# configuration script file in this directory, currently called icarus.scr -
|
| 179 |
|
|
# however it is first processesed to replace the variables, beginning with $'s,
|
| 180 |
|
|
# with the appropriate paths. Instead of naming each file to be compiled, the
|
| 181 |
|
|
# paths to be searched for each module are instead defined ( -y paths), and
|
| 182 |
|
|
# only the toplevel testbench and library source files are explicitly named.
|
| 183 |
|
|
# This simplifies the script, and also requires that the name of each verilog
|
| 184 |
|
|
# source file is the same as the module it contains (a good convention
|
| 185 |
|
|
# regardless.) In addition to the script/command file, defines are passed to
|
| 186 |
|
|
# the compiler via the command line in the EVENT_SIM_FLAGS variable.
|
| 187 |
|
|
# Additionally, a source file, test_define.v, is created with some defines
|
| 188 |
|
|
# that cannot be passed to the compiled reliably (there are differences between
|
| 189 |
|
|
# the way, for instance, icarus and ncverilog parse strings +define+'d on the
|
| 190 |
|
|
# command line). This file is then included at the appropriate places.
|
| 191 |
|
|
# It is probably not ideal that the entire design be re-compiled for each test,
|
| 192 |
|
|
# but currently the design is small enough so that this doesn't cause a
|
| 193 |
|
|
# significant overhead, unlike the cycle-accurate model compile time.
|
| 194 |
|
|
#
|
| 195 |
|
|
|
| 196 |
|
|
#
|
| 197 |
|
|
# SystemC cycle-accurate model compilation
|
| 198 |
|
|
#
|
| 199 |
|
|
# A new addition to ORPSoC v2 is the cycle-accurate model. The primary enabler
|
| 200 |
44 |
julius |
# behind this is verilator, which processes the RTL source and generates a c++
|
| 201 |
|
|
# description of the system. This c++ description is then compiled, with a
|
| 202 |
6 |
julius |
# SystemC wrapper. Finally a top-level SystemC testbench instantiates the
|
| 203 |
44 |
julius |
# model, and other useful modules - in this case a reset generation, UART
|
| 204 |
6 |
julius |
# decoder, and monitor module are included at the top level. These additional
|
| 205 |
44 |
julius |
# modules and models are written in SystemC. Finally, everything is linked with
|
| 206 |
|
|
# the cycle-accurate ORPSoC model to create the simulation executable. This
|
| 207 |
|
|
# executable is the cycle-representation of the system.
|
| 208 |
|
|
#
|
| 209 |
49 |
julius |
# Run the resulting executable with the -h switch for usage.
|
| 210 |
44 |
julius |
#
|
| 211 |
|
|
# The compilation is all done with the GNU c++ compiler, g++.
|
| 212 |
|
|
#
|
| 213 |
|
|
# The compilation process is a little more complicated than the event-driven
|
| 214 |
6 |
julius |
# simulator. It proceeds basically by generating the makefiles for compiling
|
| 215 |
|
|
# the design with verilator, running these makes which produces a library
|
| 216 |
|
|
# containing the cycle-accurate ORPSoC design, compiling the additional
|
| 217 |
|
|
# top-level, and testbench, systemC models into a library, and then linking it
|
| 218 |
|
|
# all together into the simulation executable.
|
| 219 |
44 |
julius |
#
|
| 220 |
6 |
julius |
# The major advantage of the cycle-accurate model is that it is quicker, in
|
| 221 |
|
|
# terms of simulated cycles/second, when compared with event-driven simulators.
|
| 222 |
|
|
# It is, of course, less accurate in that it cannot model propegation delays.
|
| 223 |
|
|
# However this is usually not an issue for simulating a design which is known
|
| 224 |
|
|
# to synthesize and run OK. It is very useful for running complex software,
|
| 225 |
|
|
# such as the linux kernel and real-time OS applications, which generally
|
| 226 |
44 |
julius |
# result in long simulation times.
|
| 227 |
|
|
#
|
| 228 |
6 |
julius |
# Currently the cycle-accurate model being used doesn't contain much more than
|
| 229 |
|
|
# the processor and a UART, however it's exepected in future this will be
|
| 230 |
|
|
# expanded on and more complex software test suites will be implemented to put
|
| 231 |
|
|
# the system through its paces.
|
| 232 |
|
|
#
|
| 233 |
44 |
julius |
#
|
| 234 |
49 |
julius |
#
|
| 235 |
6 |
julius |
|
| 236 |
44 |
julius |
# Name of the directory we're currently in
|
| 237 |
6 |
julius |
CUR_DIR=$(shell pwd)
|
| 238 |
|
|
|
| 239 |
|
|
# The root path of the whole project
|
| 240 |
|
|
PROJECT_ROOT=$(CUR_DIR)/../..
|
| 241 |
|
|
|
| 242 |
|
|
# Tests is only defined if it wasn't already defined when make was called
|
| 243 |
|
|
# This is the default list of every test that is currently possible
|
| 244 |
|
|
TESTS ?= basic-nocache cbasic-nocache-O2 dhry-nocache-O2 except-nocache mmu-nocache mul-nocache-O2 syscall-nocache tick-nocache uart-nocache basic-icdc cbasic-icdc-O2 dhry-icdc-O2 except-icdc mmu-icdc mul-icdc-O2 syscall-icdc tick-icdc uart-icdc
|
| 245 |
|
|
|
| 246 |
|
|
# Paths to other important parts of this test suite
|
| 247 |
|
|
SIM_DIR=$(PROJECT_ROOT)/sim
|
| 248 |
|
|
SIM_RUN_DIR=$(SIM_DIR)/run
|
| 249 |
|
|
SIM_BIN_DIR=$(SIM_DIR)/bin
|
| 250 |
|
|
SIM_RESULTS_DIR=$(SIM_DIR)/results
|
| 251 |
|
|
SIM_VLT_DIR=$(SIM_DIR)/vlt
|
| 252 |
|
|
BENCH_DIR=$(PROJECT_ROOT)/bench
|
| 253 |
|
|
BACKEND_DIR=$(PROJECT_ROOT)/backend
|
| 254 |
|
|
BENCH_VERILOG_DIR=$(BENCH_DIR)/verilog
|
| 255 |
|
|
BENCH_SYSC_DIR=$(BENCH_DIR)/sysc
|
| 256 |
|
|
BENCH_SYSC_SRC_DIR=$(BENCH_SYSC_DIR)/src
|
| 257 |
|
|
BENCH_SYSC_INCLUDE_DIR=$(BENCH_SYSC_DIR)/include
|
| 258 |
|
|
RTL_VERILOG_DIR=$(PROJECT_ROOT)/rtl/verilog
|
| 259 |
|
|
SW_DIR=$(PROJECT_ROOT)/sw
|
| 260 |
|
|
|
| 261 |
|
|
ICARUS=iverilog
|
| 262 |
|
|
ICARUS_VVP=vvp
|
| 263 |
|
|
ICARUS_COMMAND_FILE=icarus.scr
|
| 264 |
|
|
VLT_COMMAND_FILE=verilator.scr
|
| 265 |
|
|
SIM_SUCCESS_MESSAGE=deaddead
|
| 266 |
55 |
julius |
MGC_COMMAND_FILE=modelsim.scr
|
| 267 |
6 |
julius |
|
| 268 |
|
|
ARCH_SIM_EXE=or32-elf-sim
|
| 269 |
|
|
ARCH_SIM_CFG_FILE=or1ksim-orpsocv2.cfg
|
| 270 |
|
|
|
| 271 |
57 |
julius |
# Set V=1 when calling make to enable verbose output
|
| 272 |
|
|
# mainly for debugging purposes.
|
| 273 |
|
|
ifeq ($(V), 1)
|
| 274 |
|
|
Q=
|
| 275 |
|
|
else
|
| 276 |
|
|
Q=@
|
| 277 |
|
|
endif
|
| 278 |
|
|
|
| 279 |
6 |
julius |
# If USE_SDRAM is defined we'll add it to the simulator's defines on the
|
| 280 |
|
|
# command line becuase it's used by many different modules and it's easier
|
| 281 |
|
|
# to do it this way than make them all include a file.
|
| 282 |
|
|
ifdef USE_SDRAM
|
| 283 |
|
|
EVENT_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
|
| 284 |
|
|
endif
|
| 285 |
|
|
|
| 286 |
55 |
julius |
# Set SIMULATOR=vsim on command line to use Modelsim
|
| 287 |
|
|
ifeq ($(SIMULATOR), vsim)
|
| 288 |
|
|
# Modelsim
|
| 289 |
|
|
SIM_COMMANDFILE=$(MGC_COMMAND_FILE)
|
| 290 |
|
|
else
|
| 291 |
|
|
# Icarus Verilog Simulator
|
| 292 |
|
|
SIM_COMMANDFILE=$(ICARUS_COMMAND_FILE)
|
| 293 |
|
|
endif
|
| 294 |
51 |
julius |
|
| 295 |
55 |
julius |
GENERATED_COMMANDFILE=$(SIM_COMMANDFILE).generated
|
| 296 |
51 |
julius |
|
| 297 |
55 |
julius |
# When Modelsim is selected as simulator, we compile
|
| 298 |
|
|
# the ORPSoC system into one library called orpsoc and
|
| 299 |
|
|
# then simply re-compile the testbench and or1200_monitor
|
| 300 |
|
|
# whenever we run the simulation, so just that part is
|
| 301 |
|
|
# recompiled for every test, instead of the whole thing.
|
| 302 |
|
|
MGC_ORPSOC_LIB=orpsoc
|
| 303 |
|
|
MGC_ORPSOC_LIB_DIR=$(SIM_RUN_DIR)/$(MGC_ORPSOC_LIB)
|
| 304 |
|
|
|
| 305 |
|
|
# If VCD dump is desired, tell Modelsim not to optimise
|
| 306 |
|
|
# away everything.
|
| 307 |
|
|
ifeq ($(VCD), 1)
|
| 308 |
|
|
VOPT_ARGS=-voptargs="+acc=rnp"
|
| 309 |
|
|
endif
|
| 310 |
|
|
|
| 311 |
|
|
# Simulation compile and run commands, depending on your
|
| 312 |
|
|
# simulator. Currently only Modelsim (vsim) and Icarus right
|
| 313 |
|
|
# now.
|
| 314 |
|
|
# TODO: Put the NC-sim commands in here too and have just the
|
| 315 |
|
|
# single simulation test loop rule.
|
| 316 |
|
|
ifeq ($(SIMULATOR), vsim)
|
| 317 |
|
|
# Line to compile the orpsoc design into a modelsim library.
|
| 318 |
|
|
SIM_COMMANDCOMPILE=if [ ! -e work ]; then vlib work; vlib $(MGC_ORPSOC_LIB); vlog -work orpsoc -f $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE); fi
|
| 319 |
|
|
# Final modelsim compile, done each time, pulling in or1200
|
| 320 |
|
|
# monitor and the new test_defines.v file:
|
| 321 |
|
|
VSIM_COMPILE_TB=vlog +incdir+. +incdir+$(BENCH_VERILOG_DIR) +incdir+$(RTL_VERILOG_DIR) +define+TEST_DEFINE_FILE $(BENCH_VERILOG_DIR)/or1200_monitor.v $(BENCH_VERILOG_DIR)/orpsoc_testbench.v
|
| 322 |
|
|
# Simulation run command:
|
| 323 |
|
|
SIM_COMMANDRUN=$(VSIM_COMPILE_TB); vsim -c -quiet +nowarnTFMPC -L $(MGC_ORPSOC_LIB) $(VOPT_ARGS) -do "run -all; exit" orpsoc_testbench
|
| 324 |
|
|
else
|
| 325 |
|
|
# Icarus Verilog Simulator compile command
|
| 326 |
|
|
SIM_COMMANDCOMPILE=rm -f $(SIM_RUN_DIR)/a.out; $(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE) $(EVENT_SIM_FLAGS)
|
| 327 |
|
|
# Icarus Verilog run command
|
| 328 |
|
|
SIM_COMMANDRUN=$(ICARUS_VVP) -l $(SIM_RESULTS_DIR)/$$TEST-vvp-out.log a.out
|
| 329 |
|
|
endif
|
| 330 |
|
|
|
| 331 |
6 |
julius |
# Enable ethernet if defined on the command line
|
| 332 |
|
|
ifdef USE_ETHERNET
|
| 333 |
44 |
julius |
EVENT_SIM_FLAGS += "-D USE_ETHERNET=$(USE_ETHERNET) -D USE_ETHERNET_IO=$(USE_ETHERNET)"
|
| 334 |
|
|
# Extra tests we do if ethernet is enabled
|
| 335 |
51 |
julius |
TESTS += eth-basic eth-int
|
| 336 |
6 |
julius |
endif
|
| 337 |
|
|
|
| 338 |
|
|
SIM_FLASH_MEM_FILE="flash.in"
|
| 339 |
|
|
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
|
| 340 |
|
|
SIM_SRAM_MEM_FILE="sram.vmem"
|
| 341 |
|
|
|
| 342 |
|
|
TESTS_PASSED=0
|
| 343 |
|
|
TESTS_PERFORMED=0;
|
| 344 |
|
|
|
| 345 |
|
|
################################################################################
|
| 346 |
|
|
# Event-driven simulator build rules (Icarus, NCSim)
|
| 347 |
|
|
################################################################################
|
| 348 |
|
|
|
| 349 |
51 |
julius |
$(RTL_VERILOG_DIR)/components/wb_sdram_ctrl/wb_sdram_ctrl_fsm.v:
|
| 350 |
|
|
@cd $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl && perl fizzim.pl -encoding onehot -terse < wb_sdram_ctrl_fsm.fzm > wb_sdram_ctrl_fsm.v
|
| 351 |
6 |
julius |
|
| 352 |
57 |
julius |
.PHONY: prepare-rtl
|
| 353 |
|
|
prepare-rtl: $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl/wb_sdram_ctrl_fsm.v
|
| 354 |
6 |
julius |
|
| 355 |
55 |
julius |
$(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE): $(SIM_BIN_DIR)/$(SIM_COMMANDFILE)
|
| 356 |
57 |
julius |
$(Q)sed < $(SIM_BIN_DIR)/$(SIM_COMMANDFILE) > $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE) \
|
| 357 |
55 |
julius |
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
| 358 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
| 359 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
| 360 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d ; \
|
| 361 |
|
|
echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE); \
|
| 362 |
|
|
if [ ! -z $$VCD ]; \
|
| 363 |
|
|
then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE); \
|
| 364 |
|
|
fi; \
|
| 365 |
|
|
if [ ! -z $$UART_PRINTF ]; \
|
| 366 |
|
|
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE); \
|
| 367 |
|
|
fi
|
| 368 |
51 |
julius |
|
| 369 |
6 |
julius |
ifdef UART_PRINTF
|
| 370 |
44 |
julius |
TEST_SW_MAKE_OPTS="UART_PRINTF=1"
|
| 371 |
6 |
julius |
endif
|
| 372 |
|
|
|
| 373 |
57 |
julius |
.PHONY: prepare-sw
|
| 374 |
|
|
prepare-sw:
|
| 375 |
|
|
$(Q)$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
|
| 376 |
|
|
$(Q)$(MAKE) -C $(SW_DIR)/utils all
|
| 377 |
6 |
julius |
|
| 378 |
|
|
# A rule with UART_PRINTF hard defined ... used by verilator make sw
|
| 379 |
57 |
julius |
prepare-sw-uart-printf:
|
| 380 |
|
|
$(Q)$(MAKE) -C $(SW_DIR)/support all UART_PRINTF=1 $(TEST_SW_MAKE_OPTS)
|
| 381 |
|
|
$(Q)$(MAKE) -C $(SW_DIR)/utils all
|
| 382 |
6 |
julius |
|
| 383 |
57 |
julius |
prepare-dirs:
|
| 384 |
|
|
$(Q)if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
|
| 385 |
6 |
julius |
|
| 386 |
55 |
julius |
#
|
| 387 |
|
|
# Rough guide to how event driven simulation test loop works:
|
| 388 |
|
|
#
|
| 389 |
|
|
# 1. Compile software support programs.
|
| 390 |
|
|
# 2. Generate RTL compilation script file
|
| 391 |
|
|
# 3. For each test listed in $(TESTS), loop and
|
| 392 |
|
|
# a) Compile software
|
| 393 |
|
|
# b) Create appropriate image to be loaded into sim
|
| 394 |
|
|
# c) Create a verilog file to be included by top level
|
| 395 |
|
|
# d) Compile the RTL design
|
| 396 |
|
|
# e) Run the RTL design in the chosen simulator
|
| 397 |
|
|
# f) Check the output (files in ../results)
|
| 398 |
|
|
#
|
| 399 |
|
|
# Default setup is:
|
| 400 |
|
|
# * Event-driven simulation with Icarus Verilog
|
| 401 |
|
|
# * Internal SRAM memory, preloaded with application
|
| 402 |
|
|
# * Ethernet disabled
|
| 403 |
|
|
# * VCD generation disabled
|
| 404 |
|
|
# * printf() via UART disabled
|
| 405 |
|
|
# * Logging enabled
|
| 406 |
|
|
#
|
| 407 |
|
|
# Options:
|
| 408 |
|
|
# SIMULATOR=vsim
|
| 409 |
|
|
# Use Mentor Graphics Modelsim simulator
|
| 410 |
|
|
# USE_SDRAM=1
|
| 411 |
|
|
# Enable use of SDRAM - changes boot sequence and takes
|
| 412 |
|
|
# a lot longer due to application being loaded out of
|
| 413 |
|
|
# external FLASH memory and into SDRAM before execution
|
| 414 |
|
|
# from the SDRAM.
|
| 415 |
|
|
# VCD=1
|
| 416 |
|
|
# Enable VCD generation. These files are output to
|
| 417 |
|
|
# ../results
|
| 418 |
|
|
# USE_ETHERNET=1
|
| 419 |
|
|
# Turns on ethernet core inclusion. There are currently
|
| 420 |
|
|
# some tests, but not included by default. Check the sw
|
| 421 |
|
|
# directory
|
| 422 |
|
|
# UART_PRINTF=1
|
| 423 |
|
|
# Make the software use the UART core to print out
|
| 424 |
|
|
# printf() calls.
|
| 425 |
|
|
# NO_SIM_LOGGING=1
|
| 426 |
|
|
# Turn off generation of logging files in the ../results
|
| 427 |
|
|
# directory.
|
| 428 |
|
|
#
|
| 429 |
57 |
julius |
rtl-tests: $(SIM_RUN_DIR)/$(GENERATED_COMMANDFILE) prepare-sw prepare-rtl prepare-dirs
|
| 430 |
6 |
julius |
@echo
|
| 431 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
| 432 |
|
|
@echo
|
| 433 |
57 |
julius |
$(Q)for TEST in $(TESTS); do \
|
| 434 |
6 |
julius |
echo "################################################################################"; \
|
| 435 |
|
|
echo; \
|
| 436 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
| 437 |
|
|
echo "\t#### Compiling software ####"; echo; \
|
| 438 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
| 439 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS); \
|
| 440 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 441 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 442 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST$(FLASH_MEM_FILE_SUFFIX) $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 443 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 444 |
55 |
julius |
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
| 445 |
|
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
| 446 |
6 |
julius |
if [ ! -z $$VCD ]; \
|
| 447 |
55 |
julius |
then echo "\`define VCD" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 448 |
6 |
julius |
fi; \
|
| 449 |
|
|
if [ ! -z $$UART_PRINTF ]; \
|
| 450 |
55 |
julius |
then echo "\`define UART_PRINTF" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 451 |
6 |
julius |
fi; \
|
| 452 |
44 |
julius |
if echo $$TEST | grep -q -i ^eth; then \
|
| 453 |
|
|
echo "\`define ENABLE_ETH_STIM" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 454 |
|
|
echo "\`define ETH_PHY_VERBOSE" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 455 |
|
|
fi; \
|
| 456 |
43 |
julius |
if [ -z $$NO_SIM_LOGGING ]; then \
|
| 457 |
6 |
julius |
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 458 |
|
|
fi; \
|
| 459 |
|
|
echo ; \
|
| 460 |
|
|
echo "\t#### Compiling RTL ####"; \
|
| 461 |
55 |
julius |
$(SIM_COMMANDCOMPILE); \
|
| 462 |
6 |
julius |
echo; \
|
| 463 |
|
|
echo "\t#### Beginning simulation ####"; \
|
| 464 |
55 |
julius |
time -p $(SIM_COMMANDRUN) ; \
|
| 465 |
6 |
julius |
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
| 466 |
|
|
TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
|
| 467 |
|
|
echo; echo "\t####"; \
|
| 468 |
|
|
if [ $$TEST_RESULT -gt 0 ]; then \
|
| 469 |
|
|
echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
|
| 470 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
| 471 |
|
|
fi; \
|
| 472 |
|
|
echo "\t####"; echo; \
|
| 473 |
|
|
TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
|
| 474 |
|
|
done; \
|
| 475 |
|
|
echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
|
| 476 |
|
|
|
| 477 |
|
|
|
| 478 |
|
|
|
| 479 |
|
|
# Use NCSIM instead of icarus
|
| 480 |
57 |
julius |
rtl-nc-tests: prepare-sw prepare-rtl prepare-dirs
|
| 481 |
6 |
julius |
@echo
|
| 482 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
| 483 |
|
|
@echo
|
| 484 |
57 |
julius |
$(Q)for TEST in $(TESTS); do \
|
| 485 |
6 |
julius |
echo "################################################################################"; \
|
| 486 |
|
|
echo; \
|
| 487 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
| 488 |
|
|
echo "\t#### Compiling software ####"; echo; \
|
| 489 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
| 490 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST; \
|
| 491 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 492 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 493 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST_twobyte_sizefirst.hex $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 494 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST_fourbyte.hex $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 495 |
|
|
sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
|
| 496 |
|
|
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
| 497 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
| 498 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
| 499 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d ; \
|
| 500 |
|
|
echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 501 |
|
|
if [ ! -z $$VCD ]; \
|
| 502 |
|
|
then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 503 |
|
|
echo "+access+r" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 504 |
|
|
fi; \
|
| 505 |
|
|
if [ ! -z $$UART_PRINTF ]; \
|
| 506 |
|
|
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 507 |
|
|
fi; \
|
| 508 |
|
|
if [ ! -z $$USE_SDRAM ]; then \
|
| 509 |
|
|
echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 510 |
|
|
fi; \
|
| 511 |
44 |
julius |
if echo $$TEST | grep -q -i ^eth; then \
|
| 512 |
|
|
echo "\`define ENABLE_ETH_STIM" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 513 |
|
|
echo "\`define ETH_PHY_VERBOSE" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 514 |
|
|
fi; \
|
| 515 |
6 |
julius |
echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 516 |
|
|
echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
| 517 |
|
|
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
| 518 |
|
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
| 519 |
|
|
if [ -z $$NO_SIM_LOGGING ]; then \
|
| 520 |
|
|
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
| 521 |
|
|
fi; \
|
| 522 |
|
|
echo ; \
|
| 523 |
|
|
echo "\t#### Beginning simulation ####"; \
|
| 524 |
|
|
time -p ncverilog -f $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated -Q -l $(SIM_RESULTS_DIR)/$$TEST-ius-out.log $(EVENT_SIM_FLAGS); \
|
| 525 |
|
|
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
| 526 |
|
|
TEST_RESULT=`cat $(SIM_RESULTS_DIR)/$$TEST-general.log | grep report | grep $(SIM_SUCCESS_MESSAGE) -c`; \
|
| 527 |
|
|
echo; echo "\t####"; \
|
| 528 |
|
|
if [ $$TEST_RESULT -gt 0 ]; then \
|
| 529 |
|
|
echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
|
| 530 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
| 531 |
|
|
fi; \
|
| 532 |
|
|
echo "\t####"; echo; \
|
| 533 |
|
|
TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
|
| 534 |
|
|
done; \
|
| 535 |
|
|
echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
|
| 536 |
|
|
|
| 537 |
|
|
################################################################################
|
| 538 |
40 |
julius |
# RTL simulation in Icarus with GDB stub via VPI for debugging
|
| 539 |
|
|
################################################################################
|
| 540 |
|
|
# This compiles a version of the system which starts up the dhrystone nocache
|
| 541 |
|
|
# test, and launches the simulator with a VPI module that provides a GDB stub
|
| 542 |
|
|
# allowing the OpenRISC compatible GDB to connect and debug the system.
|
| 543 |
|
|
# The launched test can be changed by defining VPI_TEST_SW on the make line
|
| 544 |
|
|
VPI_DIR=$(BENCH_VERILOG_DIR)/vpi
|
| 545 |
|
|
VPI_C_DIR=$(VPI_DIR)/c
|
| 546 |
|
|
VPI_VERILOG_DIR=$(VPI_DIR)/verilog
|
| 547 |
|
|
VPI_LIB_NAME=jp_vpi
|
| 548 |
|
|
ICARUS_VPI_OPTS=-M$(VPI_C_DIR) -m$(VPI_LIB_NAME)
|
| 549 |
|
|
VPI_TEST_SW ?= dhry-nocache-O2
|
| 550 |
|
|
|
| 551 |
57 |
julius |
prepare-vpi:
|
| 552 |
40 |
julius |
## Build the VPI library
|
| 553 |
|
|
$(MAKE) -C $(VPI_C_DIR) $(VPI_LIB_NAME)
|
| 554 |
|
|
|
| 555 |
49 |
julius |
clean-vpi:
|
| 556 |
40 |
julius |
$(MAKE) -C $(VPI_C_DIR) clean
|
| 557 |
|
|
|
| 558 |
57 |
julius |
rtl-debug: prepare-sw-uart-printf prepare-rtl prepare-vpi prepare-dirs
|
| 559 |
40 |
julius |
## Prepare the software for the test
|
| 560 |
|
|
@echo "\t#### Compiling software ####"; echo; \
|
| 561 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $(VPI_TEST_SW) | cut -d "-" -f 1`; \
|
| 562 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $(VPI_TEST_SW) $(TEST_SW_MAKE_OPTS); \
|
| 563 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 564 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 565 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$(VPI_TEST_SW)$(FLASH_MEM_FILE_SUFFIX) $(SIM_RUN_DIR)/$(SIM_FLASH_MEM_FILE); \
|
| 566 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$(VPI_TEST_SW).vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE)
|
| 567 |
|
|
## Generate the icarus script we'll compile with
|
| 568 |
57 |
julius |
$(Q)sed < $(SIM_BIN_DIR)/$(ICARUS_COMMAND_FILE) > $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated \
|
| 569 |
40 |
julius |
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
| 570 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
| 571 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
| 572 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d
|
| 573 |
|
|
## Add a couple of extra defines to the icarus compile script
|
| 574 |
57 |
julius |
$(Q)echo "+define+TEST_DEFINE_FILE=\"test_define.v\"" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated
|
| 575 |
40 |
julius |
## The define that enables the VPI debug module
|
| 576 |
57 |
julius |
$(Q)echo "+define+VPI_DEBUG_ENABLE" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated
|
| 577 |
|
|
$(Q)if [ ! -z $$VCD ];then echo "+define+VCD" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated;fi
|
| 578 |
40 |
julius |
## Unless NO_UART_PRINTF=1 we use printf via the UART
|
| 579 |
57 |
julius |
$(Q)if [ -z $$NO_UART_PRINTF ];then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; fi
|
| 580 |
|
|
$(Q)echo "\`define TEST_NAME_STRING \"$(VPI_TEST_SW)-vpi\"" > $(SIM_RUN_DIR)/test_define.v
|
| 581 |
|
|
$(Q)echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v
|
| 582 |
|
|
$(Q)if [ -z $$NO_SIM_LOGGING ]; then echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; fi
|
| 583 |
40 |
julius |
@echo
|
| 584 |
|
|
@echo "\t#### Compiling RTL ####"
|
| 585 |
57 |
julius |
$(Q)rm -f $(SIM_RUN_DIR)/a.out
|
| 586 |
|
|
$(Q)$(ICARUS) -sorpsoc_testbench -c $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated $(EVENT_SIM_FLAGS)
|
| 587 |
40 |
julius |
@echo
|
| 588 |
|
|
@echo "\t#### Beginning simulation with VPI debug module enabled ####"; echo
|
| 589 |
57 |
julius |
$(Q)$(ICARUS_VVP) $(ICARUS_VPI_OPTS) -l $(SIM_RESULTS_DIR)/$(VPI_TEST_SW)-vvp-out.log a.out
|
| 590 |
40 |
julius |
|
| 591 |
|
|
################################################################################
|
| 592 |
6 |
julius |
# Verilator model build rules
|
| 593 |
|
|
################################################################################
|
| 594 |
|
|
|
| 595 |
|
|
|
| 596 |
|
|
SYSC_LIB_ARCH_DIR=$(shell ls $$SYSTEMC | grep "lib-")
|
| 597 |
|
|
|
| 598 |
|
|
|
| 599 |
|
|
# List of System C models - use this list to link the sources into the Verilator
|
| 600 |
|
|
# build directory
|
| 601 |
51 |
julius |
SYSC_MODELS=OrpsocAccess MemoryLoad
|
| 602 |
6 |
julius |
|
| 603 |
49 |
julius |
ifdef VLT_DEBUG
|
| 604 |
|
|
VLT_DEBUG_COMPILE_FLAGS = -g
|
| 605 |
|
|
# Enabling the following generates a TON of debugging
|
| 606 |
|
|
# when running verilator. Not so helpful.
|
| 607 |
|
|
#VLT_DEBUG_OPTIONS = --debug --dump-tree
|
| 608 |
|
|
VLT_SYSC_DEBUG_DEFINE = VLT_DEBUG=1
|
| 609 |
6 |
julius |
endif
|
| 610 |
|
|
|
| 611 |
49 |
julius |
# If set on the command line we build the cycle accurate model which will generate verilator-specific profiling information. This is useful for checking the efficiency of the model - not really useful for checking code or the function of the model.
|
| 612 |
|
|
ifdef VLT_ORPSOC_PROFILING
|
| 613 |
|
|
VLT_CPPFLAGS=-g -pg
|
| 614 |
|
|
VLT_DEBUG_OPTIONS +=-profile-cfuncs
|
| 615 |
|
|
else
|
| 616 |
53 |
julius |
VLT_CPPFLAGS=-fbranch-probabilities -fvpt -funroll-loops -fpeel-loops -ftracer -O3
|
| 617 |
|
|
#VLT_CPPFLAGS=-Wall
|
| 618 |
49 |
julius |
endif
|
| 619 |
|
|
|
| 620 |
|
|
ifdef VLT_DO_PROFILING
|
| 621 |
|
|
VLT_CPPFLAGS=-O3 -ftest-coverage -fprofile-generate
|
| 622 |
|
|
endif
|
| 623 |
|
|
|
| 624 |
|
|
# VCD Enabled by default when building, enable it at runtime
|
| 625 |
|
|
#ifdef VCD
|
| 626 |
|
|
VLT_FLAGS +=-trace
|
| 627 |
|
|
TRACE_FLAGS=-DVM_TRACE=1 -I${SYSTEMPERL}/src
|
| 628 |
|
|
#endif
|
| 629 |
|
|
|
| 630 |
6 |
julius |
# Only need the trace target if we are tracing
|
| 631 |
49 |
julius |
#ifneq (,$(findstring -trace, $(VLT_FLAGS)))
|
| 632 |
6 |
julius |
VLT_TRACEOBJ = SpTraceVcdC
|
| 633 |
49 |
julius |
#endif
|
| 634 |
6 |
julius |
|
| 635 |
|
|
# This is the list of extra models we'll issue make commands for
|
| 636 |
|
|
# Included is the SystemPerl trace model
|
| 637 |
|
|
SYSC_MODELS_BUILD=$(SYSC_MODELS) $(VLT_TRACEOBJ)
|
| 638 |
|
|
|
| 639 |
57 |
julius |
prepare-vlt: prepare-rtl vlt_model_links $(SIM_VLT_DIR)/Vorpsoc_top
|
| 640 |
54 |
julius |
@echo;echo "\tCycle-accurate model compiled successfully"
|
| 641 |
|
|
@echo;echo "\tRun the executable with the -h option for usage instructions:";echo
|
| 642 |
|
|
$(SIM_VLT_DIR)/Vorpsoc_top -h
|
| 643 |
|
|
@echo;echo
|
| 644 |
6 |
julius |
|
| 645 |
|
|
$(SIM_VLT_DIR)/Vorpsoc_top: $(SIM_VLT_DIR)/libVorpsoc_top.a $(SIM_VLT_DIR)/OrpsocMain.o
|
| 646 |
|
|
# Final linking of the simulation executable. Order of libraries here is important!
|
| 647 |
|
|
@echo; echo "\tGenerating simulation executable"; echo
|
| 648 |
49 |
julius |
cd $(SIM_VLT_DIR) && g++ $(VLT_DEBUG_COMPILE_FLAGS) $(VLT_CPPFLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) -I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -o Vorpsoc_top -L. -L$(BENCH_SYSC_SRC_DIR) -L$(SYSTEMC)/$(SYSC_LIB_ARCH_DIR) OrpsocMain.o -lVorpsoc_top -lmodules -lsystemc
|
| 649 |
6 |
julius |
|
| 650 |
51 |
julius |
# Now compile the top level systemC "testbench" module from the systemC source path
|
| 651 |
|
|
$(SIM_VLT_DIR)/OrpsocMain.o: $(BENCH_SYSC_SRC_DIR)/OrpsocMain.cpp
|
| 652 |
6 |
julius |
@echo; echo "\tCompiling top level SystemC testbench"; echo
|
| 653 |
49 |
julius |
cd $(SIM_VLT_DIR) && g++ $(VLT_DEBUG_COMPILE_FLAGS) $(VLT_CPPFLAGS) $(TRACE_FLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(SIM_VLT_DIR) -I$(VERILATOR_ROOT)/include -I$(SYSTEMC)/include -c $(BENCH_SYSC_SRC_DIR)/OrpsocMain.cpp
|
| 654 |
6 |
julius |
|
| 655 |
57 |
julius |
$(SIM_VLT_DIR)/libVorpsoc_top.a: $(SIM_VLT_DIR)/Vorpsoc_top__ALL.a vlt-modules-compile $(SIM_VLT_DIR)/verilated.o
|
| 656 |
6 |
julius |
# Now archive all of the libraries from verilator witht he other modules we might have
|
| 657 |
|
|
@echo; echo "\tArchiving libraries into libVorpsoc_top.a"; echo
|
| 658 |
57 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
| 659 |
6 |
julius |
cp Vorpsoc_top__ALL.a libVorpsoc_top.a && \
|
| 660 |
|
|
ar rcs libVorpsoc_top.a verilated.o; \
|
| 661 |
|
|
for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
|
| 662 |
|
|
ar rcs libVorpsoc_top.a $$SYSCMODEL.o; \
|
| 663 |
|
|
done
|
| 664 |
|
|
|
| 665 |
|
|
$(SIM_VLT_DIR)/verilated.o:
|
| 666 |
|
|
@echo; echo "\tCompiling verilated.o"; echo
|
| 667 |
57 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
| 668 |
49 |
julius |
export CXXFLAGS=$(VLT_DEBUG_COMPILE_FLAGS); \
|
| 669 |
|
|
export USER_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
| 670 |
|
|
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
| 671 |
6 |
julius |
$(MAKE) -f Vorpsoc_top.mk verilated.o
|
| 672 |
|
|
|
| 673 |
57 |
julius |
.PHONY: vlt-modules-compile
|
| 674 |
|
|
vlt-modules-compile:
|
| 675 |
6 |
julius |
# Compile the module files
|
| 676 |
|
|
@echo; echo "\tCompiling SystemC models"
|
| 677 |
57 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
| 678 |
6 |
julius |
for SYSCMODEL in $(SYSC_MODELS_BUILD); do \
|
| 679 |
|
|
echo;echo "\t$$SYSCMODEL"; echo; \
|
| 680 |
49 |
julius |
export CXXFLAGS=$(VLT_DEBUG_COMPILE_FLAGS); \
|
| 681 |
51 |
julius |
export USER_CPPFLAGS="$(VLT_CPPFLAGS) -I$(BENCH_SYSC_INCLUDE_DIR)"; \
|
| 682 |
49 |
julius |
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
| 683 |
|
|
$(MAKE) -f Vorpsoc_top.mk $$SYSCMODEL.o; \
|
| 684 |
|
|
done
|
| 685 |
6 |
julius |
|
| 686 |
|
|
$(SIM_VLT_DIR)/Vorpsoc_top__ALL.a: $(SIM_VLT_DIR)/Vorpsoc_top.mk
|
| 687 |
|
|
@echo; echo "\tCompiling main design"; echo
|
| 688 |
57 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
| 689 |
49 |
julius |
export USER_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
| 690 |
|
|
export USER_LDDFLAGS="$(VLT_CPPFLAGS)"; \
|
| 691 |
6 |
julius |
$(MAKE) -f Vorpsoc_top.mk Vorpsoc_top__ALL.a
|
| 692 |
|
|
|
| 693 |
|
|
$(SIM_VLT_DIR)/Vorpsoc_top.mk: $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated $(SIM_VLT_DIR)/libmodules.a
|
| 694 |
|
|
# Now call verilator to generate the .mk files
|
| 695 |
|
|
@echo; echo "\tGenerating makefiles with Verilator"; echo
|
| 696 |
|
|
cd $(SIM_VLT_DIR) && \
|
| 697 |
49 |
julius |
verilator -language 1364-2001 -Wno-lint --top-module orpsoc_top $(VLT_DEBUG_OPTIONS) -Mdir . -sc $(VLT_FLAGS) -I$(BENCH_SYSC_INCLUDE_DIR) -I$(BENCH_SYSC_SRC_DIR) -f $(VLT_COMMAND_FILE).generated
|
| 698 |
6 |
julius |
|
| 699 |
|
|
# SystemC modules library
|
| 700 |
|
|
$(SIM_VLT_DIR)/libmodules.a:
|
| 701 |
|
|
@echo; echo "\tCompiling SystemC modules"; echo
|
| 702 |
57 |
julius |
$(Q)export VLT_CPPFLAGS="$(VLT_CPPFLAGS)"; \
|
| 703 |
49 |
julius |
$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f $(BENCH_SYSC_SRC_DIR)/Modules.make $(VLT_SYSC_DEBUG_DEFINE)
|
| 704 |
6 |
julius |
|
| 705 |
|
|
|
| 706 |
51 |
julius |
ALL_VLOG=$(shell find $(RTL_VERILOG_DIR) -name "*.v")
|
| 707 |
|
|
|
| 708 |
6 |
julius |
# Verilator command script
|
| 709 |
51 |
julius |
# Generate the compile script to give Verilator - make it sensitive to the RTL
|
| 710 |
|
|
$(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated: $(ALL_VLOG)
|
| 711 |
6 |
julius |
@echo; echo "\tGenerating verilator compile script"; echo
|
| 712 |
57 |
julius |
$(Q)sed < $(SIM_BIN_DIR)/$(VLT_COMMAND_FILE) > $(SIM_VLT_DIR)/$(VLT_COMMAND_FILE).generated \
|
| 713 |
6 |
julius |
-e s!\$$BENCH_DIR!$(BENCH_VERILOG_DIR)! \
|
| 714 |
|
|
-e s!\$$RTL_DIR!$(RTL_VERILOG_DIR)! \
|
| 715 |
|
|
-e s!\$$BACKEND_DIR!$(BACKEND_DIR)! \
|
| 716 |
|
|
-e \\!^//.*\$$!d -e \\!^\$$!d;
|
| 717 |
|
|
|
| 718 |
|
|
.PHONY: vlt_model_links
|
| 719 |
|
|
vlt_model_links:
|
| 720 |
|
|
# Link all the required system C model files into the verilator work dir
|
| 721 |
|
|
@echo; echo "\tLinking SystemC model source to verilator build path"; echo
|
| 722 |
|
|
@if [ ! -d $(SIM_VLT_DIR) ]; then mkdir $(SIM_VLT_DIR); fi
|
| 723 |
57 |
julius |
$(Q)cd $(SIM_VLT_DIR) && \
|
| 724 |
6 |
julius |
for SYSCMODEL in $(SYSC_MODELS); do \
|
| 725 |
|
|
if [ ! -e $$SYSCMODEL.cpp ]; then \
|
| 726 |
|
|
ln -s $(BENCH_SYSC_SRC_DIR)/$$SYSCMODEL.cpp .; \
|
| 727 |
|
|
ln -s $(BENCH_SYSC_INCLUDE_DIR)/$$SYSCMODEL.h .; \
|
| 728 |
|
|
fi; \
|
| 729 |
|
|
done
|
| 730 |
|
|
|
| 731 |
|
|
|
| 732 |
|
|
################################################################################
|
| 733 |
|
|
# Verilator test loop
|
| 734 |
|
|
################################################################################
|
| 735 |
|
|
|
| 736 |
|
|
# Verilator defaults to internal memories
|
| 737 |
57 |
julius |
vlt-tests: prepare-sw-uart-printf prepare-rtl prepare-dirs prepare-vlt
|
| 738 |
6 |
julius |
@echo
|
| 739 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
| 740 |
|
|
@echo
|
| 741 |
57 |
julius |
$(Q)for TEST in $(TESTS); do \
|
| 742 |
6 |
julius |
echo "################################################################################"; \
|
| 743 |
|
|
echo; \
|
| 744 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
| 745 |
|
|
echo "\t#### Compiling software ####"; echo; \
|
| 746 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
| 747 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
|
| 748 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 749 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST.vmem $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 750 |
|
|
echo "\t#### Beginning simulation ####"; \
|
| 751 |
|
|
time -p $(SIM_VLT_DIR)/Vorpsoc_top $$TEST; \
|
| 752 |
|
|
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
| 753 |
|
|
TEST_RESULT=1; \
|
| 754 |
|
|
echo; echo "\t####"; \
|
| 755 |
|
|
if [ $$TEST_RESULT -gt 0 ]; then \
|
| 756 |
|
|
echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
|
| 757 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
| 758 |
|
|
fi; \
|
| 759 |
|
|
echo "\t####"; echo; \
|
| 760 |
|
|
TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
|
| 761 |
|
|
done; \
|
| 762 |
|
|
echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
|
| 763 |
|
|
|
| 764 |
49 |
julius |
###############################################################################
|
| 765 |
|
|
# Verilator profiled module make
|
| 766 |
|
|
###############################################################################
|
| 767 |
57 |
julius |
# To run this, first run a "make prepare-vlt VLT_DO_PROFILING=1" then do a
|
| 768 |
|
|
# "make clean" and then a "make prepare-vlt_profiled"
|
| 769 |
49 |
julius |
# This new make target copies athe results of the profiling back to the right
|
| 770 |
|
|
# paths before we create everything again
|
| 771 |
|
|
###############################################################################
|
| 772 |
57 |
julius |
prepare-vlt-profiled: vlt_restore-profileoutput prepare-rtl vlt-model-links $(SIM_VLT_DIR)/Vorpsoc_top
|
| 773 |
6 |
julius |
|
| 774 |
57 |
julius |
vlt-restore-profileoutput:
|
| 775 |
49 |
julius |
@echo;echo "\tRestoring profiling outputs"; echo
|
| 776 |
57 |
julius |
$(Q)mkdir -p ../vlt
|
| 777 |
|
|
$(Q)cp /tmp/*.gc* $(SIM_VLT_DIR)
|
| 778 |
|
|
$(Q)cp /tmp/*.gc* $(BENCH_SYSC_SRC_DIR)
|
| 779 |
6 |
julius |
|
| 780 |
|
|
################################################################################
|
| 781 |
|
|
# Architectural simulator test loop
|
| 782 |
|
|
################################################################################
|
| 783 |
|
|
|
| 784 |
|
|
# Verilator defaults to internal memories
|
| 785 |
57 |
julius |
sim-tests: prepare-sw-uart-printf
|
| 786 |
6 |
julius |
@if [ ! -d $(SIM_RESULTS_DIR) ]; then mkdir -p $(SIM_RESULTS_DIR); fi
|
| 787 |
|
|
@echo
|
| 788 |
|
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
| 789 |
|
|
@echo
|
| 790 |
57 |
julius |
$(Q)for TEST in $(TESTS); do \
|
| 791 |
6 |
julius |
echo "################################################################################"; \
|
| 792 |
|
|
echo; \
|
| 793 |
|
|
echo "\t#### Current test: $$TEST ####"; echo; \
|
| 794 |
|
|
echo "\t#### Compiling software ####"; echo; \
|
| 795 |
|
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
| 796 |
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR $$TEST $(TEST_SW_MAKE_OPTS) UART_PRINTF=1; \
|
| 797 |
|
|
rm -f $(SIM_RUN_DIR)/$(SIM_SRAM_MEM_FILE); \
|
| 798 |
|
|
ln -s $$CURRENT_TEST_SW_DIR/$$TEST.or32 $(SIM_RUN_DIR)/.; \
|
| 799 |
|
|
echo;echo "\t#### Launching architectural simulator ####"; \
|
| 800 |
|
|
time -p $(ARCH_SIM_EXE) --nosrv -f $(SIM_BIN_DIR)/$(ARCH_SIM_CFG_FILE) $$TEST.or32 > $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log 2>&1; \
|
| 801 |
|
|
if [ $$? -gt 0 ]; then exit $$?; fi; \
|
| 802 |
|
|
if [ `tail -n 10 $(SIM_RESULTS_DIR)/$$TEST-or1ksim.log | grep -c $(SIM_SUCCESS_MESSAGE)` -gt 0 ]; then \
|
| 803 |
|
|
TEST_RESULT=1; \
|
| 804 |
|
|
fi; \
|
| 805 |
|
|
echo; echo "\t####"; \
|
| 806 |
|
|
if [ $$TEST_RESULT -gt 0 ]; then \
|
| 807 |
|
|
echo "\t#### Test $$TEST PASSED ####";TESTS_PASSED=`expr $$TESTS_PASSED + 1`;\
|
| 808 |
|
|
else echo "\t#### Test $$TEST FAILED ####";\
|
| 809 |
|
|
fi; \
|
| 810 |
|
|
echo "\t####"; echo; \
|
| 811 |
|
|
TESTS_PERFORMED=`expr $$TESTS_PERFORMED + 1`;\
|
| 812 |
|
|
unlink $(SIM_RUN_DIR)/$$TEST.or32; \
|
| 813 |
|
|
done; \
|
| 814 |
|
|
echo "Test results: "$$TESTS_PASSED" out of "$$TESTS_PERFORMED" tests passed"; echo
|
| 815 |
|
|
|
| 816 |
|
|
|
| 817 |
|
|
|
| 818 |
|
|
################################################################################
|
| 819 |
|
|
# Cleaning rules
|
| 820 |
|
|
################################################################################
|
| 821 |
|
|
|
| 822 |
49 |
julius |
clean: clean-sw clean-sim clean-sysc clean-rtl clean-vpi
|
| 823 |
6 |
julius |
|
| 824 |
|
|
clean-sw:
|
| 825 |
44 |
julius |
@for SWDIR in `ls $(SW_DIR)`; do \
|
| 826 |
|
|
echo $$SWDIR; \
|
| 827 |
|
|
$(MAKE) -C $(SW_DIR)/$$SWDIR clean; \
|
| 828 |
6 |
julius |
done
|
| 829 |
|
|
|
| 830 |
|
|
clean-sim:
|
| 831 |
49 |
julius |
#backup any profiling output files
|
| 832 |
51 |
julius |
@if [ -f $(SIM_VLT_DIR)/OrpsocMain.gcda ]; then echo;echo "\tBacking up verilator profiling output to /tmp"; echo; \
|
| 833 |
49 |
julius |
cp $(SIM_VLT_DIR)/*.gc* /tmp; \
|
| 834 |
|
|
cp $(BENCH_SYSC_SRC_DIR)/*.gc* /tmp; fi
|
| 835 |
55 |
julius |
rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.* $(SIM_VLT_DIR) $(MGC_ORPSOC_LIB_DIR) $(SIM_RUN_DIR)/work $(SIM_RUN_DIR)/transcript
|
| 836 |
36 |
julius |
|
| 837 |
|
|
clean-sysc:
|
| 838 |
|
|
# Clean away dependency files generated by verilator
|
| 839 |
42 |
julius |
$(MAKE) -C $(BENCH_SYSC_SRC_DIR) -f $(BENCH_SYSC_SRC_DIR)/Modules.make clean
|
| 840 |
36 |
julius |
|
| 841 |
|
|
clean-rtl:
|
| 842 |
|
|
# Clean away temporary verilog source files
|
| 843 |
44 |
julius |
rm -f $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl/wb_sdram_ctrl_fsm.v
|
| 844 |
|
|
|