nand2vm
1.0.0
このプロジェクトの目標は、NAND2TetrisのPythonバージョン、NAND2VMのNAND2Tetrisの完全なテストスイート、およびPythonバージョンのアセンブラーを作成することです。
BitArrayは、BitArray APIを使用してビットデータを操作するときに使用され、小さな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
1101構築するためにPython演算子を使用する唯一のゲート
> >> def Nand ( a : bool , b : bool ) -> bool :
... return not ( a and b )
> >> nand2vm . Nand ( True , True )
False
> >> nand2vm . Nand ( True , False )
True
> >> プロジェクト1実装:
プロジェクト2実装:
プロジェクト3実装:
プロジェクト6実装: