| Microcode | instruction flags |
|---|---|
| Load to MBR | 00 |
| Write to MBR | 01 |
| Directly Write to MBR | 10 |
| Load to MBR | Select Loading |
|---|---|
| Register Output | 00 |
| RAM Output | 01 |
| ALU Result | 10 |
| Write to MBR | Select Writing |
|---|---|
| Register Data Input | 000 |
| Register Address Input | 001 |
| RAM Address Input | 010 |
| RAM Data Input | 011 |
| ALU A Input | 100 |
| ALU B Input | 101 |
| ALU Mode Input | 110 |
| PCR Input | 111 |
| Microprogram | Microcdes Binary... |
|---|---|
| write | 0010 0000 |
| save | (0000 0000, 0001 0001) |
| load | .... |
| jump | .... |
| beq | .... |
| bne | .... |
| bgt | .... |
| regwrite | .... |
| add | .... |
| sub | .... |
| mul | .... |
| div | .... |
| equ | .... |
| gth | .... |
| mv | .... |
| syscall | .... |
Let's assume you want to write 2 to $R0 and save the result to the RAM 0x00000000.
you could write assembly codes like below.
write 0000
write 0010
;MBR = 0000 0010
regwrite $R0
;$R0 = 0000 0010
save $R0, $R2
;RAM 0x0000 0000 = $R0Yes. It's just assembly code for our computer. but then, how work this? we have to make Control Unit to execute our Instructions.
IR Code don't just work by oneself. it work with Microprograms. and Microprograms are consists of Microcodes.
you need to design Microcode for Microprogramming.
Microprograms are depend on yours Hardware Architecture. our ISA Architecture is as the follow.
this is just simple, its'not exactly same. it's just for helping you to think about this.
We have to make 3 microprograms for The thing above. write and regwrite and add.
First, Read or Write or Etc... we will call this RWS Flag. and let's decide that 00 is Read, 01 is Write and 10 is Directly Write.
Then, let's make the write Microprogram. write is a speicial Microprogram to our CPU. it have to write directly MBR and we have only 8bits IR.. but we have to write 8bits to MBR. How can we do this?
the first idea is just that we use write twice. and makes a speical circuit for this.
if our IR bits are 0000 1111(write 1111) then our microcode is just 0010 0000. and machine is just working by the circuit. microcode don't need IR's data code. just go IR Register and take it.
next, lets make the regwrite. regwrite write Data from MBR to Register.
let's decide Select Instructon Flag that 0000 is Register SET. then our microcode is 0000 0000(save data from MBR to Register)
As a result, the Microprogram of Regwrite is 0000 0000
let's decide Select instruction Flag that 0001 is RAM.
to save data from register to RAM, first we have to load data from register to MBR and save MBR's data to RAM. 0000 0000(load data from Register to MBR) 0001 0001(write data from MBR TO RAM)
As a result, The Microprogram of save is (0000 0000, 0001 0001)
