This is a personal project which purpose is to learn computer architecture by implementing the Hack Computer.
Table of Contents
This is a personal project which purpose is to learn computer architecture by implementing the Hack Computer (Noam Nisan and Shimon Schocken. 2008. The Elements of Computing Systems: Building a Modern Computer from First Principles (History of Computing S.). The MIT Press).
The aforementioned book, a.k.a NandToTetris, aims to take the reader on a journey to build a simple but powerful 16-bit general-purpose computer. It gives you the knowledge and tools to gradually and modularly implement it from the ground up. The reader starts by building elementary logic gates, such as NOT, AND, OR, ..., and goes all the way until high-level applications, as the classic Tetris game, can be run on the computer that has been built.
I have only read the book until the 5th chapter in which the system hardware is already implemented and ready to run low-level code. Firstly, I have described the computer in a Hardware Description Language (HDL) by following the book instructions (check out computer description). Then, I have implemented the computer in Logisim, which is an educational software to simulate logic gates (check out the Logisim project). This book is awesome and presents many computer architecture fundamental concepts, I recommend it to everyone interested in computer science.
The computer description in HDL can be interpreted and tested by using the software suite provided by the book. But, its implementation in Logisim is a thing that I have done by myself, so let's see how you can get a local copy of that project and run it.
-
Go to this website and follow the instructions to install Logisim.
-
Clone this repo:
git clone https://github.com/VitorgsRuffo/Building-The-Hack-Computer.git
- Open Logisim and inside it open the "hack-computer.circ" file located at "/path/to/repository/Building-The-Hack-Computer/Hack Computer (Logisim)":
- Click on the Hack Computer chip:
- Go to the Simulate option on Logisim's menu and enable clock ticks:
- The computer will start to run the program that is preloaded in its ROM. After the first four intructions, value 10 gets loaded at RAM's 6th address. The 2 last instructions are there to avoid that the computer runs garbage instructions stored at subsequential ROM addresses, compromising the result of the actual program.
- By inspecting RAM chip we can see that the value 10 has actually been loaded at RAM's 6th address.
The book's 4th chapter defines the computer machine language. After understanding it you can write machine-level programs, load them into ROM chip and get the computer to run your program. For more information, check out the book.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Vitor G. S. Ruffo - LinkedIn - vitor.gs.ruffo@gmail.com