๐ง About โข ๐๏ธ Datapath โข ๐ฉ Components โข ๐ Quick Start โข ๐ GTKWave โข ๐ Fibonacci
Krypton-Core is a single-cycle RV32I RISC-V processor designed and implemented in Scala + Chisel.
It brings together a full processor datapath: instruction memory, register file, ALU, control logic, data memory, branch handling and next-PC generation. Every run can be dumped to a VCD and inspected cycle by cycle in GTKWave.
โก ISA โ RV32I (RISC-V 32-bit base integer)
๐งฌ Design Style โ Single-cycle, one instruction per clock
๐ ๏ธ Language โ Scala + Chisel (hardware construction)
๐งช Verification โ ChiselTest + GTKWave waveforms
Krypton-Core is a single-cycle RISC-V processor: every instruction travels through the whole datapath within one clock cycle.
The core follows the classic RISC-V execution flow:
Fetch โ Decode โ Execute โ Memory โ Write Back โ Next PC
Because the whole design is written in Chisel, the hardware is describable, testable, and ready for RTL generation.
| Feature | |
|---|---|
| ๐งฉ | Modular design: every block (ALU, RegFile, Controller...) is its own Chisel module |
| โฑ๏ธ | Single-cycle execution: simple, easy-to-follow datapath |
| ๐ | Branch + Jump support: branch logic and JAL/JALR handling |
| ๐ | Swappable programs: load different instruction files into instruction memory |
| ๐ | Waveform debugging: generate VCDs and step through every clock cycle |
| ๐งช | Testable: run hardware tests straight from SBT |
The datapath connects the major processor components to execute RISC-V instructions.
โโโโโโโโโโโโโโโ
โ PC โ
โโโโโโโโฌโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโ
โ Instruction Mem โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโ
โ Decode โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโโโดโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ Register โ โ Immediate โ
โ File โ โ Generator โ
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโโ
โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โโโโโโโโโโโโ
โ ALU โ
โโโโโโฌโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Data Memory โ โ Next PC โ
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ
โโโโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโโโโ
โ Write Back โ
โโโโโโโโโโโโโโ
| Component | Responsibility |
|---|---|
| ๐งญ Program Counter | Holds the current instruction address |
| ๐ Instruction Memory | Fetches instructions |
| ๐งฉ Instruction Decoder | Identifies the instruction type |
| ๐๏ธ Controller | Generates processor control signals |
| ๐๏ธ Register File | Reads and writes RISC-V registers |
| ๐ข Immediate Generator | Generates instruction immediates |
| โ๏ธ ALU Control | Selects the required ALU operation |
| ๐งฎ ALU | Performs arithmetic and logical operations |
| ๐พ Data Memory | Handles load/store operations |
| ๐ Branch Logic | Determines branch conditions |
| ๐ JAL/JALR Logic | Handles jump instructions |
| โก๏ธ Next-PC Logic | Determines the next instruction address |
Click to expand the project tree
Krypton-Core/
โ
โโโ ๐ images/ # Banner, datapath diagram, GIF
โโโ ๐ project/ # SBT project configuration
โโโ ๐ src/
โ โโโ main/scala/core/
โ โ โโโ ALU.scala
โ โ โโโ InstMem.scala
โ โ โโโ Top.scala
โ โ โโโ RegFile.scala
โ โ โโโ DataMem.scala
โ โ โโโ Controller.scala
โ โ โโโ Imm_gen.scala
โ โ โโโ ...
โ โโโ test/scala/core/ # ChiselTest testbenches
โโโ ๐ target/
โโโ ๐ test_run_dir/ # Generated test + VCD files
โ
โโโ ๐ Assembly instructions.txt
โโโ ๐ fibonaciAssembly.txt
โโโ ๐ instruction.txt
โโโ ๐ build.sbt
โโโ ๐ LICENSE
โโโ ๐ README.md
Krypton-Core loads different instruction programs through the Instruction Memory.
| File | What it contains |
|---|---|
๐ Assembly instructions.txt |
Assembly instructions for the main program |
๐ fibonaciAssembly.txt |
Assembly implementation of the Fibonacci program |
๐ข instruction.txt |
Instruction data used by the processor |
The program executed by Krypton-Core is selected in InstMem.scala and Top.scala.
Open src/main/scala/core/InstMem.scala and find:
class InstMem(initFile: String = "fibonaciAssembly.txt") extends Module with Config4Change the filename to the program you want to run:
// Fibonacci
class InstMem(initFile: String = "fibonaciAssembly.txt") extends Module with Config4
// Main assembly program
class InstMem(initFile: String = "Assembly instructions.txt") extends Module with Config4Open src/main/scala/core/Top.scala and find:
class Top(initFile: String = "fibonaciAssembly.txt") extends ModuleChange the filename to match the selected program:
class Top(initFile: String = "Assembly instructions.txt") extends Module๐ก Tip: Use the same filename in both files so the program stays consistent.
# 1. Clone
git clone https://github.com/Blue-Rangoon/Krypton-Core.git
# 2. Enter the project
cd Krypton-Core
# 3. Start SBT
sbtInside SBT:
# 4. Run the processor test
testOnly core.TopTest
# 5. Run it and generate a waveform
testOnly core.TopTest -- -DwriteVcd=1Then open the waveform:
gtkwave <generated-vcd-file>You should see the SBT prompt, for example
sbt:RISCV_Project>
The general test format is:
testOnly core.<TestName>The important option for waveform generation is:
-DwriteVcd=1
After the test finishes, open test_run_dir/, find the directory generated for the test, and open the VCD inside it:
gtkwave TopTest.vcdGTKWave lets you inspect the processor cycle by cycle.
โฑ Clock ๐ PC ๐ Instruction
๐งฎ ALU ๐ Register File ๐พ Data Memory
๐ Control Signals ๐ Branch Signals โก Next PC
๐ค Register Output
Follow the whole execution by stepping through the clock cycles:
Clock Cycle 1 โ Instruction 1
Clock Cycle 2 โ Instruction 2
Clock Cycle 3 โ Instruction 3
...
Clock Cycle N โ Instruction N
This gives a hardware-level view of how the RISC-V processor executes a program.
One of the programs shipped with Krypton-Core is a Fibonacci implementation, stored in fibonaciAssembly.txt.
Run it in 4 steps:
- Set
fibonaciAssembly.txtin bothInstMem.scalaandTop.scala - Start SBT with
sbt - Run
testOnly core.TopTest(or add-- -DwriteVcd=1for a waveform) - Inspect the generated VCD in GTKWave
flowchart LR
A[Select Program] --> B[Update InstMem.scala]
B --> C[Update Top.scala]
C --> D[sbt]
D --> E[testOnly core.TopTest]
E --> F[Generate VCD]
F --> G[test_run_dir]
G --> H[GTKWave]
| Technology | Used For |
|---|---|
| ๐ Chisel | Hardware Construction |
| ๐ด Scala | Hardware Description |
| ๐ข RISC-V RV32I | Instruction Set Architecture |
| ๐ต SBT | Build & Testing |
| ๐ฃ ChiselTest | Hardware Verification |
| ๐ GTKWave | Waveform Analysis |
Krypton-Core was built to explore the design and implementation of a RISC-V processor at the hardware level.
- ๐ง Understand the RISC-V architecture
- โ๏ธ Design a single-cycle datapath
- ๐ง Implement processor components in Chisel
- ๐งฉ Connect datapath and control logic
- ๐งช Test hardware modules
- ๐ Generate VCD waveforms
- ๐ Debug processor execution with GTKWave
Krypton-Core is based on the RISC-V RV32I instruction-set architecture, built around these fundamentals:
Registers + ALU + Memory + Control + Program Counter
โ
Instruction Execution
Built by Blue Rangoon
A clean and simple single-cycle RV32I processor implemented in Chisel.
โญ If you find this project useful, consider giving the repository a star!
