Professional Documents
Culture Documents
Design:
1. Program Counter
2. PC Adder
3. Instruction memory
4. Registers
5. Data memory
6. Arithmetic Logic Unit
7. ALU Control
8. Control Unit
9. Sign Extend
10. Shift Left – 2
11. Adders
12. Multiplexers
13. Concatenation unit
14. Logic gates
ALU Design:
The different ALU operations depend on the Control inputs from the ALU control.
1. 0000 – AND operations
2. 0001 – OR Operation
3. 0010 – ADD Operation – as in Load and Store instructions
4. 0110 – SUB Operation – as in BEQ and BNE instructions
5. 1100 – NOR Operation
6. 0111 – SLT – Set if less than
7. 1000 – Shift left Operation
8. 1001 – Shift right Operation
When the ouput is zero the Zero output bit is set to '1'.
ALU Control : The functionality of the ALU Control depends on the ALUop from the
Control Unit and/or on the Function Code (bits 5 – 0) of the instruction and the
corresponding ALU Control output bits are set.
When ALUop – 001 it is a BEQ / BNE instruction and the ALU Control lines are set to
001
When ALUop – 010 then it is a R-Format instruction, hence the ALU Control lines
depend on the function code ( bits 5 – 0) of the instruction. R-Format instructions include
add(32), sub(34), and(36), or(37), slt(42), sll(0), srl(2), jr(8). According to these function
codes the ALU control lines are set.
When ALUop – 011 then it is an ANDI operation and the control lines are set to 0000.
When ALUop – 100 then it is an ORI operation and the control lines are set to 0001.
When ALUop – 101 then it is an SLTI operation and the control lines are set to 0111.
We have used another output called the alujr from the ALU Control unit the use of which
is described in the next topic (Control Unit). The Alujr bit is set to '1' only if the
instruction is “jr” .
Control Unit:
The design of the control unit is the most important part of designing the architecture.
The control unit takes the bits 31-26 of the instruction( the output of the instruction
memory) and depending on those bits it sets the output signals.
Depending on the input ( OpCode ) to the Control Unit these above bits are set to 0s and
1s.
If the instruction Opcode is – 000011 – it is JAL – J format but PC+4 has to be written
into $ra. Hence for this there is a small modification in the design. To write into $ra we
give another input to the multiplexer that chooses the register to be written into. Hence
the multiplexer is now 3x1 and RegDst signal is 2 bits - 10. To select PC+4 to be written
into the destination we make the Multiplexer which chooses the data to be written into
the register as 4x1 and the forth input to it is the value PC+4 and MemtoReg = 11.
If the instruction Opcode is – 001010 – it is SLTI – I Format. ALUop is 101.
The final change that is to be made in the design is for JR instruction – R Format. In this
instruction the address to jump to is chosen from $ra. That is 'rs' in the instruction. Hence
to choose this we need to give another input to the multiplexer and hence made 3x1 and
to choose this at the multiplexer another output line from ALU Control is given – alujr
and is set to 1 for a JR instruction and 0 for all other instructions.
Changes to multiplexers :
1. The multiplexer to choose the Write data has been made a 4x1 multiplexer.
The inputs are Data read from Data Memory, ALU output, PC+4(for JAL)
and the output of the concatenation unit.
2. The Multiplexer which chooses the Register Destination has been made 3x1.
The inputs are rt, rd and 31($ra).
3. One of the multiplexer which chooses the value to be written into the PC has
been made 3x1. The inputs are PC+4, rs(for jr instruction) and Branch target
address.
ALU :
The implementation in the ALU depends on the ALU Control Lines from the ALU
control Unit.
The complete Architecture, State Tables and the simulation results have been provided.
Test Benches for each module/component have been used to check the functionality of
the component.