Skip to content

About

Krypton is a 32-bit datapath single cycle processor core built according to the RISC-V standards for chip design and architecture. It is free and open-source under the AGPL v3.0 License.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


โœจ Overview

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

๐Ÿง  About Krypton-Core

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.


๐ŸŽฏ Highlights

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

๐Ÿ—๏ธ RISC-V Single-Cycle Datapath

RISC-V Single Cycle Architecture

The datapath connects the major processor components to execute RISC-V instructions.

Core Flow

            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚     PC      โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ†“
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ Instruction Mem  โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ†“
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚     Decode       โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ†“
      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ†“                       โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Register    โ”‚       โ”‚ Immediate    โ”‚
โ”‚ File        โ”‚       โ”‚ Generator    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ†“
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚   ALU    โ”‚
            โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
                 โ†“
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ†“                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Data Memory โ”‚      โ”‚   Next PC   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ†“
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ Write Back โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ฉ Processor Components

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

๐Ÿ“‚ Repository Structure

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

๐Ÿ“ Instruction Programs

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

๐Ÿ”„ Selecting a Program

The program executed by Krypton-Core is selected in InstMem.scala and Top.scala.

1๏ธโƒฃ Configure Instruction Memory

Open src/main/scala/core/InstMem.scala and find:

class InstMem(initFile: String = "fibonaciAssembly.txt") extends Module with Config4

Change 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 Config4

2๏ธโƒฃ Configure the Top Module

Open src/main/scala/core/Top.scala and find:

class Top(initFile: String = "fibonaciAssembly.txt") extends Module

Change 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.


โšก Quick Start

# 1. Clone
git clone https://github.com/Blue-Rangoon/Krypton-Core.git

# 2. Enter the project
cd Krypton-Core

# 3. Start SBT
sbt

Inside SBT:

# 4. Run the processor test
testOnly core.TopTest

# 5. Run it and generate a waveform
testOnly core.TopTest -- -DwriteVcd=1

Then 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>

๐ŸŒŠ GTKWave

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.vcd

๐Ÿ”ฌ What Can Be Observed?

GTKWave 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.


๐ŸŒ€ Fibonacci Demonstration

One of the programs shipped with Krypton-Core is a Fibonacci implementation, stored in fibonaciAssembly.txt.

Run it in 4 steps:

  1. Set fibonaciAssembly.txt in both InstMem.scala and Top.scala
  2. Start SBT with sbt
  3. Run testOnly core.TopTest (or add -- -DwriteVcd=1 for a waveform)
  4. Inspect the generated VCD in GTKWave

๐Ÿงช Verification Workflow

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]
Loading

๐Ÿ› ๏ธ Technologies

Technology Used For
๐ŸŸ  Chisel Hardware Construction
๐Ÿ”ด Scala Hardware Description
๐ŸŸข RISC-V RV32I Instruction Set Architecture
๐Ÿ”ต SBT Build & Testing
๐ŸŸฃ ChiselTest Hardware Verification
๐ŸŒŠ GTKWave Waveform Analysis

๐ŸŽฏ Project Goals

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

๐Ÿ“š RISC-V

Krypton-Core is based on the RISC-V RV32I instruction-set architecture, built around these fundamentals:

Registers + ALU + Memory + Control + Program Counter
                       โ†“
              Instruction Execution

๐Ÿค Connect

Built by Blue Rangoon

GitHub LinkedIn


A clean and simple single-cycle RV32I processor implemented in Chisel.

โญ If you find this project useful, consider giving the repository a star!

Footer Typing SVG

About

Krypton is a 32-bit datapath single cycle processor core built according to the RISC-V standards for chip design and architecture. It is free and open-source under the AGPL v3.0 License.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages