Skip to content

Commit

Permalink
Add CDE test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Phantom1003 committed Aug 13, 2021
1 parent 25b5c95 commit ff89765
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ This project will follow the lastest rocket-chip, the functions of each folder i
Before you start compiling, you should already have sbt, vivado and a RISC-V toolchian.
```bash
# sbt install: https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html
# vivado install: https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/2020-2.html
# RISC-V toolchain: https://github.com/riscv-zju/riscv-rss-sdk

$ git clone https://github.com/riscv-zju/riscv-starship.git
$ git submodule update --init --recursive --progress

# set $RISCV to your toolchain path, not inclued bin
$ make bitstream
```
After these, you will find your bitstream under `build/vivado/obj`, named `TestHarness.bit`.
To use Intellij IDEA as your IDE, please install scala plugin and use (JDK 11)[https://www.oracle.com/java/technologies/javase-jdk11-downloads.html] as your project SDK (at File - Project Structure).
After compiling, you will find your bitstream under `build/vivado/obj`, named `TestHarness.bit`.

You can open `build/vivado/TestHarness.xpr` to program your FPGA device. But before loading the bitstream into the board, you should prepare the test image on a SD/TF card.
> Note that the image should place on the 2048th selector of the SD card without filesystem.
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/FPGA/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class StarshipFPGAConfig extends Config(
val make = s"make -C firmware/zsbl ROOT_DIR=${path} img"
println("[Leaving Starship] " + make)
require (make.! == 0, "Failed to build bootrom")
println("[Starship Continue]")
p.copy(hang = 0x10000, contentFileName = s"build/firmware/zsbl/bootrom.img")
}
})
Expand Down
69 changes: 69 additions & 0 deletions src/main/scala/Playyard/CDETest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package starship.playyard.cde

import chisel3._

import freechips.rocketchip.config.{Config, Field, Parameters}

case object TestKey1 extends Field[Int](-1)
case object TestKey2 extends Field[Int]
case object TestKey3 extends Field[Int](-3)
case object TestKey4 extends Field[Int]

class TestConfig extends Config((site, here, up) => {
case TestKey1 => 0
})


object CDETest {
def main(args: Array[String]): Unit = {

// Empty config
var p: Parameters = Parameters.empty

// Parameter Access
assert(p(TestKey1) == p.apply(TestKey1))
assert(p(TestKey1) == p.lift(TestKey1).get)

// Default Value
assert(p(TestKey1) == -1)
try { p(TestKey4) }
catch {
case e: java.lang.IllegalArgumentException => println(s"TestKey4 == ${p.lift(TestKey4)}")
}

// Alter
p = Parameters((site, here, up) => {
case TestKey1 => 1
})
p = p.alter((site, here, up) => {
case TestKey2 => 2
})
p = p.alterPartial({
case TestKey3 => 3
})
p = p.alterMap(Map(
TestKey4 -> 4
))
assert(p(TestKey1) == 1)
assert(p(TestKey2) == 2)
assert(p(TestKey3) == 3)
assert(p(TestKey4) == 4)

// site, here, up
p = Parameters((site, here, up) => {
case TestKey1 => 0
}) ++ Parameters((site, here, up) => {
case TestKey1 => 1
case TestKey2 => here(TestKey1, site) + 1
case TestKey3 => up(TestKey4, site) - 1
}) ++ Parameters((site, here, up) => {
case TestKey4 => site(TestKey1, site) + 4
})
assert(p(TestKey1) == 0)
assert(p(TestKey2) == 2)
assert(p(TestKey3) == 3)
assert(p(TestKey4) == 4)

print("[CDETest] SUCCESS\n")
}
}
File renamed without changes.

0 comments on commit ff89765

Please sign in to comment.