lowRISC / ibex

Ibex is a small 32 bit RISC-V CPU core, previously known as zero-riscy.
https://www.lowrisc.org
Apache License 2.0
1.29k stars 495 forks source link

Proof-of-concept Nix environments for Ibex development #2156

Open hcallahan-lowrisc opened 3 months ago

hcallahan-lowrisc commented 3 months ago

This PR is just a PoC, and will likely never be merged. It contains some unrelated changes that I didn't bother completely tidying up, and some short-term fixes to make things work. Hopefully it is obvious which parts are unrelated.

Add a Nix flake to provide development environments for Ibex simulation and synthesis. The goal of this is to try and utilize the principled properties of Nix (the tool, the language, etc) to easily bootstrap reproducible development environments. This should work on any x86_64-linux system where nix is installable (macOS support is also possible), as there is no dependency on system libraries at all.

Precursors

  1. Install Nix (I suggest to use this guide: https://zero-to-nix.com/start/install). If you use another installer, you will need to ensure the flakes and nix-command experimental features are enabled.
  2. Clone/checkout this branch
    git clone git@github.com:hcallahan-lowrisc/ibex.git --branch nix_env_init_poc
    cd ibex/

N.B. The first time running nix develop may take a little while to fetch and build dependencies. This is normal (no system library deps etc.), and the second time everything will be cached.

Demo 1 (verilator sims)

  1. Enter a development shell
    nix develop # This drops you into a subshell with all the deps on your path
    # When you are done with the devshell...
    exit
  2. Run some verilator sims (My makefile changes are incomplete, so ensure you clean with make reset when switching between sims)
    # Run the simple_system under verilator
    make run-simple-system-hello
    # Run coremark under verilator
    make run-coremark
    # Run a pmp smoketest
    make run-pmp-smoke-test

    Demo 2 (synthesis)

  3. Enter a different development shell, which contains the synthesis deps
    nix develop .#syn_shell
  4. Run a yosys synthesis using the Nangate45 open cell library
    make run_syn_yosys_nangate45

Demo 3 (HDL simulations including bootstrapping internal lowrisc tools)

N.B. this will only evaluate for lowrisc internal environments with appropriate credentials. See the commit message (https://github.com/lowRISC/ibex/pull/2156/commits/350969abe123cd2d5a70816dd8132e2d0b12e1a8) for more details

  1. Enter a development shell
    nix develop .#eda_shell_lowrisc
  2. Run a simulation using the core_ibex UVM environment
    make -C dv/uvm/core_ibex SIMULATOR=xlm ITERATIONS=4 TEST=riscv_rand_instr_test
hcallahan-lowrisc commented 3 months ago

@GregAC @rswarbrick you may find this interesting to play around with @nbdd0121 @HU90m if you have any ideas about where we could go next!