Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/summergift/nand2everything
Building a Complete Computer System from Scratch and build something fun on it.
https://github.com/summergift/nand2everything
assembler compiler computer-science virtual-machine
Last synced: about 2 hours ago
JSON representation
Building a Complete Computer System from Scratch and build something fun on it.
- Host: GitHub
- URL: https://github.com/summergift/nand2everything
- Owner: SummerGift
- License: mit
- Created: 2020-07-30T13:52:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T12:56:33.000Z (about 1 year ago)
- Last Synced: 2023-09-29T16:55:47.429Z (about 1 year ago)
- Topics: assembler, compiler, computer-science, virtual-machine
- Language: Java
- Homepage:
- Size: 78 MB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nand2Everything
Inspired by the **One Life One Chip** program, in which NUST 16 graduates participated, I decided to make a chip of my own and implement **Assembler**, **Virtual Machine**, **High Level Language**, **High Level Language Compiler** and an **Operating System** on top of it. It sounds crazy :), but it works, what can't be done in the software world, let's build a new one.
The original idea for this came to me one weekend afternoon when I first learned about the theory of origin of artificial neural networks (deep learning), also known as perceptual machines. In my subsequent explorations, I learned that two layers of perceptual machines could theoretically be used to build a computer. This is because it has been shown that a two-layer perceptron (strictly speaking, a perceptron that uses a nonlinear sigmoid function for the activation function) can represent an arbitrary function.
The principle behind this can be understood simply as follows: a computer can be reproduced simply by combining it with a non-gate, and a non-gate can be implemented using a perceptron. In other words, if a computer can be realized by combining with non-gates, then a computer can be represented by combining perceptual machines, and the combination of perceptual machines can be represented by superimposing multiple layers of single-layer perceptual machines.
This discovery sparked my curiosity so much that I decided to take action and make my own computer system, which is really awesome and I can't wait!
Why the name nand2everything, meaning, it all starts with the simplest of gates and non-gates, and then builds the entire computer system of everything. Of course, purely out of intense curiosity, in the final stage I will definitely try to run RT-Thread on my own chip as well (and then I suddenly realize that this is a very difficult thing to do, and seems to require rewriting a C compiler), but maybe I can add some abstraction layers to it to achieve this.
## First Stage
The projects that have been completed are as follows:
### [Project 1 Boolean Logic](01)
- [x] And16 Or16 Not16
- [x] MUX16
- [x] DMUX16### [Project 2 Boolean Arithmetic](02)
- [x] HalfAdder
- [x] FullAdder
- [x] Add16
- [x] ALU### [Project 3 Sequential Logic](03)
- [x] 16-bit Register
- [x] Program Counter
- [x] RAM8 - RAM16K### [Project 4 Machine Language](04)
- [x] Machine Language
- [x] Input/Output### [Project 5 Computer Architecture](05)
- [x] Memory
- [x] CPU
- [x] Controller
- [x] Computer### [Project 6 Assembler](06)
- [x] AssemblerNow I have completed the first phase of the construction process from the NAND gate to a complete computer, and wrote an assembler for it, which greatly satisfied my curiosity. It is really exciting :)
## Second Stage
From now on, I plan to use java to develop the following projects, first to develop the VM, next is a high-level language compiler targeting VM code, and finally, develop an operating system for the first stage computer.
### [Project 7 VM Ⅰ: Stack Arithemetic](07)
- [x] Stack Arithmetic
- [x] Memory AccessI start using Java to develop a program for project7, add more fun and challenge to the journey :) The project7 has been finished now, even the code writing with java is not so elegant,but it still open a new window for me, cool!
### [Project 8 VM II: Program Control](08)
This project is about design stack-based mechanisms for handling nested subroutine calls of procedural or object-oriented languages.
- [x] Program Flow
- [x] Function CallsNow project 8 has been finished, it takes me a lot of effort to handle the recursion call. The problem is about -1 is great than 0 or not. Human will think -1 is less than zero, but the computer won't, the computer uses complement to represent numbers, so it will think -1 is great than 0, so when the recursion meet -1, it will go on the loop but not exit the recursion. So, this point should be noticed when implementing VM translator.
All right, let's go to the next project.
### [Project 9 High-Level Language](09)
I am going to learn how a programming language is designed and implemented in project 9. Suddenly I realized that if we can understand the principle of designing and implementation, it means we can get a deep understanding of many programming languages.
Finally finished project 9, I wrote an applet introducing Chinese cities using jack, a programming language of my own design, keep up the good work!
### [Project 10 Compiler I: Syntax Analysis](10)
Project 10, the compiler front-end, was a big challenge for me. Understanding lexical parsing and syntactic parsing and implementing them by hand was not an easy task, but in any case, completion is more important than perfection.
### [Project 11 Compiler II: Code Generation](11)
Now I start to finish the second part of the compiler, code generation, which is the conversion of the abstract syntax tree compiled on the front end of the compiler into code that can actually run on the virtual machine.
It took me four Sundays to finished the project11. I'm happy to be able to build a working compiler from scratch.
### [Project 12 Operating System](11)
Start to write an operating system for hack platform.