Line 199... |
Line 199... |
|
|
#
|
#
|
# SystemC cycle-accurate model compilation
|
# SystemC cycle-accurate model compilation
|
#
|
#
|
# A new addition to ORPSoC v2 is the cycle-accurate model. The primary enabler
|
# A new addition to ORPSoC v2 is the cycle-accurate model. The primary enabler
|
# behind this is verilator, which processes the RTL sources and generates a c++
|
# behind this is verilator, which processes the RTL source and generates a c++
|
# description of the system. This c++ description is then compiled with a
|
# description of the system. This c++ description is then compiled, with a
|
# SystemC wrapper. Finally a top-level SystemC testbench instantiates the
|
# SystemC wrapper. Finally a top-level SystemC testbench instantiates the
|
# model, as well as any other modules - in this case a reset generation, UART
|
# model, and other useful modules - in this case a reset generation, UART
|
# decoder, and monitor module are included at the top level. These additional
|
# decoder, and monitor module are included at the top level. These additional
|
# modules and models are written in SystemC and compiled all together with the
|
# modules and models are written in SystemC. Finally, everything is linked with
|
# cycle-accurate ORPSoC model to create the simulation executable. Finally this
|
# the cycle-accurate ORPSoC model to create the simulation executable. This
|
# executable is run and should be a cycle-representation of the system. VCDs
|
# executable is the cycle-representation of the system.
|
# can be generated if enabled. The compiled mentioned above is all done with
|
#
|
# the GNU c++ compiler, g++.
|
# VCDs can be generated if the model is made with VCD=1 specified on the
|
# The compilation process is a little more tricky than a typical even-driven
|
# command line. Specify a dump file with the "-vcd" option at runtime, eg:
|
|
# "./Vorpsoc_top -vcd dump.vcd"
|
|
# Note that this slows down the simulation.
|
|
#
|
|
# Logging of the processor's execution can be done by specifying a log file
|
|
# on the command line at runtime, eg: "./Vorpsoc_top -log or1200_exec.log"
|
|
# Note that this slows down the simulation.
|
|
#
|
|
# There are performance metrics printed at the conclusion of simulations. To
|
|
# disable these launch the executable with either the -q or --no-perf-summary
|
|
# options. eg: "./Vorpsoc_top -q"
|
|
#
|
|
# The compilation is all done with the GNU c++ compiler, g++.
|
|
#
|
|
# The compilation process is a little more complicated than the event-driven
|
# simulator. It proceeds basically by generating the makefiles for compiling
|
# simulator. It proceeds basically by generating the makefiles for compiling
|
# the design with verilator, running these makes which produces a library
|
# the design with verilator, running these makes which produces a library
|
# containing the cycle-accurate ORPSoC design, compiling the additional
|
# containing the cycle-accurate ORPSoC design, compiling the additional
|
# top-level, and testbench, systemC models into a library, and then linking it
|
# top-level, and testbench, systemC models into a library, and then linking it
|
# all together into the simulation executable.
|
# all together into the simulation executable.
|
|
#
|
# The major advantage of the cycle-accurate model is that it is quicker, in
|
# The major advantage of the cycle-accurate model is that it is quicker, in
|
# terms of simulated cycles/second, when compared with event-driven simulators.
|
# terms of simulated cycles/second, when compared with event-driven simulators.
|
# It is, of course, less accurate in that it cannot model propegation delays.
|
# It is, of course, less accurate in that it cannot model propegation delays.
|
# However this is usually not an issue for simulating a design which is known
|
# However this is usually not an issue for simulating a design which is known
|
# to synthesize and run OK. It is very useful for running complex software,
|
# to synthesize and run OK. It is very useful for running complex software,
|
# such as the linux kernel and real-time OS applications, which generally
|
# such as the linux kernel and real-time OS applications, which generally
|
# require long simulation times.
|
# result in long simulation times.
|
|
#
|
# Currently the cycle-accurate model being used doesn't contain much more than
|
# Currently the cycle-accurate model being used doesn't contain much more than
|
# the processor and a UART, however it's exepected in future this will be
|
# the processor and a UART, however it's exepected in future this will be
|
# expanded on and more complex software test suites will be implemented to put
|
# expanded on and more complex software test suites will be implemented to put
|
# the system through its paces.
|
# the system through its paces.
|
#
|
#
|
|
#
|
|
|
|
# Name of the directory we're currently in
|
# Name of
|
|
# the directory we're currently in
|
|
CUR_DIR=$(shell pwd)
|
CUR_DIR=$(shell pwd)
|
|
|
# The root path of the whole project
|
# The root path of the whole project
|
PROJECT_ROOT=$(CUR_DIR)/../..
|
PROJECT_ROOT=$(CUR_DIR)/../..
|
|
|
Line 273... |
Line 288... |
EVENT_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
|
EVENT_SIM_FLAGS += "-D USE_SDRAM=$(USE_SDRAM)"
|
endif
|
endif
|
|
|
# Enable ethernet if defined on the command line
|
# Enable ethernet if defined on the command line
|
ifdef USE_ETHERNET
|
ifdef USE_ETHERNET
|
EVENT_SIM_FLAGS += "-D USE_ETHERNET=$(USE_ETHERNET)"
|
EVENT_SIM_FLAGS += "-D USE_ETHERNET=$(USE_ETHERNET) -D USE_ETHERNET_IO=$(USE_ETHERNET)"
|
|
# Extra tests we do if ethernet is enabled
|
|
TESTS += eth-basic
|
endif
|
endif
|
|
|
SIM_FLASH_MEM_FILE="flash.in"
|
SIM_FLASH_MEM_FILE="flash.in"
|
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
|
FLASH_MEM_FILE_SUFFIX="-twobyte-sizefirst.hex"
|
SIM_SRAM_MEM_FILE="sram.vmem"
|
SIM_SRAM_MEM_FILE="sram.vmem"
|
Line 294... |
Line 311... |
@cd $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl && perl fizzim.pl -encoding onehot -terse < wb_sdram_ctrl_fsm.fzm > wb_sdram_ctrl_fsm.v
|
@cd $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl && perl fizzim.pl -encoding onehot -terse < wb_sdram_ctrl_fsm.fzm > wb_sdram_ctrl_fsm.v
|
@cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
|
@cd $(RTL_VERILOG_DIR) && sed '/defparam/!s/\([a-zA-Z0-9_]\)\.//g' intercon.vm > intercon.v
|
|
|
|
|
ifdef UART_PRINTF
|
ifdef UART_PRINTF
|
TEST_SW_MAKE_OPTS=UART_PRINTF=1
|
TEST_SW_MAKE_OPTS="UART_PRINTF=1"
|
endif
|
endif
|
|
|
.PHONY: prepare_sw
|
.PHONY: prepare_sw
|
prepare_sw:
|
prepare_sw:
|
@$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
|
@$(MAKE) -C $(SW_DIR)/support all $(TEST_SW_MAKE_OPTS)
|
Line 355... |
Line 372... |
# software and linking of the resulting hex file to the run path, etc.
|
# software and linking of the resulting hex file to the run path, etc.
|
# Main RAM setup - (RTL simulation with Icarus/NCSim only!):
|
# Main RAM setup - (RTL simulation with Icarus/NCSim only!):
|
# Define USE_SDRAM to enable the external SDRAM, otherwise the simulation
|
# Define USE_SDRAM to enable the external SDRAM, otherwise the simulation
|
# defaults to an internal SRAM. Eg. $ make rtl-tests USE_SDRAM=1 VCD=1
|
# defaults to an internal SRAM. Eg. $ make rtl-tests USE_SDRAM=1 VCD=1
|
# Verilator defaults to internal memories
|
# Verilator defaults to internal memories
|
rtl-tests: prepare_sw_uart_printf prepare_rtl prepare_dirs
|
rtl-tests: prepare_sw prepare_rtl prepare_dirs
|
@echo
|
@echo
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
@echo "Beginning loop that will complete the following tests: $(TESTS)"
|
@echo
|
@echo
|
@for TEST in $(TESTS); do \
|
@for TEST in $(TESTS); do \
|
echo "################################################################################"; \
|
echo "################################################################################"; \
|
Line 384... |
Line 401... |
if [ ! -z $$UART_PRINTF ]; \
|
if [ ! -z $$UART_PRINTF ]; \
|
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
fi; \
|
fi; \
|
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
|
if echo $$TEST | grep -q -i ^eth; then \
|
|
echo "\`define ENABLE_ETH_STIM" >> $(SIM_RUN_DIR)/test_define.v; \
|
|
echo "\`define ETH_PHY_VERBOSE" >> $(SIM_RUN_DIR)/test_define.v; \
|
|
fi; \
|
if [ -z $$NO_SIM_LOGGING ]; then \
|
if [ -z $$NO_SIM_LOGGING ]; then \
|
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define OR1200_DISPLAY_ARCH_STATE" >> $(SIM_RUN_DIR)/test_define.v; \
|
fi; \
|
fi; \
|
echo ; \
|
echo ; \
|
echo "\t#### Compiling RTL ####"; \
|
echo "\t#### Compiling RTL ####"; \
|
Line 440... |
Line 461... |
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
then echo "+define+UART_PRINTF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
fi; \
|
fi; \
|
if [ ! -z $$USE_SDRAM ]; then \
|
if [ ! -z $$USE_SDRAM ]; then \
|
echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define USE_SDRAM" >> $(SIM_RUN_DIR)/test_define.v; \
|
fi; \
|
fi; \
|
|
if echo $$TEST | grep -q -i ^eth; then \
|
|
echo "\`define ENABLE_ETH_STIM" >> $(SIM_RUN_DIR)/test_define.v; \
|
|
echo "\`define ETH_PHY_VERBOSE" >> $(SIM_RUN_DIR)/test_define.v; \
|
|
fi; \
|
echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
echo "+nocopyright" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
echo "+nowarn+MACRDF" >> $(SIM_RUN_DIR)/$(ICARUS_COMMAND_FILE).generated; \
|
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_NAME_STRING \"$$TEST\"" > $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
echo "\`define TEST_RESULTS_DIR \"$(SIM_RESULTS_DIR)/\" " >> $(SIM_RUN_DIR)/test_define.v; \
|
if [ -z $$NO_SIM_LOGGING ]; then \
|
if [ -z $$NO_SIM_LOGGING ]; then \
|
Line 698... |
Line 723... |
################################################################################
|
################################################################################
|
|
|
clean: clean-sw clean-sim clean-sysc clean-rtl clean_vpi
|
clean: clean-sw clean-sim clean-sysc clean-rtl clean_vpi
|
|
|
clean-sw:
|
clean-sw:
|
@for TEST in $(TESTS); do \
|
@for SWDIR in `ls $(SW_DIR)`; do \
|
echo "Current test: $$TEST"; \
|
echo $$SWDIR; \
|
CURRENT_TEST_SW_DIR=$(SW_DIR)/`echo $$TEST | cut -d "-" -f 1`; \
|
$(MAKE) -C $(SW_DIR)/$$SWDIR clean; \
|
echo "Current test sw directory: " $$CURRENT_TEST_SW_DIR; \
|
|
$(MAKE) -C $$CURRENT_TEST_SW_DIR clean; \
|
|
done
|
done
|
$(MAKE) -C $(SW_DIR)/support clean
|
|
$(MAKE) -C $(SW_DIR)/utils clean
|
|
|
|
clean-sim:
|
clean-sim:
|
rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.* $(SIM_VLT_DIR)
|
rm -rf $(SIM_RESULTS_DIR) $(SIM_RUN_DIR)/*.* $(SIM_VLT_DIR)
|
|
|
clean-sysc:
|
clean-sysc:
|
Line 718... |
Line 739... |
|
|
clean-rtl:
|
clean-rtl:
|
# Clean away temporary verilog source files
|
# Clean away temporary verilog source files
|
rm -f $(RTL_VERILOG_DIR)/intercon.v
|
rm -f $(RTL_VERILOG_DIR)/intercon.v
|
rm -f $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl/wb_sdram_ctrl_fsm.v
|
rm -f $(RTL_VERILOG_DIR)/components/wb_sdram_ctrl/wb_sdram_ctrl_fsm.v
|
No newline at end of file
|
No newline at end of file
|
|
|