Simple MIDAS Examples
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
barstools @ c884a2f
chisel @ 00796df
firrtl @ 672162b
midas @ 52d1c8d
platforms
plsi @ 4492f2a
project
riscv-mini @ 69a48ca
rocket-chip @ fef522a
scripts
src
.gitignore
.gitmodules
LICENSE
Makefile
Makefile.project
Makefrag
Makefrag-plsi
README.md
build.sbt
fpga.mk
hex
replay.mk
setup.sh
sourceme-hammer.sh
test.mk

README.md

MIDAS/Strober Examples

This repository demonstrates an example use of MIDAS/Strober for simple RTL designs including:

  • Chisel tutorial
    • GCD, Parity, ShiftRegister, EnableShiftRegister, ResetShiftRegister, Stack, Risc
  • More simple examples:
    • RiscSRAM: Implementation of Risc with SeqMem
    • PointerChaser: Simple pointer chaser following a random list.
  • riscv-mini
    • Tile: the top module of riscv-mini
    • ISA: RISCV RV32I
    • 3 stage pipeline with caches
    • Passes all rv32ui tests except FENCE.I
    • Passes all rv32mi tests except timer
    • Runs RISC-V benchmarks: median, multiply, qsort, towers, vvadd

STEP 0: Get Started

To initiate the project, run the following commands:

$ git clone https://github.com/ucb-bar/midas-examples.git
$ cd midas-examples
# initialize the submodules
$ ./setup.sh
# publish chisel & firrtl to local maven
$ make publishLocal

With the following make commands, you can enable RTL state snapshotting with STROBER=1. Also, MACRO_LIB=1 is required for power modeling to transform technology-independent macro blocks to technology-dependent macro blocks.

Use HAMMER for the Strober Power Modeling

For power modeling, we need to use commercial CAD tools and we expect you have these tools installed in your machine. Instead of manually-written TCL scripts, the ASIC backend flow is driven by automatically-generated TCL scripts by HAMMER. To use HAMMER, we need to set proper environment variables.

First, edit sourceme-hammer.sh for your tool environment. Before executing make commands in the following steps, run:

$ source sourceme-hammer.sh

If you want to use the Strober power modeling but do not correctly set the variables in sourceme-hammer.sh, you will see error messages, and therefore, make sure all the variables are correct in your environment. When you run HAMMER at the first time, it will install prerequisite tools, which may take hours.

STEP 1: Run Verilator/VCS Tests

First of all, you need to write simulation drivers. Examples are given in src/main/cc. To increase code reuse for tests and FPGA simulation, write a header file with virtual base class simif_t(src/main/cc/<design>.h). Also, add your design in Makefile in the main directory. For Verilator/VCS tests, just write a wrapper and the main function with simif_emul_t(src/main/cc/<design>-emul.cc).

For Verilator tests, run:

 $ make <design>-verilator-test [STROBER=1] [MACRO_LIB=1] [LOADMEM=<hexfile>] [ARGS="<simulation specific arguments>"]

Chisel generated files and test binaries are in generated-src, while log files, waveform files, sample snapshot files are in output. VCD files are not dumped by default, but you can get VCD files with <design>-verilator-tests-debug as the make target.

For VCS tests, run:

 $ make <design>-vcs-test [STROBER=1] [MACRO_LIB=1] [LOADMEM=<hexfile>] [ARGS="<testbench specific arguments>"]

You can get VPD files with <design>-vcs-tests-debug as the make target.

We can also take advantage of sbt for tests. Test wrappers are written in src/test/scala. For individual tests, run sbt testOnly <test name>. For integration tests, run sbt test.

STEP 2: Run FPGA Simulation

First, write a wrapper and the main function with simif_zynq_t(src/main/cc/<design>-zynq.cc) by reusing the header file in Verilator/VCS tests.

To generate boot.bin for FPGA Simulation, run:

$ make <design>-fpga [STROBER=1] [BOARD=<zybo|zedboard|zc706>]

The default FPGA board is zedboard, but you can also select zybo or zc706.

To synthesize the design for FPGA, run:

$ make <design>-fpga

Finally, to compile the compile FPGA simulation driver, run:

$ make <design>-zynq

Copy /output/zynq/<design>/boot.bin to the SD card to program FPGA. Also, you should copy the following files in output/zynq/<design> to the board (refer to ucb-bar/fpga-zynq):

* <design>-zynq: driver executable
* <design>.chain: scan chain information (only for Strober)

To execute simulation in the FPGA board, run:

$ ./<design>-zynq [+loadmem=<hexfile>] [+sample=<sample file>]

STEP 3: Replay RTL Sample Snapshots (Optional for Strober)

If you enable state snapshotting in STEP 1 or STEP 2, you will get random RTL state snapshots at the end of simulation (<design>.sample by default). To replay RTL sample snapshots, run:

$ make <design>-replay-rtl SAMPLE=<sample file> [MACRO_LIB=1]

MACRO_LIB=1 is not necessary if it's not enabled in the previous steps.

For power modeling, MACRO_LIB=1 is required in this step as well as the previous steps. The following commands interact with HAMMER to run proper CAD tools. For power estimation with RTL simulation, run:

$ make <design>-replay-rtl-pwr SAMPLE=<sample file> MACRO_LIB=1

For power estimation with post-synthesis simulation, run:

$ make <design>-replay-syn SAMPLE=<sample file> MACRO_LIB=1