three instructions. four registers. — 16-bit instructions...

Post on 30-Apr-2020

6 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Really Simple RS0 Processor

— Three instructions. Four registers.— 16-bit instructions, 8-bit bus.— Built in Logisim.— For demonstration purposes only

— This is wasteful in terms of transistors. Designed to keep things straightforward and easy to understand.

RS0 Processor

Instruction Format

— First 8 bits are— 2 bits opcode— 2 bits destination register— 2 bits source register 0— 2 bits source register 1

— Opcodes are— 00 for load immediate— 10 for addition— 11 for subtraction

RS Instruction Cycle

— Fetch, wait, store result, then back to the top.— This is implemented in a finite state machine (three

states, two bits)

The Control Unit

RS Fetch

— The current program counter is used to index into memory. An instruction is fetched, and stored in the Instruction Register. At the same time, the next instruction address (current program counter plus one) is stored into the PC.

RS Execute

— Next step. We wait. In a real circuit, it would take some time for the decoder to extract the bits from an instruction, and for an ALU to do a computation.

RS Store

— Finally, we enable write for the register file, storing either an immediate value, or the result computed by the ALU.

— And then? Do the next instruction.

The ALU

The Decoder

Simple instruction processing. The first bit will determine if the instruction is a load, or if we're doing an ALU operation. That bit will go to a mux, where we select between bits from the instruction, or from the ALU.

Second bit goes to the ALU (selecting ADD or SUBTRACT), and the remaining bits go to the register file.

The Decoder

Register File

Four 8-bit registers, with inputs for DR, R0, R1. We can read from any of the four registers at any time. Write enable will store an incoming result in the register indicated by DR.

Register File

Example

Load register 1 with value 15

00 01 00 00: (Opcode, R1, source registers ignored)

00001111 : (15 in binary)

Convert to hex: 100F

Example

Add R2 to R3, result to R1

10 01 10 11: (Opcode, R1, R2, R3)

00000000: (Immediate is ignored)

Convert to hex: 9B00

Example

Subtract R0 from R3, result to R2

11 10 11 00: (Opcode, R2, R3, R0)

00000000: (Immediate is ignored)

Convert to hex: EC00

Coding Exercise

r0 = 4;r1 = 10;r2 = r0 + r1;r3 = r1 - r0;

r0 = 4

Opcode: 00 00 00 00Immediate: 00000100Instruction in hex: 0x0004

r1 = 10

Opcode: 00 01 00 00Immediate: 00001010Instruction in hex: 0x100a

r2 = r0 + r1

Opcode: 10 10 00 01Immediate: 00000000Instruction in hex: 0xA100

r3 = r1 - r0

Opcode: 11 11 01 00Immediate: 00000000Instruction in hex: F400

top related