COA Final Merged
COA Final Merged
Chapter 3
Structured Computer Organization
(6th_Edition)
TANENBAUM
Memory: Latches
Setting S (i.e., making
S, for Setting the latch, and
it 1) switches the
R, for Resetting (i.e.,
state from 0 to 1
clearing) it
Figure 3-21. (a) NOR latch in state 0. (b) NOR latch in state 1.
(c) Truth table for NOR.
Memory: Latches
(Two NAND gates)
Memory: Latches
clock pulse
This time shifting just means that the D latch will be activated at a fixed delay
after the rising edge of the clock, but it has no effect on the pulse width
I3
Used as an
when the amplifier
clear signal
CLR goes to
0, all the flip-
flops are
forced to
their 0 state
The register accepts an 8-bit input value (I0 to I7) when the clock CK
transitions
Figure 3-27. An 8-bit storage register constructed from
eight single-bit flip-flops.
Memory Organization (2a)
Write OP: CK is
enabled loading
Four word-select
the input data
AND gates form
into flip-flops
a decoder
Read OP: CK is
disabled and
none of the flip- Read OP: AND
flops is modified gates tied to the
Q bits of the
selected word
are enabled
CS OE RD A0 A1
(a) 1 1 0 1 0
(b) 1 1 1 1 0
Assume that Q=1 for all flip flops in the following 4x3 memory. In the
diagrams below, mark all gates that will be outputting a 1 given the
following sets of inputs:
Memory Organization (4)
Option 1
Option 2
A’B + AB’
Revision: Chapter 3 - Exercise 14
• An n-bit adder can be constructed by cascading n full
adders in series, with the carry into stage i, Ci , coming
from the output of stage i − 1. The carry into stage 0,
C0, is 0.
Use the same circuit, but replace the AND gate in the pulse generator by a
NOR gate. The only time both inputs will be low is just after the falling edge.
Revision: Chapter 3 - Exercise 21
The 4 × 3 memory of Fig. 3-28 uses 22 AND gates and three OR gates. If
the circuit were to be expanded to 256 × 8, how many of each would be
needed?
Revision: Chapter 3 - Exercise 21
The 4 × 3 memory of Fig. 3-28 uses 22 AND gates and three OR gates. If
the circuit were to be expanded to 256 × 8, how many of each would be
needed?
The design uses two AND gates for chip enable logic plus two AND gates
per word select line plus one AND gate per data bit. For a 256 × 8 memory
this comes to 2 + 512 + 2048 = 2562 AND gates. The circuit also uses one
OR gate for each bit in the word; hence eight of them would be needed.
CPU Chip Control Pins
• Bus control
• Interrupts
• Bus arbitration
• Coprocessor signaling
• Status
• Miscellaneous
CPU Chips
Reading from memory takes 15 nsec from the time the address is stable
Figure 3-38. (a) Read timing on a synchronous bus
(100MHz --> 10 nsec bus cycle).
Synchronous Buses (2)
MREQ’ indicates that memory (as opposed to an I/O device) is being accessed
RD’ is asserted for reads and negated for writes
Figure 3-38. (b) Specification of some critical times.
Asynchronous Buses
What happens if two or more devices all want to become bus master at the same time?
Figure 3-40. (a) A centralized one-level bus arbiter using daisy
chaining. (b) The same arbiter, but with two levels.
Bus Arbitration (2)
1) Wired-
OR line
2) Asserted by
the current bus
master
To acquire the bus, a device first checks to see if the bus is idle and the
arbitration signal it is receiving, IN, is asserted
Only one device will have IN asserted and OUT negated. This device
becomes bus master, asserts BUSY and OUT, and begins its transfer.
INTerrupt
Acknowledge
The Core i7 processor can carry out up to four instructions at once, making it a 4-
wide superscalar machine.
Each processor has a 32-KB level 1 (L1) data cache and a 32-KB level 1
instruction cache. Each core also has its own 256-KB level 2 (L2) cache. All
cores share a single level 3 (L3) unified cache, the size of which varies from 4 to
15 MB
The Core i7’s Logical Pinout
Allow 1333 million
transactions per
second
peripherals to the
Bus Signals
Connects
CPU
A general-purpose
switch for
connecting chips
using serial links
Chapter 3
The Microarchitecture Level
Chapter 4
Reference from TANENBAUM’s book
Structured Computer Organization (6th
Edition)
Contemporary Multilevel Machines (2)
...
The set of instructions carried out
interpretively by the micro-programmer
or hardware execution circuits
Data
Stack
Macroinstr.
Microprogram
5
MEMORY
MAR
MBR
CPU Main Memory
0
System 1
2
PC MAR Bus
Instruction
Instruction
Instruction
IR MBR
I/O AR
Data
Execution
unit Data
I/O BR Data
Data
PC = Program counter
Buffers IR = Instruction register
MAR = Memory address register
MBR = Memory buffer register
I/O AR = Input/output address register
I/O BR = Input/output buffer register
set of
microinstr.
Read/Write
from/to
Current microinst.
Memory
in MIR register
Addr[8]
8
Microinstructions (1)
Functional Signal Groups:
9 Signals to keep track of the next address (8 for data + 1 bit for jump).
9 Signals to control writing data from C bus into registers.
4 Signals to enable registers onto B bus for ALU input.
8 Signals to control ALU and shifter functions.
3 Signals to indicate memory read/write/fetch via MAR/MDR.
3 Signals to indicate JAM options for branching.
Microinstructions (3)
Groups of signals:
...but why are all these jumps required to determine the next microinstruction ?
In case of conditional jumps (if..then..else) we normally need two jump addresses as parameter.
To uniform the microinstruction format all instructions must have the same length:
either we make all microinstructions contain two addresses (-> waste of space) or
(better solution) we specify only one address and compute the second one as
Addr + Constant Value (in Mic-1 we have: Constant Value = 0x100)
JMPC is used to jump to the address specified by MBR, which, as we will see, contains
the opcode of the macroinstruction. Note that the microinstructions for each
macroinstruction M are stored starting from the position determined by the
opcode of M.
Example. The opcode of the macroinstruction BIPUSH is 0x10. This means that the
corresponding microinstructions start at address 0x10 in the control store.
11
Microinstruction Control: The Mic-1 (1)
13
ALU, Registers, Buses and Control
Signals
Control Signals
9 for reading and 9 for writing the registers
To and 8 for ALU/Shifter and 3 for read/write/fetch
from main
memory Nine 32-bit registers
MAR: Memory Address Register
MDR: Memory Data Register
PC: Program Counter
SP: Stack Pointer
…
One 8-bit register
MBR: Memory Buffer Register
A bus : drives data from register H to the ALU
B bus : drives data from one register to the ALU
C bus : drives data from the ALU to registers
ALU
with 6 control signals, two additional outputs:
N tests for negative numbers and
Z tests for zero;
and a shifter:
SLL8 to shift the content left by 8 bits (logical shift)
SRA1 shifts the content right by one bit (arith.
shift) 1
Microprogram Registers
Shifter (SHFT)
There are two possible shift operations. The first shifts the value
from the ALU 8 bits to the left with zero fill (SLL shift Left
Logical). The second shifts the value in the ALU one bit to the
right with sign extension (Shift Right Arithmetic). Sign extension
means that the high order bit prior to the shift will be copied into
the vacated high order bit position following the shift right. The
value displayed in the shifter is the value after the specified shift
operation is performed. If there is no shift operation, the value
in the shifter will be the same as the value displayed in the
ALU.
Mic-1 Memory Operations
•Two ports into memory
• 32 bit port
• 8 bit port
•32-bit port: (Data Cache interface)
• MAR - Memory Address register specifies the memory
address to use for a memory operation (LOAD or STORE)
• MDR - Memory Data Register serves as destination or source
for LOAD and STORE operations
• note that you cannot put the MAR contents on the B bus
•8-bit port: (Instruction Cache interface)
• PC - Program Counter serves as the address pointer into
memory
• MBR - Memory Buffer Register serves as destination for
memory contents (i.e., opcodes and their other fields)
Data Path Synchronization
1
0 5 6 7
2
Each
5 microinstruction
is executed in one
cycle !
1 2 3 4
4
0 5 6 7
G
0 7
o If JMPC is set, the 8 MBR bits are bitwise ORed with the 8 low-
order bits of the NEXT ADDRESS field coming from the current
microinstruction. The result is sent to MPC
o MPC is not loaded until the registers it depends on (MBR, N, and
Z) are ready. High Bit
JAMN JAMZ
Output
0 0 NEXT_ADDRESS[8]
0 1 NEXT_ADDRESS[8] + Z
1 0 NEXT_ADDRESS[8] + N
1 1 NEXT_ADDRESS[8] + Z + N
Microinstruction Control: The Mic-1 (5)
constants, strings,
PC = PC+1 results in a
and pointers to
fetch of the next byte
other areas of
(address of next
memory (name of
instruction).
functions)
stores variables
during the lifetime
of the invocation
Local variables do not have absolute memory addresses. Variables are referred
to by giving their offset (distance) from LV
Figure 4-8. Use of a stack for storing local variables. (a) While A
is active. (b) After A calls B. (c) After B calls C. (d) After C and B
return and A calls D (A,B,C,D are considered as procedures)
Stacks (2)
Suppose, for example, that before calling B, A has to do the
computation:
a1 = a2 + a3;
Pop two words off the stack to
execute the instruction
Result pushed
back onto the
stack
1012
All the branch instructions, if taken, adjust the value of PC by the size of their (16-bit signed)
offset. This offset is added to the address of the opcode.
It is assumed that i is local variable 1 (0x01), j is local variable 2 (0x02), and k is local variable
3 (0x03).
A reference (pointer)
to the object to be Address of old
called PC and old LV of
the caller method
if exists
Executing IRETURN
• Deallocates space used by returning method
• Restores stack to former state except
–OBJREF (Link ptr) and parameters are popped off the stack
–Returned value placed on top of stack
The IJVM Instruction Set (4)
BIPUSH 3
ISTORE i
L1: ILOAD i
IFEQ L2
IINC i -1
GOTO L1
L2: HALT
Ex: Code Segment using Standard Output
Ex: Code Segment using Standard Output
Ex: Constants
Syntax:
.constant
constant1 value1
constant2 value2
.end-constant
Notes: Global constants are declared in the .constant section at the beginning of the file.
The value of the constant can be given as a hexadecimal number (must be prefixed with
"0x"), an octal number (must be prefixed with "0"), or a decimal number (no prefix).
Declared constants may then be referred to by name, or by an instruction expecting a
constant as a parameter (i.e. LDC_W constant_name ). For example:
Ex: Constants
http://www.ontko.com/mic1/jas.html
.constant
one 1
start 32 // this program displays all the printable ASCII
stop 126 values 32..126
.end-constant
.main
LDC_W start
next: DUP
OUT // output the current character
DUP
LDC_W stop
ISUB
IFEQ done // exit if we've reached the end
LDC_W one
IADD
GOTO next // increment and do the next one
done: POP
HALT
.end-main
Ex: ADDING AN INSTRUCTION TO THE IJVM ISA BY
MODIFYING THE MIC-1 MICROPROGRAM.
(If you understand the problem statement, you’re halfway there.)
In this exercise, we will extend the capabilities of the Mic-1 machine by modifying the
definition of its control store to include a new instruction. Then we will add the details for
this instruction into the definition file for the ijvmasm assembler. Finally we’ll write some
.jas code that exercises the new instruction, and run it in the simulator to make sure it
works.
The instruction we will add is COM, for complement. The instruction will calculate the
one’s complement of the word on the stack and push it back on the stack.
The microcode for this is fairly straightforward. The point of this exercise is to walk
through all the steps, to set you up for doing some more interesting microprograms.
com1 MDR = TOS = NOT TOS // calc 1s compl, save in TOS and MDR
com2 MAR = SP = SP+1; wr; goto Main1 // set MAR from SP, write, recycle
Revision Exercises
How long does a 200 MHz Mic-1 take to execute the Java
statement i=j+k;? Give your answer in nanoseconds.
JAVA Code Micro-instructions
ILOAD j main1 + iload(5) =6
ILOAD k main1 + iload(5) =6
IADD main1 + iadd(3) =4
ISTORE i main1 + istore(6) =7
Chapter 4