From c0f5c77520ad5ec27d338e41ea9138e062801c0a Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Fri, 24 Dec 2021 05:07:17 -0800 Subject: [PATCH 01/23] Added FFT Generator integration --- .gitmodules | 3 +++ build.sbt | 7 ++++++- generators/FFTGenerator | 1 + generators/chipyard/src/main/scala/DigitalTop.scala | 1 + .../chipyard/src/main/scala/config/RocketConfigs.scala | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 160000 generators/FFTGenerator diff --git a/.gitmodules b/.gitmodules index 6128783a..be860d41 100644 --- a/.gitmodules +++ b/.gitmodules @@ -131,3 +131,6 @@ [submodule "generators/ibex"] path = generators/ibex url = https://github.com/ucb-bar/ibex-wrapper +[submodule "generators/FFTGenerator"] + path = generators/FFTGenerator + url = git@github.com:AnimeshAgrawal/FFTGenerator.git diff --git a/build.sbt b/build.sbt index afb82b5d..6c58256a 100644 --- a/build.sbt +++ b/build.sbt @@ -164,7 +164,12 @@ lazy val chipyard = (project in file("generators/chipyard")) .dependsOn(testchipip, rocketchip, boom, hwacha, sifive_blocks, sifive_cache, iocell, sha3, // On separate line to allow for cleaner tutorial-setup patches dsptools, `rocket-dsp-utils`, - gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex) + gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, FFTGenerator) + .settings(libraryDependencies ++= rocketLibDeps.value) + .settings(commonSettings) + +lazy val FFTGenerator = (project in file("generators/FFTGenerator")) + .dependsOn(rocketchip, `rocket-dsp-utils`) .settings(libraryDependencies ++= rocketLibDeps.value) .settings(commonSettings) diff --git a/generators/FFTGenerator b/generators/FFTGenerator new file mode 160000 index 00000000..55b7f2e6 --- /dev/null +++ b/generators/FFTGenerator @@ -0,0 +1 @@ +Subproject commit 55b7f2e6a1246d54340f406efe128ac11f85a92c diff --git a/generators/chipyard/src/main/scala/DigitalTop.scala b/generators/chipyard/src/main/scala/DigitalTop.scala index ba094163..271f9478 100644 --- a/generators/chipyard/src/main/scala/DigitalTop.scala +++ b/generators/chipyard/src/main/scala/DigitalTop.scala @@ -32,6 +32,7 @@ class DigitalTop(implicit p: Parameters) extends ChipyardSystem with chipyard.example.CanHavePeripheryStreamingPassthrough // Enables optionally adding the DSPTools streaming-passthrough example widget with nvidia.blocks.dla.CanHavePeripheryNVDLA // Enables optionally having an NVDLA with chipyard.clocking.HasChipyardPRCI // Use Chipyard reset/clock distribution + with FFTGenerator.HasPeripheryFFT { override lazy val module = new DigitalTopModule(this) } diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index 43bb2fb2..f602f9e2 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -21,6 +21,12 @@ class TinyRocketConfig extends Config( new freechips.rocketchip.subsystem.With1TinyCore ++ // single tiny rocket-core new chipyard.config.AbstractConfig) +class RocketWithFFT extends Config( + new FFTGenerator.WithFFTNumPoints(8) ++ + new FFTGenerator.WithFFTBaseAddr(0x2000) ++ + new FFTGenerator.WithFFTGenerator ++ + new RocketConfig) + class HwachaRocketConfig extends Config( new chipyard.config.WithHwachaTest ++ new hwacha.DefaultHwachaConfig ++ // use Hwacha vector accelerator From beaf37f30e20d70c0bfc444fe35b28fdb9b374aa Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Sun, 26 Dec 2021 18:14:40 +0530 Subject: [PATCH 02/23] Use https for submodule path instead of ssh --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index be860d41..e8176fea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -133,4 +133,4 @@ url = https://github.com/ucb-bar/ibex-wrapper [submodule "generators/FFTGenerator"] path = generators/FFTGenerator - url = git@github.com:AnimeshAgrawal/FFTGenerator.git + url = https://github.com/AnimeshAgrawal/FFTGenerator.git From 1b18b0b9c8268d99a26dd9fae4e90c8a9489c1e6 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 3 Jan 2022 01:15:52 -0800 Subject: [PATCH 03/23] Rename fft generator submodule for consistency --- .gitmodules | 6 +++--- generators/FFTGenerator | 1 - generators/fft-generator | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 160000 generators/FFTGenerator create mode 160000 generators/fft-generator diff --git a/.gitmodules b/.gitmodules index e8176fea..6f45793b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -131,6 +131,6 @@ [submodule "generators/ibex"] path = generators/ibex url = https://github.com/ucb-bar/ibex-wrapper -[submodule "generators/FFTGenerator"] - path = generators/FFTGenerator - url = https://github.com/AnimeshAgrawal/FFTGenerator.git +[submodule "generators/fft-generator"] + path = generators/fft-generator + url = https://github.com/ucb-bar/FFTGenerator.git diff --git a/generators/FFTGenerator b/generators/FFTGenerator deleted file mode 160000 index 55b7f2e6..00000000 --- a/generators/FFTGenerator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 55b7f2e6a1246d54340f406efe128ac11f85a92c diff --git a/generators/fft-generator b/generators/fft-generator new file mode 160000 index 00000000..f190edd3 --- /dev/null +++ b/generators/fft-generator @@ -0,0 +1 @@ +Subproject commit f190edd31c94033794f60a30a6377c976b340636 From fab88150f358554062339e49f0f478a93f108205 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 3 Jan 2022 01:43:51 -0800 Subject: [PATCH 04/23] follow naming convention in build.sbt --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 6c58256a..2808adb1 100644 --- a/build.sbt +++ b/build.sbt @@ -164,11 +164,11 @@ lazy val chipyard = (project in file("generators/chipyard")) .dependsOn(testchipip, rocketchip, boom, hwacha, sifive_blocks, sifive_cache, iocell, sha3, // On separate line to allow for cleaner tutorial-setup patches dsptools, `rocket-dsp-utils`, - gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, FFTGenerator) + gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator) .settings(libraryDependencies ++= rocketLibDeps.value) .settings(commonSettings) -lazy val FFTGenerator = (project in file("generators/FFTGenerator")) +lazy val fft_generator = (project in file("generators/fft-generator")) .dependsOn(rocketchip, `rocket-dsp-utils`) .settings(libraryDependencies ++= rocketLibDeps.value) .settings(commonSettings) From b9820a521c915dd1293aceb67ac7d18b219fbf87 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Tue, 4 Jan 2022 00:09:47 -0800 Subject: [PATCH 05/23] Rename FFTGenerator package to fftgenerator --- generators/chipyard/src/main/scala/DigitalTop.scala | 2 +- .../chipyard/src/main/scala/config/RocketConfigs.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generators/chipyard/src/main/scala/DigitalTop.scala b/generators/chipyard/src/main/scala/DigitalTop.scala index 271f9478..b8390920 100644 --- a/generators/chipyard/src/main/scala/DigitalTop.scala +++ b/generators/chipyard/src/main/scala/DigitalTop.scala @@ -32,7 +32,7 @@ class DigitalTop(implicit p: Parameters) extends ChipyardSystem with chipyard.example.CanHavePeripheryStreamingPassthrough // Enables optionally adding the DSPTools streaming-passthrough example widget with nvidia.blocks.dla.CanHavePeripheryNVDLA // Enables optionally having an NVDLA with chipyard.clocking.HasChipyardPRCI // Use Chipyard reset/clock distribution - with FFTGenerator.HasPeripheryFFT + with fftgenerator.CanHavePeripheryFFT { override lazy val module = new DigitalTopModule(this) } diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index f602f9e2..88b961a1 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -22,9 +22,9 @@ class TinyRocketConfig extends Config( new chipyard.config.AbstractConfig) class RocketWithFFT extends Config( - new FFTGenerator.WithFFTNumPoints(8) ++ - new FFTGenerator.WithFFTBaseAddr(0x2000) ++ - new FFTGenerator.WithFFTGenerator ++ + new fftgenerator.WithFFTNumPoints(8) ++ + new fftgenerator.WithFFTBaseAddr(0x2000) ++ + new fftgenerator.WithFFTGenerator ++ new RocketConfig) class HwachaRocketConfig extends Config( From 2de84962fa1e302e1f97200bd6a485c4348c8cb3 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Tue, 4 Jan 2022 00:11:12 -0800 Subject: [PATCH 06/23] Modify RocketWithFFTConfig to follow naming convention and branch off AbstractConfig --- .../chipyard/src/main/scala/config/RocketConfigs.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index 88b961a1..3a6de2b8 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -21,11 +21,12 @@ class TinyRocketConfig extends Config( new freechips.rocketchip.subsystem.With1TinyCore ++ // single tiny rocket-core new chipyard.config.AbstractConfig) -class RocketWithFFT extends Config( +class FFTRocketConfig extends Config( new fftgenerator.WithFFTNumPoints(8) ++ new fftgenerator.WithFFTBaseAddr(0x2000) ++ new fftgenerator.WithFFTGenerator ++ - new RocketConfig) + new freechips.rocketchip.subsystem.WithNBigCores(1) ++ + new chipyard.config.AbstractConfig) class HwachaRocketConfig extends Config( new chipyard.config.WithHwachaTest ++ From e66ebe999695ce5fb8041fde202bc9cdaa68ad76 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 10 Jan 2022 21:57:10 +0400 Subject: [PATCH 07/23] Add comment explaining CanHavePeripheryFFT Co-authored-by: Abraham Gonzalez --- generators/chipyard/src/main/scala/DigitalTop.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/chipyard/src/main/scala/DigitalTop.scala b/generators/chipyard/src/main/scala/DigitalTop.scala index b8390920..0d751969 100644 --- a/generators/chipyard/src/main/scala/DigitalTop.scala +++ b/generators/chipyard/src/main/scala/DigitalTop.scala @@ -32,7 +32,7 @@ class DigitalTop(implicit p: Parameters) extends ChipyardSystem with chipyard.example.CanHavePeripheryStreamingPassthrough // Enables optionally adding the DSPTools streaming-passthrough example widget with nvidia.blocks.dla.CanHavePeripheryNVDLA // Enables optionally having an NVDLA with chipyard.clocking.HasChipyardPRCI // Use Chipyard reset/clock distribution - with fftgenerator.CanHavePeripheryFFT + with fftgenerator.CanHavePeripheryFFT // Enables optionally having an MMIO-based FFT block { override lazy val module = new DigitalTopModule(this) } From a4f21c3fba804836519243ce7000c4235ff5193f Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Wed, 19 Jan 2022 21:49:18 -0800 Subject: [PATCH 08/23] Use single config option instead of multiple for enabling/configuring fft --- generators/chipyard/src/main/scala/config/RocketConfigs.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index 3a6de2b8..cbc102d3 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -22,9 +22,7 @@ class TinyRocketConfig extends Config( new chipyard.config.AbstractConfig) class FFTRocketConfig extends Config( - new fftgenerator.WithFFTNumPoints(8) ++ - new fftgenerator.WithFFTBaseAddr(0x2000) ++ - new fftgenerator.WithFFTGenerator ++ + new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8) ++ new freechips.rocketchip.subsystem.WithNBigCores(1) ++ new chipyard.config.AbstractConfig) From d8a9cfc592a004820f5da7c5ee3f290ef2eb9d88 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Thu, 20 Jan 2022 14:58:36 -0800 Subject: [PATCH 09/23] Move fft-test into tests/ directory --- tests/fft.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/fft.c diff --git a/tests/fft.c b/tests/fft.c new file mode 100644 index 00000000..fbe36b48 --- /dev/null +++ b/tests/fft.c @@ -0,0 +1,69 @@ +#define FFT_WRITE_LANE 0x2000 +#define FFT_RD_LANE_BASE 0x2008 +// addr of read lane i is FFT_RD_LANE_BASE + i * 8 + +#include +#include +#include + +// from test_pts.py +// point size (and therefore integer width/uint32_t) determined by IOWidth from Tail.scala +// point size is 2 * IOWidth since both real and imaginary components get IOWidth bits +const uint32_t points[8] = { + 0b00000000101101011111111101001011, // 00B5FF4B + 0b00000000000000001111111100000000, // 0000FF00 + 0b11111111010010111111111101001011, // FF4BFF4B + 0b11111111000000000000000000000000, // FF000000 + 0b11111111010010110000000010110101, // FF4B00B5 + 0b00000000000000000000000100000000, // 00000100 + 0b00000000101101010000000010110101, // 00B500B5 + 0b00000001000000000000000000000000 // 01000000 +}; + +const uint32_t expected_outputs[8] = { + 0x00000000, // read 0 + 0x00000000, // read 1 + 0x00000000, // read 2 + 0xffff0000, // read 3 + 0x00000000, // read 4 -- real portion is 0xff (very small negative number) + 0x00000000, // read 5 + 0x00000000, // read 6 + 0x05a8fa57, // read 7 -- real: ~5.656 imaginary: ~-5.656 +}; + +int main(void) { + int num_points = 8; + + // write points to fft + for (int i = 0; i < num_points; i++) { + uint32_t write_val = points[i]; + volatile uint32_t* ptr = (volatile uint32_t*) FFT_WRITE_LANE; + *ptr = write_val; + } + + for (int i = 0; i < num_points; i++) { + volatile uint32_t* ptr_0 = (volatile uint32_t*) (FFT_RD_LANE_BASE + (i * 8)); + uint32_t read_val = *ptr_0; + + /* To convert binary to floating point + * However, RISC-V compiler can't print floats. You can use this by copy-pasting it into an online + * C compiler. The printf at the bottom of this for loop will print out the values of real_part_bin + * and imag_part_bin + * + * Code is commented out because default risc-v compiler doesn't support pow + */ + // uint16_t real_part_bin = read_val >> 16; + // uint16_t imag_part_bin = read_val & 0xFFFF; + // int bp = 8; // from tail.scala + // float real_comp = ((int16_t) real_part_bin) * pow(2, bp); + // float imag_comp = ((int16_t) imag_part_bin) * pow(2, bp); + + if (read_val != expected_outputs[i]) { + printf("FAIL: Expected and real differed: %x %x", read_val, expected_outputs[i]); + return -1; + } + } + + printf("PASS: FFT Test Passed\n"); + return 0; +} \ No newline at end of file From 1dacb5367e83ace043a2859739d1ceb5804cd67c Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Thu, 20 Jan 2022 18:53:05 -0800 Subject: [PATCH 10/23] Update FFTRocketConfig to set number representation --- generators/chipyard/src/main/scala/config/RocketConfigs.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index cbc102d3..a87eb6b7 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -22,7 +22,7 @@ class TinyRocketConfig extends Config( new chipyard.config.AbstractConfig) class FFTRocketConfig extends Config( - new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8) ++ + new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8, width=16, decPt=8) ++ new freechips.rocketchip.subsystem.WithNBigCores(1) ++ new chipyard.config.AbstractConfig) From 807cf7f11c2ec79246ebb0c4b25bfcb07c30e8f1 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Thu, 20 Jan 2022 18:53:18 -0800 Subject: [PATCH 11/23] Bump fft-generator commit --- generators/fft-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/fft-generator b/generators/fft-generator index f190edd3..04d6b3e9 160000 --- a/generators/fft-generator +++ b/generators/fft-generator @@ -1 +1 @@ -Subproject commit f190edd31c94033794f60a30a6377c976b340636 +Subproject commit 04d6b3e930d80b7e6f1076bfac39252b8cfb1267 From e77355818069ad47ac00a5733c1f1513733ff085 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Sat, 22 Jan 2022 13:24:09 -0800 Subject: [PATCH 12/23] Comment RocketConfigs and fft test --- .../src/main/scala/config/RocketConfigs.scala | 2 +- tests/fft.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index a87eb6b7..8ccf698a 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -22,7 +22,7 @@ class TinyRocketConfig extends Config( new chipyard.config.AbstractConfig) class FFTRocketConfig extends Config( - new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8, width=16, decPt=8) ++ + new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8, width=16, decPt=8) ++ // add 8-point mmio fft at 0x2000 with 16bit fixed-point numbers. new freechips.rocketchip.subsystem.WithNBigCores(1) ++ new chipyard.config.AbstractConfig) diff --git a/tests/fft.c b/tests/fft.c index fbe36b48..cddfa6db 100644 --- a/tests/fft.c +++ b/tests/fft.c @@ -1,12 +1,14 @@ -#define FFT_WRITE_LANE 0x2000 -#define FFT_RD_LANE_BASE 0x2008 -// addr of read lane i is FFT_RD_LANE_BASE + i * 8 +/* This Test should be used with the fft generator config -- FFTRocketConfig. */ #include #include #include -// from test_pts.py +#define FFT_WRITE_LANE 0x2000 +#define FFT_RD_LANE_BASE 0x2008 +// addr of read lane i is FFT_RD_LANE_BASE + i * 8 + +// from generators/fft-generator/test_pts.py (in the fft-generator repo) // point size (and therefore integer width/uint32_t) determined by IOWidth from Tail.scala // point size is 2 * IOWidth since both real and imaginary components get IOWidth bits const uint32_t points[8] = { @@ -24,8 +26,8 @@ const uint32_t expected_outputs[8] = { 0x00000000, // read 0 0x00000000, // read 1 0x00000000, // read 2 - 0xffff0000, // read 3 - 0x00000000, // read 4 -- real portion is 0xff (very small negative number) + 0xffff0000, // read 3 -- real portion is 0xff (very small negative number) + 0x00000000, // read 4 0x00000000, // read 5 0x00000000, // read 6 0x05a8fa57, // read 7 -- real: ~5.656 imaginary: ~-5.656 From 32efaaec970e572995a78cd1ff413a22f4b4a9fa Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Sat, 22 Jan 2022 13:42:05 -0800 Subject: [PATCH 13/23] Bump fft-generator commit --- generators/fft-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/fft-generator b/generators/fft-generator index 04d6b3e9..b9f1c085 160000 --- a/generators/fft-generator +++ b/generators/fft-generator @@ -1 +1 @@ -Subproject commit 04d6b3e930d80b7e6f1076bfac39252b8cfb1267 +Subproject commit b9f1c085afa25e1688d5acbd3f252882d511b90e From f728a393ba22fa05f29666a7e0fce0686ae09ef9 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 11:12:43 -0800 Subject: [PATCH 14/23] Add fft generator to CI --- .circleci/defaults.sh | 1 + .github/scripts/run-tests.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.circleci/defaults.sh b/.circleci/defaults.sh index bfb63a33..5d7a886e 100755 --- a/.circleci/defaults.sh +++ b/.circleci/defaults.sh @@ -81,6 +81,7 @@ mapping["chipyard-nvdla"]=" CONFIG=SmallNVDLARocketConfig" mapping["chipyard-sodor"]=" CONFIG=Sodor5StageConfig" mapping["chipyard-multiclock-rocket"]=" CONFIG=MulticlockRocketConfig" mapping["chipyard-nomem-scratchpad"]=" CONFIG=MMIOScratchpadOnlyRocketConfig" +mapping["chipyard-fftgenerator"]=" CONFIG=FFTRocketConfig" mapping["firesim"]="SCALA_TEST=firesim.firesim.RocketNICF1Tests" mapping["firesim-multiclock"]="SCALA_TEST=firesim.firesim.RocketMulticlockF1Tests" diff --git a/.github/scripts/run-tests.sh b/.github/scripts/run-tests.sh index e5bdf99c..bc344c1a 100755 --- a/.github/scripts/run-tests.sh +++ b/.github/scripts/run-tests.sh @@ -111,6 +111,10 @@ case $1 in make -C $LOCAL_CHIPYARD_DIR/tests make -C $LOCAL_SIM_DIR $DISABLE_SIM_PREREQ ${mapping[$1]} BINARY=$LOCAL_CHIPYARD_DIR/tests/nvdla.riscv run-binary-fast ;; + chipyard-fftgenerator) + make -C $LOCAL_CHIPYARD_DIR/tests + make -C $LOCAL_SIM_DIR $DISABLE_SIM_PREREQ ${mapping[$1]} BINARY=$LOCAL_CHIPYARD_DIR/tests/fft.riscv run-binary-fast + ;; icenet) make run-binary-fast BINARY=none -C $LOCAL_SIM_DIR $DISABLE_SIM_PREREQ ${mapping[$1]} ;; From a3198add7bfbac0894a80a38b44199a760a1e8ef Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 11:20:48 -0800 Subject: [PATCH 15/23] Add fft test to Makefile --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index ca8268ea..556c6fd3 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,7 +6,7 @@ LDFLAGS= -static include libgloss.mk PROGRAMS = pwm blkdev accum charcount nic-loopback big-blkdev pingd \ - streaming-passthrough streaming-fir nvdla spiflashread spiflashwrite + streaming-passthrough streaming-fir nvdla spiflashread spiflashwrite fft spiflash.img: spiflash.py python3 $< From afad6c46364b9c65343cd3268bbfc395e75f53b7 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 14:32:12 -0800 Subject: [PATCH 16/23] Add fft test to yml --- .github/workflows/chipyard-run-tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/chipyard-run-tests.yml b/.github/workflows/chipyard-run-tests.yml index 560cd142..443426b6 100644 --- a/.github/workflows/chipyard-run-tests.yml +++ b/.github/workflows/chipyard-run-tests.yml @@ -375,6 +375,26 @@ jobs: project-key: "chipyard-sodor" - uses: ./.github/actions/job-end + chipyard-fftgenerator-run-tests: + name: chipyard-fftgenerator-run-tests + needs: prepare-chipyard-cores + runs-on: ubuntu-latest + container: + image: ucbbar/chipyard-ci-image:554b436 + options: --entrypoint /bin/bash + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: ./.github/actions/job-start + id: job-start + - name: Run tests + if: steps.job-start.outputs.run_result != 'success' + uses: ./.github/actions/run-tests + with: + group-key: "group-cores" + project-key: "chipyard-fftgenerator" + - uses: ./.github/actions/job-end + chipyard-dmirocket-run-tests: name: chipyard-dmirocket-run-tests needs: prepare-chipyard-peripherals From f4587c6fff4878bf51fd1be68405043f3ae4311c Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 16:08:45 -0800 Subject: [PATCH 17/23] Add fft core to groupcores --- .circleci/defaults.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/defaults.sh b/.circleci/defaults.sh index 5d7a886e..2ff81ef1 100755 --- a/.circleci/defaults.sh +++ b/.circleci/defaults.sh @@ -49,7 +49,7 @@ LOCAL_FIRESIM_DIR=$LOCAL_CHIPYARD_DIR/sims/firesim/sim # key value store to get the build groups declare -A grouping -grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad" +grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad chipyard-fftgenerator" grouping["group-peripherals"]="chipyard-dmirocket chipyard-blkdev chipyard-spiflashread chipyard-spiflashwrite chipyard-mmios chipyard-lbwif" grouping["group-accels"]="chipyard-nvdla chipyard-sha3 chipyard-hwacha chipyard-gemmini chipyard-streaming-fir chipyard-streaming-passthrough" grouping["group-tracegen"]="tracegen tracegen-boom" From f22d1c5a6df0d69764178b502079564238ebee72 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 16:50:23 -0800 Subject: [PATCH 18/23] docs for fft generator --- docs/Generators/fft.rst | 63 +++++++++++++++++++++++++++++++++++++++ docs/Generators/index.rst | 1 + 2 files changed, 64 insertions(+) create mode 100644 docs/Generators/fft.rst diff --git a/docs/Generators/fft.rst b/docs/Generators/fft.rst new file mode 100644 index 00000000..4ced93df --- /dev/null +++ b/docs/Generators/fft.rst @@ -0,0 +1,63 @@ +FFT Generator +==================================== + +The FFT generator is a parameterizable fft accelerator. + +Configuration +-------------------------- +The following configuration creates an 8-point FFT: + +.. literalinclude:: ../../generators/chipyard/src/main/scala/config/RocketConfigs.scala + :language: scala + :start-after: DOC include start: FFTRocketConfig + :end-before: DOC include end: FFTRocketConfig + +:code:`baseAddress` specifies the starting address of the FFT's read and write lanes. The FFT write lane is always located at :code:`baseAddress`. There is 1 read lane per output point; since this config specifies an 8-point FFT, there will be 8 read lanes. Read lane :code:`i` (which can be loaded from to retrieve output point :code:`i`) will be located at :code:`baseAddr + 64bits (assuming 64bit system) + (i * 8)`. :code:`baseAddress` should be 64-bit aligned + +:code:`width` is the size of input points in binary. A width of :code:`w` means that each point will have :code:`w` bits for the real component and :code:`w` bits for the imaginary component, yielding a total of `2w` bits per point. :code:`decPt` is the location of the decimal point in the fixed-precision representation of each point's real and imaginary value. In the Config above, each point is `32` bits wide, with `16` bits used to represent the real component and `16` bits used to represent the imaginary component. Within the `16` bits for each component, the `8` LSB are used to represent the decimal component of the value and the remaining (8) MSB are used to represent the integer component. Both the real and imaginary components use a fixed-precision representation. + +To build a simulation of this example Chipyard config, run the following commands: + +.. code-block:: shell + + cd sims/verilator # or "cd sims/vcs" + make CONFIG=FFTRocketConfig + +Usage and Testing +-------------------------- + +Points are passed into the FFT via the single write lane. In C pseudocode, this might look like: + +.. code-block:: C + + for (int i = 0; i < num_points; i++) { + // FFT_WRITE_LANE = baseAddress + uint32_t write_val = points[i]; + volatile uint32_t* ptr = (volatile uint32_t*) FFT_WRITE_LANE; + *ptr = write_val; + } + +Once the correct number of inputs are passed in (in the config above, 8 values would be passed in), the read lanes can be read from (again in C pseudocode): + +.. code-block:: C + + for (int i = 0; i < num_points; i++) { + // FFT_RD_LANE_BASE = baseAddress + 64bits (for write lane) + volatile uint32_t* ptr_0 = (volatile uint32_t*) (FFT_RD_LANE_BASE + (i * 8)); + uint32_t read_val = *ptr_0; + } + +The :code:`fft.c` test file in the :code:`tests/` directory can be used to verify the fft's functionality on an SoC built with :code:`FFTRocketConfig`. + +Acknowledgements +-------------------------- +The code for the FFT Generator was adapted from the ADEPT Lab at UC Berkeley's `Hydra Spine `_ project. + +Authors for the original project (in no particular order): + +* James Dunn, UC Berkeley (dunn [at] eecs [dot] berkeley [dot] edu) + * :code:`Deserialize.scala` + * :code:`Tail.scala` + * :code:`Unscramble.scala` +* Stevo Bailey (stevo.bailey [at] berkeley [dot] edu) + * :code:`FFT.scala` diff --git a/docs/Generators/index.rst b/docs/Generators/index.rst index 22d7ad40..27e18e77 100644 --- a/docs/Generators/index.rst +++ b/docs/Generators/index.rst @@ -29,6 +29,7 @@ so changes to the generators themselves will automatically be used when building SHA3 CVA6 Ibex + fft NVDLA Sodor From 2e2362682aef8f0aefc7093545b9ee8638dbfdbb Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 22:30:17 -0800 Subject: [PATCH 19/23] Add fftgenerator's config to github actions mapping in default.sh --- .github/scripts/defaults.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index 5d33cbf7..f311d74c 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -69,6 +69,7 @@ mapping["chipyard-nvdla"]=" CONFIG=SmallNVDLARocketConfig" mapping["chipyard-sodor"]=" CONFIG=Sodor5StageConfig" mapping["chipyard-multiclock-rocket"]=" CONFIG=MulticlockRocketConfig" mapping["chipyard-nomem-scratchpad"]=" CONFIG=MMIOScratchpadOnlyRocketConfig" +mapping["chipyard-fftgenerator"]=" CONFIG=FFTRocketConfig" mapping["firesim"]="SCALA_TEST=firesim.firesim.RocketNICF1Tests" mapping["firesim-multiclock"]="SCALA_TEST=firesim.firesim.RocketMulticlockF1Tests" From 15e40d40c7d2818229037a5473f93da61c9a7654 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 22:34:56 -0800 Subject: [PATCH 20/23] Add fftgenerator as dependency to to 'all tests passed' --- .github/workflows/chipyard-run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/chipyard-run-tests.yml b/.github/workflows/chipyard-run-tests.yml index 443426b6..9dd7281a 100644 --- a/.github/workflows/chipyard-run-tests.yml +++ b/.github/workflows/chipyard-run-tests.yml @@ -737,7 +737,7 @@ jobs: name: "all tests passed" needs: [commit-on-master-check, tutorial-setup-check, documentation-check, chipyard-rocket-run-tests, chipyard-hetero-run-tests, chipyard-boom-run-tests, chipyard-cva6-run-tests, chipyard-ibex-run-tests, - chipyard-sodor-run-tests, chipyard-dmirocket-run-tests, chipyard-spiflashwrite-run-tests, + chipyard-sodor-run-tests, chipyard-dmirocket-run-tests, chipyard-spiflashwrite-run-tests, chipyard-fftgenerator-run-tests, chipyard-spiflashread-run-tests, chipyard-lbwif-run-tests, chipyard-sha3-run-tests, chipyard-streaming-fir-run-tests, chipyard-streaming-passthrough-run-tests, chipyard-hwacha-run-tests, chipyard-gemmini-run-tests, chipyard-nvdla-run-tests, From 950876b835dd4b4fbe16d33fb33a73516694b49f Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Mon, 24 Jan 2022 23:49:45 -0800 Subject: [PATCH 21/23] Add doc include messages to RocketConfigs for fft --- generators/chipyard/src/main/scala/config/RocketConfigs.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generators/chipyard/src/main/scala/config/RocketConfigs.scala b/generators/chipyard/src/main/scala/config/RocketConfigs.scala index 8ccf698a..1888fc5a 100644 --- a/generators/chipyard/src/main/scala/config/RocketConfigs.scala +++ b/generators/chipyard/src/main/scala/config/RocketConfigs.scala @@ -21,10 +21,12 @@ class TinyRocketConfig extends Config( new freechips.rocketchip.subsystem.With1TinyCore ++ // single tiny rocket-core new chipyard.config.AbstractConfig) +// DOC include start: FFTRocketConfig class FFTRocketConfig extends Config( new fftgenerator.WithFFTGenerator(baseAddr=0x2000, numPoints=8, width=16, decPt=8) ++ // add 8-point mmio fft at 0x2000 with 16bit fixed-point numbers. new freechips.rocketchip.subsystem.WithNBigCores(1) ++ new chipyard.config.AbstractConfig) +// DOC include end: FFTRocketConfig class HwachaRocketConfig extends Config( new chipyard.config.WithHwachaTest ++ From 6ef6c20a7773245ed0e7b7c3703f8ff449cb0f09 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Tue, 25 Jan 2022 02:29:58 -0800 Subject: [PATCH 22/23] Add fftgenerator to group-cores --- .github/scripts/defaults.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index f311d74c..ae1b5964 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -37,7 +37,7 @@ LOCAL_FIRESIM_DIR=$LOCAL_CHIPYARD_DIR/sims/firesim/sim # key value store to get the build groups declare -A grouping -grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad" +grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad chipyard-fftgenerator" grouping["group-peripherals"]="chipyard-dmirocket chipyard-blkdev chipyard-spiflashread chipyard-spiflashwrite chipyard-mmios chipyard-lbwif" grouping["group-accels"]="chipyard-nvdla chipyard-sha3 chipyard-hwacha chipyard-gemmini chipyard-streaming-fir chipyard-streaming-passthrough" grouping["group-tracegen"]="tracegen tracegen-boom" From dba2a584f27424710fa894fc37d48d3a62a44910 Mon Sep 17 00:00:00 2001 From: Animesh Agrawal Date: Tue, 25 Jan 2022 04:24:13 -0800 Subject: [PATCH 23/23] Move fft to group-accel --- .github/scripts/defaults.sh | 4 ++-- .github/workflows/chipyard-run-tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/defaults.sh b/.github/scripts/defaults.sh index ae1b5964..25bffb6a 100755 --- a/.github/scripts/defaults.sh +++ b/.github/scripts/defaults.sh @@ -37,9 +37,9 @@ LOCAL_FIRESIM_DIR=$LOCAL_CHIPYARD_DIR/sims/firesim/sim # key value store to get the build groups declare -A grouping -grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad chipyard-fftgenerator" +grouping["group-cores"]="chipyard-cva6 chipyard-ibex chipyard-rocket chipyard-hetero chipyard-boom chipyard-sodor chipyard-digitaltop chipyard-multiclock-rocket chipyard-nomem-scratchpad" grouping["group-peripherals"]="chipyard-dmirocket chipyard-blkdev chipyard-spiflashread chipyard-spiflashwrite chipyard-mmios chipyard-lbwif" -grouping["group-accels"]="chipyard-nvdla chipyard-sha3 chipyard-hwacha chipyard-gemmini chipyard-streaming-fir chipyard-streaming-passthrough" +grouping["group-accels"]="chipyard-fftgenerator chipyard-nvdla chipyard-sha3 chipyard-hwacha chipyard-gemmini chipyard-streaming-fir chipyard-streaming-passthrough" grouping["group-tracegen"]="tracegen tracegen-boom" grouping["group-other"]="icenet testchipip" grouping["group-fpga"]="arty vcu118" diff --git a/.github/workflows/chipyard-run-tests.yml b/.github/workflows/chipyard-run-tests.yml index 9dd7281a..245bfd74 100644 --- a/.github/workflows/chipyard-run-tests.yml +++ b/.github/workflows/chipyard-run-tests.yml @@ -377,7 +377,7 @@ jobs: chipyard-fftgenerator-run-tests: name: chipyard-fftgenerator-run-tests - needs: prepare-chipyard-cores + needs: prepare-chipyard-accels runs-on: ubuntu-latest container: image: ucbbar/chipyard-ci-image:554b436 @@ -391,7 +391,7 @@ jobs: if: steps.job-start.outputs.run_result != 'success' uses: ./.github/actions/run-tests with: - group-key: "group-cores" + group-key: "group-accels" project-key: "chipyard-fftgenerator" - uses: ./.github/actions/job-end