You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jamie Munro d294f2b6ce 2 pipeline forwarding optimizations complete: simultaneous JMP and WB, OF can fetch operands from incomplete WB 10 months ago
src 2 pipeline forwarding optimizations complete: simultaneous JMP and WB, OF can fetch operands from incomplete WB 10 months ago
Cargo.lock Initial commit 11 months ago
Cargo.toml Initial commit 11 months ago
README.md Modularised approach completed and tested. Pipeline steps are executed sequentially 11 months ago

README.md

Hack Platform Simulator

Introduction

Noam Nisan and Shimon Schocken introduced the “Hack” platform in their 2005 textbook “The Elements of Computing Systems” published by MIT press (https://www.nand2tetris.org/). The book takes students on a voyage of discovery by guiding them through building a complete computer platform, starting by using NAND gates to build more complex chips eventually culminating in a CPU and a complete software stack including an assembler, virtual machine translator, high-level language compiler and finally an operating system that can run programs such as Tetris. This process is informally known as Nand2Tetris and the book consists of 13 chapters, each chapter providing the necessary knowledge and then setting a project which, once implemented, acts as a layer in the computer system.

Hack is a simple 16-bit Von Neumann architecture that can be built from elementary NAND gates and Flip-Flops. The instruction set is extremely simple with a focus on hardware simplicity. Even basic operations like multiply and divide do not have hardware implementations and rely on software procedures. Programs are supplied to the computer in the form of replaceable ROM chips, similar to some cartridge-based games consoles. Most memory management is performed at the VM level and the program memory is read-only which leads to a simple single-tasking operating system that acts more like a standard library for the high-level language. Despite this the computer is powerful and building it is an extremely informative journey.

You can see my implementation of the Hack platform here: https://git.jbm.fyi/jbm/Nand2Tetris

What is this?

This is a simulator for the Hack plaform developed in rust capable of running Hack binaries. The goal is to slowly add modern CPU optimisations to the simulator and evaluate the performance effects of these optimisations. There will be a full write up on my website at https://portfolio.jbm.fyi/ after the project is complete.

Usage

cargo run --release -- [path to configuration]
For example: cargo run --release -- ../configurations/pong.sim

Of course, you can replace cargo run --release -- with a compiled binary. Note that only around 10% performance is acheived when compiling without the release flag. To build this binary, you must have the relevant SDL dev package installed for your environment.

You can find a number of configurations and binaries (along with source code and build tools) for the platform here: https://git.jbm.fyi/jbm/hack_toolchain

Example Configuration

[parameters]
[parameters]
path = "/media/jbm/JBM-WORK/CompSciMSc/Dissertation/toolchain/bin/big/Pong.hack"
mode = 32
clock_speed = 0
fps = 144
scale_factor = 2
debug = false
halt = true

[components]
control_unit = "basic"
a_instruction_unit = "basic"
memory_unit = "basic"
operand_unit = "basic"
arithmetic_logic_unit = "basic"
jump_unit = "basic"
write_back_unit = "basic"