https://github.com/mlouielu/nand2vm
nand2vm - pure python implement of nand2tetris Hack platform
https://github.com/mlouielu/nand2vm
nand2tetris operating-system os python virtual-machine
Last synced: 2 months ago
JSON representation
nand2vm - pure python implement of nand2tetris Hack platform
- Host: GitHub
- URL: https://github.com/mlouielu/nand2vm
- Owner: mlouielu
- License: bsd-3-clause
- Created: 2017-07-03T10:05:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-04T10:39:52.000Z (almost 8 years ago)
- Last Synced: 2024-12-30T03:33:18.061Z (4 months ago)
- Topics: nand2tetris, operating-system, os, python, virtual-machine
- Language: Assembly
- Homepage:
- Size: 378 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/mlouielu/nand2vm)
[](https://coveralls.io/github/mlouielu/nand2vm?branch=master)
nand2vm - pure Python implement nand2tetris
-------------------------------------------The goal of this project is to create a Python version of nand2tetris,
nand2vm include the full test suite of nand2tetris, and assembler with python version.Fundamental Elements
--------------------### BitArray
BitArray is used when manipulate bit data, using BitArray API,
we can quickly create a small endian bit array:```python
>>> import nand2vm
# Init from list using big endian
>>> b = nand2vm.BitArray([True, True, False, True])
>>> b
1101
>>> b[0]
True
>>> b[1] # Internal using small endian
False
>>> b.data
[True, False, True, True]# Init from integer, default using 16 bits
>>> b = nand2vm.BitArray(-1)
>>> b # 16 bits 2's complement
1111111111111111# Init from string
>>> b = nand2vm.BitArray('1101')
>>> b
1101
```### Nand gate
The only gate using python operator to construct
```python
>>> def Nand(a: bool, b: bool) -> bool:
... return not (a and b)>>> nand2vm.Nand(True, True)
False
>>> nand2vm.Nand(True, False)
True
>>>
```How To Start
------------Project 1 implement:
* gate.not_g.Not
* gate.and_g.And
* gate.or_g.Or
* gate.xor.Xor
* gate.mux.Mux
* gate.mux.DMux
* gate.and_g.Not16
* gate.and_g.And16
* gate.or_g.Or16
* gate.mux.Mux16
* gate.or_g.Or8Way
* gate.mux.Mux4Way16
* gate.mux.Mux8Way16
* gate.mux.DMux4Way
* gate.mux.DMux8WayProject 2 implement:
* gate.adder.ha
* gate.adder.fa
* gate.adder.Add16
* gate.adder.Inc16
* gate.alu.ALUProject 3 implement:
* seq.bit.Bit
* seq.register.Register
* seq.ram.RAM8
* seq.ram.RAM64
* seq.ram.RAM512
* seq.ram.RAM4K
* seq.ram.RAM16K
* seq.pc.PCProject 6 implement:
* assembler