Controlling the data forwarding operations in the datapath

Previously, we studied this (simple) data path:

The datapath and other parts of the CPU are controlled by a number of control signals

The data path is controlled using various signals:

We will go over the signals one at a time next...

Signals that control the operation of the CPU

The 4 bits named  A  controls the multiplexors that select one of the 16 registers into the A-bus:

Signals that control the operation of our CPU

The 4 bits named  B  controls the multiplexors that select one of the 16 registers into the B-bus:

Signals that control the operation of our CPU

The 4 bits named  C  controls the decoder that select one of the 16 registers for writing:

Signals that control the operation of our CPU

The 1 bit named  EnC  controls whether or not a register will be written:

Signals that control the operation of our CPU

The 1 bit named  A-Select  controls the selection between MDR output and A-bus as first input of the ALU:

Signals that control the operation of our CPU

The 1 bit named  ALU  controls the operation that the ALU will perform (= part of the opcode)

Signals that control the operation of our CPU

The 1 bit named  SHF  controls the operation that the shifter will perform (= the other part of the opcode)

Signals that control the operation of our CPU

The 1 bit named  MAR Wr  controls whether or not the MAR register will be written:

Signals that control the operation of our CPU

The 1 bit named  MDR Wr  controls whether or not the MDR register will be written:

Machine instruction = a command to control the operation of the CPU
 

  • Machine instruction = a command that is executed by the CPU

  • A machine instruction is a binary number (= code) that tells (= commands) the CPU what to do.

  • The machine instruction format is determined by the CPU manufacturer

  • For our toy CPU, we will use a very simple instruction format:

      • We will use the values of all the control signals (and some additional signals) as machine instruction code !!!     

Format of Machine Instructions used in the simple CPU

The instruction format of the simple CPU that we will build:

 

Note:   we will not use (nor discuss) the signals given in red in the diagram above...

How a machine instruction controls the operation of the CPU

Bits in the IR are connected to the selection device (e.g.:mux) that it controls on the datapath:

How a machine instruction controls the operation of the CPU

Example: the field A (= source operand 1) in the machine instruction

How a machine instruction controls the operation of the CPU

Example: the field B (= source operand 2) in the machine instruction

How a machine instruction controls the operation of the CPU

Example: the field C (= destination operand) in the machine instruction

How a machine instruction controls the operation of the CPU

Example: the fields ALU and SHIFT (= opcode) in the machine instruction

Example of how a machine instruction controls the execution by the CPU

Sample machine instruction: (see binary number inside IR)

Example of how a machine instruction controls the execution by the CPU

The A-field and B-field will forward R0 and R6 onto the A- and B-buses:

Example of how a machine instruction controls the execution by the CPU

The AMux bit will select data from the A-bus to be forwarded to the ALU input:

Example of how a machine instruction controls the execution by the CPU

The ALU and SHIFT bits will select the ADD and NO SHIFT operations:

Example of how a machine instruction controls the execution by the CPU

The C and EnC bits will update the register R1 with the output value from the ALU:

Example of how a machine instruction controls the execution by the CPU

In other words, the machine code instructs the CPU to perform: add r1, r0, r6 !!!

DEMO
 

  • Students who took CS355 in the past have contructed the following simulation of the datapath that was discussed

  • You can run the simulation with this command:

       /home/cs355001/demo/datapath/cs355-demo-dp1      

    It's a bit complicated to work with this simulator; so I will explain it in class to to work with it.