contributed by AgainTW
build-essential
) in Cygwin
.$ apt-cyg install make gcc-core gcc-g++ patch bzip2 perl tar xz
$ apt-cyg install git automake cmake python3-devel
$ apt-cyg install flex bison glade-python
$ cd "address about .gz file"
$ tar vxfz verilator-5.018.tar.gz
$ cd verilator-5.018
$ autoconf
$ ./configure
$ make -j
./configure
again.
Annotation: Installing some libraries using apt-cyg
will cause incorrect environment variable settings (such as "bison" library), so it is recommended to re-install using the cygwin installation file.
$ cd "address about .gz file"
$ tar vxfz gtkwave-gtk3-3.3.114.tar.gz
$ cd gtkwave-gtk3-3.3.114
$ autoconf
$ ./configure
Annotation: I additionally installed tcl, tk, gperf, libz, libbz2, xz-devel, LZMA, libgtk2
$ curl -s "https://get.sdkman.io" | bash
Annotation: I additionally installed unzip、zip
CTRL+C
to close sbt in cygwin.$ cd "address_of_your_file\chisel\chisel-tutorial"
again@DESKTOP-7MC8UTU ..\chisel\chisel-tutorial
$ sbt run
[info] Loading project definition from ..\chisel\chisel-tutorial\project
[info] Loading settings for project chisel-tutorial from build.sbt ...
[info] Set current project to chisel-tutorial (in build file:/../chisel/chisel-tutorial/)
[info] running hello.Hello
[info] [0.000] Elaborating design...
[info] [0.047] Done elaborating.
Computed transform order in: 125.6 ms
Total FIRRTL Compile Time: 269.7 ms
End of dependency graph
Circuit state created
[info] [0.000] SEED 1701862250275
test Hello Success: 1 tests passed in 6 cycles taking 0.008166 seconds
[info] [0.000] RAN 1 CYCLES PASSED
[success] Total time: 3 s, completed 2023年12月6日 下午7:30:52
again@DESKTOP-7MC8UTU ../chisel/chisel-tutorial
$ ./run-examples.sh FullAdder
[sbt_options] declare -a sbt_options=()
[process_args] java_version = '11'
[copyRt] java9_rt = 'C:\Users\again\.sbt\1.0\java9-rt-ext-microsoft_11_0_21/rt.jar'
# Executing command line:
java
-Dfile.encoding=UTF-8
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-Dsbt.script=/cygdrive/c/Program%20Files%20(x86)/sbt/bin/sbt
-Dscala.ext.dirs=C:\Users\again\.sbt\1.0\java9-rt-ext-microsoft_11_0_21
-Djline.terminal=jline.UnixTerminal
-Dsbt.cygwin=true
-jar
"C:\Program Files (x86)\sbt\bin\sbt-launch.jar"
"test:runMain examples.Launcher FullAdder"
[info] Loading project definition from ..\chisel\chisel-tutorial\project
[info] Loading settings for project chisel-tutorial from build.sbt ...
[info] Set current project to chisel-tutorial (in build file:/../chisel/chisel-tutorial/)
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
[info] running examples.Launcher FullAdder
Starting tutorial FullAdder
[info] [0.000] Elaborating design...
[info] [0.912] Done elaborating.
Computed transform order in: 265.5 ms
Total FIRRTL Compile Time: 405.6 ms
file loaded in 0.0360903 seconds, 13 symbols, 8 statements
[info] [0.000] SEED 1701862629796
test FullAdder Success: 8 tests passed in 9 cycles in 0.011595 seconds 776.17 Hz
[info] [0.000] RAN 4 CYCLES PASSED
Tutorials passing: 1
[success] Total time: 3 s, completed 2023年12月6日 下午7:37:11
sbt
command to use chisel.src/
├── main/
│ ├── resources/
│ │ └── <files to include in main jar here>
│ ├── scala/
│ │ └── <main Scala sources>
│ ├── scala-2.12/
│ │ └── <main Scala 2.12 specific sources>
│ └── java/
│ └── <main Java sources>
└── test/
├── resources/
│ └── <files to include in test jar here>
├── scala/
│ └── <test Scala sources>
├── scala-2.12/
│ └── <test Scala 2.12 specific sources>
└── java/
└── <test Java sources>
sbt new
to add a new template.git
to add a new template.git clone https://github.com/freechipsproject/chisel-template
source a.sh
and sh a.sh
.$ cd "target folder"
$ git clone https://github.com/sysprog21/chisel-bootcamp
$ cd chisel-bootcamp
$ export SCALA_VERSION=2.12.10
$ export ALMOND_VERSION=0.9.1
$ export COURSIER_CACHE=coursier_cache
$ export JUPYTER_CONFIG_DIR=jupyter/config
$ export JUPITER_DATA_DIR=jupyter/data
$ mkdir -p $JUPYTER_CONFIG_DIR/custom
$ cp source/custom.js $JUPYTER_CONFIG_DIR/custom/
$ apt-cyg install graphviz
$ mkdir coursier_cache
$ curl -Lo coursier https://git.io/coursier-cli && chmod +x coursier
$ ./coursier bootstrap \
-r jitpack \
-i user -I user:sh.almond:scala-kernel-api_2.12.11:0.10.0 \
sh.almond:scala-kernel_2.12.11:0.10.0 \
-o almond
$ ./almond --install --id scala_2_12_8 --display-name "Scala 2.12.8"
$ jupyter notebook
visualize()
visualize()
function, but the image is still generated and saved in the diagrams
subfolder.
.json
and.fir
files will be generated under the .ipynb
.$ docker run -it --rm -p 8888:8888 sysprog21/chisel-bootcamp
.asTypeOf()
Arbiter
firrtl.Compiler
cannot compile the modified FIRRTL normally. Therefore, the FIRRTL-related content in Chapters 7 and 8 is still being established and i still attempts to resolve related issues.$ git clone https://github.com/sysprog21/ca2023-lab3
$ cd ca2023-lab3
jump
instruction, the ID decoding of the previous cycle jump_flag_id
is true, and the jump_flag_id
result is input to the IF in this cycle, therefore:memory_read_enable
and memory_write_enable
according to the opcode type.Mux
hardware to determine the ALU data input based on aluop1_source
and aluop2_source
from ID respectively.alu_ctrl
sbt run
[info] welcome to sbt 1.9.7 (Microsoft Java 11.0.21)
[info] loading settings for project ca2023-lab3_sysprog21-build from plugins.sbt ...
[info] loading project definition from C:\AG\course notes\112_1\閮?璈?瑽HW3\RV32 bootcamp\ca2023-lab3_sysprog21\project
[info] loading settings for project root from build.sbt ...
[info] set current project to mycpu (in build file:/C:/AG/course%20notes/112_1/閮?璈?瑽?HW3/RV32%20bootcamp/ca2023-lab3_sysprog21/)
[info] running board.verilator.VerilogGenerator
[success] Total time: 4 s, completed 2024撟???5??銝?5:40:52
sbt test
[info] RegisterFileTest:
[info] Register File of Single Cycle CPU
[info] - should read the written content
[info] - should x0 always be zero
[info] - should read the writing content
[info] Run completed in 4 seconds, 145 milliseconds.
[info] Total number of tests run: 9
[info] Suites: completed 7, aborted 0
[info] Tests: succeeded 6, failed 3, canceled 0, ignored 0, pending 0
[info] *** 3 TESTS FAILED ***
[error] Failed tests:
[error] riscv.singlecycle.ByteAccessTest
[error] riscv.singlecycle.FibonacciTest
[error] riscv.singlecycle.QuicksortTest
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 5 s, completed 2024撟???5??銝?5:40:41
test(new CPU) { c =>
def printReg() = {
for(i <- 0 until Parameters.PhysicalRegisters){
c.io.debug_read_address.poke(i.U)
print(s"${c.io.debug_read_data.peek()} ")
if(i%8==7) println()
}
println()
}
// Init
printReg()
c.clock.step(1)
// I1 addi x1, x1, 15
c.io.instruction_valid.poke(true.B)
c.io.instruction.poke("b00000000111100001000000010010011".U)
c.clock.step(1)
printReg()
// I2 addi x2, x2, 5
c.io.instruction_valid.poke(true.B)
c.io.instruction.poke("b00000000010100010000000100010011".U)
c.clock.step(1)
printReg()
// I2 add x3, x2, x1
c.io.instruction_valid.poke(true.B)
c.io.instruction.poke("b00000000000100010000000110110011".U)
c.clock.step(1)
printReg()
}
Elaborating design...
Done elaborating.
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(15) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(15) UInt<32>(5) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(15) UInt<32>(5) UInt<32>(20) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0) UInt<32>(0)
test CPU Success: 0 tests passed in 6 cycles in 0.124751 seconds 48.10 Hz
val path = System.getProperty("user.dir") + "/source/load-ivy.sc"
interp.load.module(ammonite.ops.Path(java.nio.file.FileSystems.getDefault().getPath(path)))
objects
, so pay attention to the "import of objects
".
ArraySeq
is defined in immutable
, but jupyter kernel scala’s ArraySeq
is defined in mutable
.import scala.collection.immutable
import scala.collection.mutable.{ArraySeq => mutable_ArraySeq}
ceil
.
// Original: Can be compiled in sbt, but cannot be compiled successfully in jupyter
val WordSize = Math.ceil(DataBits / ByteBits).toInt
// After modification, it can be compiled in jupyter
val WordSize = ((DataBits / ByteBits).ceil).toInt
getVerilog()
and visualize()
.build-essential
in Cygwin
?