From 6ae3f017901e0c83859f72a14626f4ba8fd442b5 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Tue, 15 Oct 2024 14:10:32 +0800 Subject: [PATCH 1/2] [chore] fix outdated document Signed-off-by: Avimitin --- Makefile | 10 +------ README.md | 81 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 6664c714c..fd67fb7b9 100644 --- a/Makefile +++ b/Makefile @@ -44,14 +44,6 @@ reformat: checkformat: mill -i __.checkFormat -.PHONY: list-testcases -list-testcases: - nix search '.#t1.blastoise.cases' cases --json | jq 'to_entries[].key|split(".")|.[-2:]|join(".")' -r - .PHONY: list-configs list-configs: - nix run '.#t1.configgen' -- listConfigs - -.PHONY: update-configs -update-configs: - nix run '.#t1.configgen' -- listConfigs + @nix eval ".#t1.allConfigs" --json | jq -r 'to_entries| map({key: .key, value: .value|keys|map(split(".")[4])}) | map( .key as $$key | reduce .value[] as $$item ([]; ["\($$key).\($$item)"]+. )) | flatten' diff --git a/README.md b/README.md index 92c13213d..c209405d5 100644 --- a/README.md +++ b/README.md @@ -115,16 +115,20 @@ You can build its components with the following commands: ```shell $ nix build .#t1.elaborator # the wrapped jar file of the Chisel elaborator -$ nix build .#t1..ip.rtl # the elaborated IP core .sv files -$ nix build .#t1..ip.emu-rtl # the elaborated IP core .sv files with emulation support -$ nix build .#t1..ip.verilator-emu # build the IP core emulator using verilator -$ nix build .#t1..ip.vcs-emu --impure # build the IP core emulator using VCS w/ VCS environment locally -$ nix build .#t1..ip.vcs-emu-trace --impure # build the IP core emulator using VCS w/ trace support - -$ nix build .#t1..subsystem.rtl # the elaborated soc .sv files -$ nix build .#t1..subsystem.emu-rtl # the elaborated soc .sv files with emulation support -$ nix build .#t1..subsystem.emu # build the soc emulator -$ nix build .#t1..subsystem.emu-trace # build the soc emulator with trace support +# Build T1 +$ nix build .#t1..t1.rtl # the elaborated IP core .sv files + +# Build T1 Emu +$ nix build .#t1..t1emu.rtl # the elaborated IP core .sv files +$ nix build .#t1..t1emu.verilator-emu # build the IP core emulator using verilator +$ nix build .#t1..t1emu.vcs-emu --impure # build the IP core emulator using VCS w/ VCS environment locally +$ nix build .#t1..t1emu.vcs-emu-trace --impure # build the IP core emulator using VCS w/ trace support + +# Build T1 Rocket emulator +$ nix build .#t1..t1rocketemu.rtl # the elaborated T1 with Rocket core .sv files +$ nix build .#t1..t1rocketemu.verilator-emu # build the t1rocket emulator using verilator +$ nix build .#t1..t1rocketemu.vcs-emu # build the t1rocket emulator using VCS +$ nix build .#t1..t1rocketemu.vcs-emu-trace # build the t1rocket emulator using VCS with trace support ``` where `` should be replaced with a configuration name, e.g. `blastoise`. The build output will be put in `./result` directory by default. @@ -137,41 +141,51 @@ Currently under tested configs: | **Machamp** | `DLEN512 VLEN1K ; NOFP; VRF p0r,p1w bank2; LSU bank8 beatbyte 16` | | **Sandslash** | `DLEN1K VLEN4K ; NOFP; VRF p0rw bank4; LSU bank16 beatbyte 16` | | **Alakazam** | `DLEN2K VLEN16K; NOFP; VRF p0rw bank8; LSU bank8 beatbyte 64` | +| **t1rocket** | `Configs that specific to t1rocket` | The `` could also be `t1rocket`, this is special configuration name that enable rocket-chip support for scalar instruction. +To see all possible combination of `` and ``, use: + +```bash +make list-configs +``` + #### Run Testcases To run testcase on IP emulator, use the following script: + ```shell -$ nix develop -c t1-helper run -c -e +$ nix develop -c t1-helper run -i -c -e ``` + wheres -- `` is the configuration name; +- `` is the configuration name +- `` is one of the `t1emu`, `t1rocketemu` - `` is one of the `verilator-emu`, `verilator-emu-trace`, `vcs-emu`, `vcs-emu-trace` -- `` is the name of a testcase, you can resolve runnable test cases by command: `t1-helper listCases -c `; +- `` is the name of a testcase, you can resolve runnable test cases by command: `t1-helper listCases -c ` For example: ```shell -$ nix develop -c t1-helper run -c blastoise -e vcs-emu intrinsic.linear_normalization +$ nix develop -c t1-helper run -i t1emu -c blastoise -e vcs-emu intrinsic.linear_normalization ``` To get waveform, use the trace emulator ```console -$ nix develop -c t1-helper run -c blastoise -e vcs-emu-trace intrinsic.linear_normalization +$ nix develop -c t1-helper run -i t1emu -c blastoise -e vcs-emu-trace intrinsic.linear_normalization ``` -The `` and `` option will be cached under `$XDG_CONFIG_HOME`, +The ``, `` and `` option will be cached under `$XDG_CONFIG_HOME`, so if you want to test multiple test case with the same emulator, -you don't need to add `-c` and `-e` option every time. +you don't need to add `-c`, `-i` and `-e` option every time. For example: ```console -$ nix develop -c t1-helper run -c blastoise -e vcs-emu-trace intrinsic.linear_normalization +$ nix develop -c t1-helper run -i t1emu -c blastoise -e vcs-emu-trace intrinsic.linear_normalization $ nix develop -c t1-helper run pytorch.llama ``` @@ -185,7 +199,7 @@ The `t1-helper run` subcommand only run the driver without validating internal s To run design verification, use the `t1-helper check` subcommand: ```console -$ nix develop -c t1-helper run -c blastoise -e vcs-emu mlir.hello +$ nix develop -c t1-helper run -i t1emu -c blastoise -e vcs-emu mlir.hello $ nix develop -c t1-helper check ``` @@ -195,15 +209,15 @@ so make sure you `run` a test before `check`. #### Export RTL Properties ```shell -$ nix run .#t1..ip.omreader # export the contents of the specified key -$ nix run .#t1..ip.emu-omreader # export the contents of the specified key with emulation support +$ nix run .#t1...omreader # export the contents of the specified key +$ nix run .#t1...emu-omreader # export the contents of the specified key with emulation support ``` To dump all available keys and preview their contents: ```shell -$ nix run .#t1..ip.omreader -- run --dump-methods -$ nix run .#t1..ip.emu-omreader -- run --dump-methods +$ nix run .#t1...omreader -- run --dump-methods +$ nix run .#t1...emu-omreader -- run --dump-methods ```
@@ -245,11 +259,12 @@ $ nix develop .#t1.elaborator.editable # or if you want submodules editable $ mill -i elaborator # build and run elaborator ``` -#### Developing DPI +#### Developing VCS DPI + ```shell -$ nix develop .#t1..ip.vcs-dpi-lib # replace with your configuration name -$ cd t1emu/csrc -$ cargo build --feature dpicommon/vcs +$ nix develop .#t1...vcs-dpi-lib # replace with your configuration name +$ cd difftest +$ cargo build --feature vcs ``` #### Developing Testcases @@ -266,12 +281,12 @@ The `tests/` directory contains all the testcases. To view what is available to run, use the `t1-helper listCases` sub command: ```console -$ t1-helper listCases -c +$ nix develop -c t1-helper listCases -c -i ``` For example, ```console -$ t1-helper listCases -c blastoise mlir +$ t1-helper listCases -c blastoise -i t1emu mlir [INFO] Fetching current test cases * mlir.axpy_masked @@ -284,7 +299,7 @@ $ t1-helper listCases -c blastoise mlir * mlir.stripmining * mlir.vectoradd -$ t1-helper listCases -c blastoise '.*vslid.*' +$ t1-helper listCases -c blastoise -i t1emu '.*vslid.*' [INFO] Fetching current test cases * codegen.vslide1down_vx @@ -298,18 +313,18 @@ $ t1-helper listCases -c blastoise '.*vslid.*' To develop a specific testcases, enter the development shell: ```shell -# nix develop .#t1..ip.cases.. +# nix develop .#t1...cases.. # # For example: -$ nix develop .#t1.blastoise.ip.cases.pytorch.llama +$ nix develop .#t1.blastoise.t1emu.cases.pytorch.llama ``` Build tests: ```shell # build a single test -$ nix build .#t1..cases.ip.intrinsic.matmul -L +$ nix build .#t1...cases.intrinsic.matmul -L $ ls -al ./result ``` From e6a356589949e011fb35e177b2e8f7cb5ad072de Mon Sep 17 00:00:00 2001 From: Avimitin Date: Tue, 15 Oct 2024 15:29:45 +0800 Subject: [PATCH 2/2] [makefile] fix recurse level of reformat Signed-off-by: Avimitin --- Makefile | 6 +----- nix/t1/mill-modules.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fd67fb7b9..0979a2603 100644 --- a/Makefile +++ b/Makefile @@ -38,11 +38,7 @@ clean: .PHONY: reformat reformat: - mill -i __.reformat - -.PHONY: checkformat -checkformat: - mill -i __.checkFormat + nix develop ".#t1.elaborator" -c bash -c 'eval "$$formatHook"' .PHONY: list-configs list-configs: diff --git a/nix/t1/mill-modules.nix b/nix/t1/mill-modules.nix index 85e81f885..26a720d83 100644 --- a/nix/t1/mill-modules.nix +++ b/nix/t1/mill-modules.nix @@ -80,6 +80,18 @@ let CIRCT_INSTALL_PATH = circt-full; JEXTRACT_INSTALL_PATH = jextract-21; JAVA_TOOL_OPTIONS = "--enable-preview"; + formatHook = '' + targets=( $(mill -i resolve _.reformat) ) + localTargets=() + for t in ''${targets[@]}; do + if ! mill -i show "''${t//reformat/sources}" | grep -q dependencies; then + localTargets+=($t) + fi + done + for t in ''${localTargets[@]}; do + mill -i "$t" + done + ''; }; outputs = [ "out" "omreader" "elaborator" "t1package" ];