|
|
||
|---|---|---|
| project | ||
| src | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| build.sbt | ||
README.md
Brainfsck Interpreter in Chisel
This project implements a Brainfsck interpreter in Chisel with multiple simulation and hardware targets.
Project Structure
- src/main/scala: Chisel source code
Brainfsck.scala: Main Brainfsck interpreter coreDataMem.scala: Data memory implementationSimulatedRom.scala: ROM for storing Brainfsck programsUartRx.scala/UartTx.scala: UART transmitter/receiverCrossBuffer.scala: Cross-domain bufferPassthroughBuffer.scala: Passthrough buffer implementationRandomDelay.scala: Random delay module for testingFpgaTop.scala: Top-level module for FPGA implementationNvboardTop.scala: Top-level module for NVBoard simulationSimulate.scala: Simulation testbench
- src/main/cc: C++ source for NVBoard integration
- src/main/bf: Brainfsck example programs
- src/test/scala: Test suites
Targets
1. Simulation Target (SimulateTop)
Run simulation:
sbt "runMain brainfsck.Simulate"
2. FPGA Target (FpgaTop)
Generate Verilog for FPGA synthesis:
sbt "runMain brainfsck.FpgaTop"
This will:
- Generate SystemVerilog files in
target/src/main/sv/ - Create memory initialization files in
target/src/main/mi/
3. NVBoard Target (NvboardTop)
Generate Verilog for NVBoard simulation:
sbt "runMain brainfsck.NvboardTop"
This generates SystemVerilog files in target/src/main/sv/
NVBoard Integration
The project includes a C++ main file (src/main/cc/main.cc) for NVBoard integration. To use with NVBoard:
- Generate the Verilog using the NVBoard target
- Write a Makefile that:
- Compiles the Verilog code with Verilator
- Links with the NVBoard library
- Uses the provided main.cc file for pin binding and simulation
The main.cc file handles:
- Pin binding for UART interface
- Clock and reset generation
- NVBoard initialization and update
Brainfsck Programs
The project includes several example programs:
tolower.bf: Converts input to lowercaserepeat.bf: Repeats one sentence based on user choicehello.bf: Hello world program
Testing
Run the test suites with:
sbt test
Tests cover:
- Data memory functionality
- Random delay module behavior
- Passthrough buffer correctness