We'll start with the Arithmetic and Logic Unit (the ALU). This unit implements arithmetic and logic operations, as the name suggests:
addition, subtraction, multiplication, and division;
and, or, not, nor, and xor;
comparison;
shifting.
In addition to the main ALU, there are three "mini-ALUs": one to add 4 to the program counter, another to compute a branch address, and the third to shift the contents of a branch immediate field.
The adder
The adder is given two 32-bit integers as inputs, and produces the sum as output.
You have already seen how one might go about designing an adder. Here's a quick review. Examining the truth table seems fruitless—there are 264 rows! Instead, we look for a way to break the problem down into smaller circuits that can be combined into the circuit we want. The standard addition-by-hand algorithm we learned in grade school provides a hint for how to do this.
Consider, for example, the addition of two 4-bit values a and b, producing a sum s.
a3 + a2 + a1 + a0
+ b3 + b2 + b1 + b0
------------------------
s3 + s2 + s1 + s0
We start by adding the least significant bits, computing a0 + b0 = s0. A second output will represent a potential carry into column 1; we'll call that c1. Here's the truth table.
a0 b0 s0 c1
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Adding in the second column from the right requires slightly different behavior, namely the use of an extra input—the carry from the first column. Here's its truth table.
a1 b1 c1 s1 c2
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Constructing a 32-bit adder out of 1-bit adders
One may observe that the 1-bit adder just designed for the second addition column works for the remaining columns as well. That is, the same structure can be used to produce sk and ck+1 from ak, bk, and ck, for k ranging from 1 to 31. The resulting circuit is diagrammed below.
In fact, the addition in the rightmost column need not be treated as a special case. The adders used for columns 1-31 can also be used in column 0, merely by providing an input of 0 as the carry-in.
This circuit is called a ripple adder, since carries "ripple" from the rightmost to the leftmost columns. The possibility of a rippling carry constrains the speed of the adder. P&H section B.6 describes an adder design that trades simplicity for speed.
One of the very important properties of this adder is that it works for unsigned numbers and signed numbers (2's complement). In fact, it doesn't even need to know which kind it is working on—it does just the same thing in either case. Addition is moving clockwise on the number wheel. Plug in a positive and a negative 4-bit number in the 4-bit adder that you built last week. Convince yourself it does the right thing.
Overflow
It is very useful to have the adder signal overflow when it occurs. This is one place where signed and unsigned arithmetic differs.
In adding unsigned values, detecting overflow is pretty obvious. If there is a carry out from the MSB there was an overflow. This is where you cross from FF...F to 00...0 on the number wheel.
The more interesting case is detecting overflow in addition of signed integers. If you add a positive and a negative number there cannot possibly be an overflow because the magnitude of A–B (for positive A and B) must be less than the larger of A and B.
When you add two positive signed values and an overflow occurs, there is no carry out. What happens instead?
Whenever you add two negative numbers there is a carry out since both have the sign bit on, so that is not what tells you there is an overflow. What does?
If you remember the number wheel, an overflow occurs when the result of the arithmetic operation crosses from the most positive numbers to the most negative, or vice versa. In other words, overflow occurs when adding two positive numbers produces a negative sum, or vice versa.
It is possible to detect the overflow using only the inputs and outputs of the most significant bit slice of your adder. Write down the truth table for the FA that forms the MSB of your adder. Add a 6th column that is overflow. Derive a boolean expression for the overflow. Can you reduce this to a single gate? Add this simple overflow detector to your 4-bit adder.
pls help I will thumbs up 4. Given the following Processor Datapath Latencies, Determine the addi...
6. Consider a datapath similar to the one in figure below, but for a processor that only has one type of instruction: unconditional PC-relative branch. What would the cycle time be for this datapath? PCSrc Add ALU Add result Shift +( left 2 Read register 1 ALUSrc, 4 ALU operation PCRead PC-address Read data 1 Registers Read data 2 MemWrite Zero ALU ALU-I Address MemtoReg Instruction register 2 Instruction | Write Read data-M register Write Lu memory Write Data data...
Question 5 0.25 pts What is the value of the MemWrite control signal? Question 6 0.25 pts What is the value of the ALUSrc control signal? Add Add Sum--(1 4 Shift left 1 Branch MemRead Instruction [6-0] ControMemtoReg MemWrite ALUSrc RegWrite Instruction [19-15]Read Read register 1 Read Read data! PCaddress Instruction [24-20] Zero ALU ALU result register 2 Instruction 31-0 Instruction [11-7 Read1 Address data | Write Read register daiaALU | M Instruction memory Write data Registers Write Data data...
3. Assume the processor data path show below. XE30 Add Add ALU result Shift left 2 RegDst Branch MemRead Instruction (31-26] RegSrc Control ALUOP Mem Write ALUSrc RegWrite PC Instruction (25-21) Read address Instruction (20-16] Instruction [31-0) Instruction instruction (15-11) memory Read register 1 Read data 1 Read register 2 Write Read register data 2 Write data Registers Zero ALU ALU result Read Address data OX OX3) 3x) Write Data data memory Instruction [15-0) 16 32 Sign- extend ALU control...
*For a clearer view of the datapath* Answer choices for all Consider the MIPS single cycle datapath shown below. Select the correct control signals that will be generated by the control unit for the following instruction: andi $t0,$t1,4 Instruction (25-01 Shin Jump address (31-0) - left 2) 28 PC +4 [31-28) XCS result left 2 RegDst Jump Branch MemRead Instruction (31-26] MemtoReg Control ALUOP MemWrite ALUSrc RegWrite Instruction (25-21] PC Read address Read register 1 Read Instruction (20-16] Read data...
PCSrc Add ALU Add result Shift left 2 Read register 1Read Read register 2 Write register Write data RegWrite Read ALU operation MemWrite data 1 MemtoReg Zero ALU ALUAddresS data Instruction Registers Read Read Instruction MI IMI memory WriteData data memory 16 Sign- MemRead extend 3, (4 points) For question#2, in the datapath as shown in Fig. 1, assume that one of the following control signals has a stuch-at-0 fault, meaning that the signal is always 0, regardless of its...
Add d Sum Shit left 1 B anch Instruction 16-0 Control emiaR nstruction [1915Read rogisar 1 Reat estruction [24-20 Zeru ALU ALU egster 2 Write Read 31-0retucion 11-7 Read dataM Instruction dala Registers Wrie Data data mem Instrucion (31032 imm Gen control Instrucion 130,14-12 4 pts) 74. Please fill in the following table, which specify how to set the control signals when executing the 2 instructions Instuction Branch Sd MemtoRe Src RegWrite MemRead MemWriteALUOp 01 Beq (4 pts)7.5. Please explain...
Consider the following MIPS assembly language instructions: addi $1, $2, 100 swr $1, 0($2): addi $rt, $rs, immediate # add immediate swr $rt, immedi ate ($rs) # store word write register These instructions are I-format instructions similar to the load word and store word instructions. The addi and swr instructions store a computed value to the destina- tion register $rt. The instructions do not require any physical hardware changes to the datapath. The effect of each instruction is given below....
it is the same question A block diagram of MIPS architecture is given below. What is the value of the control bit for each MUX during the execution of the given instruction? Note, you may use N/Aif MUX output is not usefu Add MUX 4 ALU Add, result Shift left 2 RegDst Branch MemRead Instruction (31-26] Control Memto Reg ALUOP Mem Write ALUSrc RegWrite Instruction [25-21) PC Read address Instruction (20-16] MUXT Read register 1 Read Read data 1 register...
Add 9 MUX 4 4 Addresult ALU Shift left 2 RegDst Branch MemRead Instruction (31-26) Control Memto Reg ALUOD MemWrite ALUSC RegWrite Instruction [25-21) Read PC Read address register 1 Read Instruction (20-16] MUX1 MUX Zero ALU ALU MUX3 M Instruction (31-0) Instruction memory Road Address data Read data 1 register 2 Write Read register data 2 Write data Registers result Instruction (15-11] Fox SX) Data Write data memory 16 32 Instruction (150) Sign- extend ALU control Instruction (5-0)
Question 4: Single Cycle Datapath Control (15 points) We wish to add the hardware support for a special R-type instruction jlr Jump and Link Register) to the single-cycle datapath below. Though this is an R-type instruction, but it is a special one that has the opcode being 000001 (instead of 000000), so the control unit will be able to differentiate this jlr instruction from the other R-type instructions and generate a special set of controls for this instruction. Opcode rs...