Title: Chapter 4.1 From Code To Hardware
1Clark UniversityComputer Science DepartmentCSCI
140 Computer OrganizationFrom Code To Hardware
Professor Jerry Breecher 2004
2The Plan
- We start with code.
- From that code we get a 32-bit equivalent binary
representation. - The binary maps what the hardware looks like.
- The hardware reads each of those fields.
- The hardware performs an operation.
3We Start With Code
- This is code that mimics the following C
program. - main( )
-
- printf( "Hello World\n" )
-
-
- .text
- .globl main
- main
- la a0, hello
- ori v0, 0, 4 li v0, 4
- add t0, t1, t2
- syscall
- jr ra
- .data
- hello
4From that code we get a 32-bit Equivalent Binary
Representation.
- 0x00400020 0x3c021001 lui 2, 4097 12
la a0, hello - 0x00400024 0x34440000 ori 4, 2, 0
- 0x00400028 0x34020004 ori 2, 0, 4 14
ori v0, 0, 4 - 0x0040002c 0x012a4020 add 8, 9, 10 14
add t0,t1,t2 - 0x00400030 0x0000000c syscall 15
syscall - 0x00400034 0x03e00008 jr 31 16
jr ra
0 1 2 a 4 0 2 0
0000 0001 0010 1010 0100 0000 0010 0000
0 9 10 8
0 32
000000 01001 01010 01000 00000 100000
5What the hardware looks like.
Selector
Selector
Input bits
Outputs
0
0
Input
Output
31
31
The 5 selector wires can choose one of the 32
inputs voltages and send it to the output.
The 5 selector wires choose which of the 32
outputs will get the input voltage.
6What the hardware looks like.
This multiplexor is equivalent to 32 of those on
the previous page
Bit 0
Bit 31
Selector
Bit 0
Bit 31
Input words
0
Word 0
Output
Word 31
31
End View
End View
Side View
Now, each of the 32 inputs has 32 bits. There
are 32 x 32 bits in and 1 x 32 bits out.
Each of these input words COULD be a register!
7What the hardware looks like.
- ALU
- On this and the next few pages, we look at
increasingly complicated forms of ALU. - These pictures are taken from Figs 4.14, 4.17,
4.18, 4.19 in the text.
A 1-bit ALU that performs AND, OR, and ADDITION.
8What the hardware looks like.
Causes set on Less operation.
A 1-bit ALU that performs AND, OR, and
ADDITION. The possible inputs are a, b, and b
9What the hardware looks like.
A 32-bit ALU that performs AND, OR, and
ADDITION. This is made up of 32 of the sub-pieces
weve just examined.
10What the hardware looks like.
11What the hardware looks like.
Op
Select
5 wires
R0
6 wires
MUX To ALU
R8
A
B
MUX To ALU
ALU
c
ovf
Out
MUX From ALU
R31
12What the hardware looks like.
Op
R0
MUX To ALU
R8
A
B
MUX To ALU
ALU
Out
MUX From ALU
R31
13The hardware reads each of those fields.
0 9 10
8 0 32
000000 01001 01010 01000 00000 100000
R0
MUX To ALU
R8
A
B
MUX To ALU
ALU
Out
MUX From ALU
R31