nand2vm
1.0.0
이 프로젝트의 목표는 NAND2TETRIS의 Python 버전을 만드는 것입니다.
BitArray는 비트 데이터를 조작 할 때 사용됩니다. BitArray API를 사용하여 작은 엔디 언 비트 어레이를 신속하게 만들 수 있습니다.
> >> 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
1101Python 연산자를 사용하는 유일한 게이트
> >> 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 구현 :