nand2vm
1.0.0
เป้าหมายของโครงการนี้คือการสร้างรุ่น Python ของ Nand2Tetris, 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 ดำเนินการ: