Com sys lab/control unit that works with registers

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
มาจาก com sys lab

ใช้เทมเพลตใหม่ ในแบบฝึกหัดนี้ control unit จะเชื่อมโยงกับส่วนอื่น ๆ ซับซ้อนขึ้น อ่าน instruction set ของ CPU ได้ที่นี่

หมายเหตุ มีการแก้ op-code format ของ ADD และ SUB (เพื่อไม่ให้ชนกับ NOP = 0x00)

Load to $0, Store from $0

เพื่อทดสอบการออกแบบ control unit ในส่วนนี้เราจะใช้โค้ดในการเตรียมค่า register และคำสั่งใน instruction memory ดังด้านล่าง

  // set register $1 = 1
  reg.set(1,1);

  // set instruction memory
  rom.set(0,0x11);   // ADD $1     $0 = 1
  rom.set(1,0x8b);   // STA $3     $3 = 1
  rom.set(2,0x19);   // SUB $1     $0 = 0
  rom.set(3,0x13);   // ADD $3     $0 = 1
  rom.set(4,0x13);   // ADD $3     $0 = 2
  rom.set(5,0x8c);   // STA $4     $4 = 2
  rom.set(6,0x14);   // ADD $4     $0 = 4
  rom.set(7,0x19);   // SUB $1     $0 = 3
  rom.set(8,0x8d);   // STA $5     $5 = 3
  rom.set(9,0x84);   // LDA $4     $0 = 2
  rom.set(10,0x1d);  // SUB $5     $0 = -1 = 0x0f
  rom.set(11,0x8c);  // STA $4     $4 = 0xf

Unconditional short jump

Jump if zero

Load immediate