This project implements a Brainfsck interpreter in Chisel with multiple simulation and hardware targets.
- 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
Run simulation:
sbt "runMain brainfsck.Simulate"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/
Generate Verilog for NVBoard simulation:
sbt "runMain brainfsck.NvboardTop"This generates SystemVerilog files in target/src/main/sv/
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
The project includes several example programs:
tolower.bf: Converts input to lowercaserepeat.bf: Repeats one sentence based on user choicehello.bf: Hello world program
Run the test suites with:
sbt testTests cover:
- Data memory functionality
- Random delay module behavior
- Passthrough buffer correctness