nand2vm
1.0.0
L'objectif de ce projet est de créer une version Python de Nand2tetris, NAND2VM inclut la suite de test complète de NAND2tetris et l'assembleur avec version Python.
BitArray est utilisé lors de la manipulation des données de bits, en utilisant l'API BitArray, nous pouvons rapidement créer un petit tableau de bits endian:
> >> 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
1101La seule porte utilisant l'opérateur Python à construire
> >> def Nand ( a : bool , b : bool ) -> bool :
... return not ( a and b )
> >> nand2vm . Nand ( True , True )
False
> >> nand2vm . Nand ( True , False )
True
> >> Implémentation du projet 1:
Implémentation du projet 2:
Implémentation du projet 3:
Implémentation du projet 6: