Skip to content

Commit

Permalink
implement fast loadmem feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zhemao committed Aug 1, 2020
1 parent d5a2d43 commit d7f3f91
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
23 changes: 23 additions & 0 deletions docs/Simulation/Software-RTL-Simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ For instance, to run one of the riscv-tools assembly tests.
.. Note:: In a VCS simulator, the simulator name will be ``simv-chipyard-RocketConfig`` instead of ``simulator-chipyard-RocketConfig``.

The makefiles have a ``run-binary`` rule that simplifies running the simulation executable. It adds many of the common command line options for you and redirects the output to a file.

.. code-block:: shell
make run-binary BINARY=$RISCV/riscv64-unknown-elf/share/riscv-tests/isa/rv64ui-p-simple
Alternatively, we can run a pre-packaged suite of RISC-V assembly or benchmark tests, by adding the make target ``run-asm-tests`` or ``run-bmark-tests``.
For example:

Expand Down Expand Up @@ -126,6 +132,23 @@ All ``make`` targets that can be applied to the default example, can also be app
Finally, in the ``generated-src/<...>-<package>-<config>/`` directory resides all of the collateral and Verilog source files for the build/simulation.
Specifically, the SoC top-level (``TOP``) Verilog file is denoted with ``*.top.v`` while the ``TestHarness`` file is denoted with ``*.harness.v``.

Fast Memory Loading
-------------------

The simulator loads the program binary over a simulated serial line. This can be quite slow if there is a lot of static data, so the simulator also allows data to be loaded from a file directly into the DRAM model.

.. code-block:: shell
make run-binary BINARY=test.riscv LOADMEM=testdata.hex LOADMEM_ADDR=81000000
The ``.hex`` file should be a text file with a hexadecimal number on each line.

.. code-block:: text
deadbeef
0123
Each line uses little-endian order, so this file would produce the bytes "ef be ad de 01 23". ``LOADMEM_ADDR`` specifies which address in memory (in hexadecimal) to write the first byte to. The default is 0x81000000.

Generating Waveforms
-----------------------
Expand Down
2 changes: 1 addition & 1 deletion sims/firesim
Submodule firesim updated 41 files
+21 −0 .mergify.yml
+1 −0 README.md
+25 −13 deploy/buildtools/buildafi.py
+6 −6 deploy/sample-backup-configs/sample_config_hwdb.ini
+1 −1 platforms/f1/aws-fpga
+5 −2 sim/Makefile
+11 −13 sim/firesim-lib/src/main/cc/bridges/tracerv.cc
+4 −1 sim/firesim-lib/src/main/scala/bridges/TracerVBridge.scala
+1 −1 sim/firesim-lib/src/main/scala/bridges/UARTBridge.scala
+12 −3 sim/firesim-lib/src/main/scala/passes/ILATopWiring.scala
+5 −2 sim/midas/src/main/cc/emul/mmio.cc
+2 −1 sim/midas/src/main/cc/emul/mmio.h
+49 −9 sim/midas/src/main/cc/simif.h
+3 −4 sim/midas/src/main/cc/simif_emul.cc
+14 −9 sim/midas/src/main/scala/midas/passes/AssertPass.scala
+1 −0 sim/midas/src/main/scala/midas/passes/MidasTransforms.scala
+9 −3 sim/midas/src/main/scala/midas/passes/fame/EmitAndWrapRAMModels.scala
+9 −2 sim/midas/src/main/scala/midas/widgets/AXI4AddressTranslation.scala
+13 −8 sim/midas/src/main/scala/midas/widgets/Assert.scala
+6 −0 sim/midas/src/main/scala/midas/widgets/PeekPokeIO.scala
+5 −1 sim/midas/src/main/verilog/vcs_top.v
+25 −0 sim/midas/src/test/scala/midas/FooTransform.scala
+1 −1 sim/src/main/cc/fasedtests/test_harness_bridge.cc
+0 −7 sim/src/main/cc/firesim/firesim_top.cc
+82 −0 sim/src/main/cc/midasexamples/AssertTorture.h
+10 −0 sim/src/main/cc/midasexamples/Driver.cc
+43 −0 sim/src/main/cc/midasexamples/MultiReg.h
+101 −0 sim/src/main/cc/midasexamples/MultiRegfile.h
+38 −0 sim/src/main/cc/midasexamples/NestedModels.h
+72 −0 sim/src/main/cc/midasexamples/Regfile.h
+1 −1 sim/src/main/makefrag/fasedtests/Makefrag
+1 −1 sim/src/main/makefrag/firesim/Makefrag
+1 −1 sim/src/main/makefrag/midasexamples/Makefrag
+105 −0 sim/src/main/scala/midasexamples/AssertTorture.scala
+37 −0 sim/src/main/scala/midasexamples/MultiReg.scala
+39 −0 sim/src/main/scala/midasexamples/MultiRegfile.scala
+51 −0 sim/src/main/scala/midasexamples/NestedModels.scala
+41 −0 sim/src/main/scala/midasexamples/Regfile.scala
+58 −22 sim/src/test/scala/midasexamples/TutorialSuite.scala
+4 −3 sim/target-agnostic.mk
+1 −1 target-design/chipyard
5 changes: 5 additions & 0 deletions variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ output_dir=$(sim_dir)/output/$(long_name)
PERMISSIVE_ON=+permissive
PERMISSIVE_OFF=+permissive-off
BINARY ?=
LOADMEM ?=
LOADMEM_ADDR ?= 81000000
override SIM_FLAGS += +dramsim +dramsim_ini_dir=$(TESTCHIP_DIR)/src/main/resources/dramsim2_ini +max-cycles=$(timeout_cycles)
ifneq ($(LOADMEM),)
override SIM_FLAGS += +loadmem=$(LOADMEM) +loadmem_addr=$(LOADMEM_ADDR)
endif
VERBOSE_FLAGS ?= +verbose
sim_out_name = $(output_dir)/$(subst $() $(),_,$(notdir $(basename $(BINARY))))

Expand Down

0 comments on commit d7f3f91

Please sign in to comment.