Memory Traffic
Memory Traffic
Memory Traffic
http://www.egr.unlv.edu/~b1morris/cpe300/
2
Outline
• Recap
• Addressing Modes
• Simple RISC Computer (SRC)
• Register Transfer Notation (RTN)
3
Example 2.1
• Evaluate a = (b+c)*d-e
• for 3- 2- 1- and 0-address machines
Example 2.1
3-Address 2-Address 1-Address 0-Address
add a, b, c load a, b lda b push b
mult a, a, d add a, c add c push c
Instructions
Bytes size
3-Address 2-Address 1-Address 0-Address
Instruction 30 28 20 23
Memory 27 33 15 15
Total 57 61 35 38
6
• 1-1/2 addresses
▫ Load/store have one long & one short address
▫ 2-operand arithmetic instruction has 3 half
addresses
8
Real Machines
• General registers offer greatest flexibility
▫ Possible because of low price of memory
• Most real machines have a mixture of 3, 2, 1, 0, 1-1/2
address instructions
▫ A distinction can be made on whether arithmetic
instructions use data from memory
• Load-store machine
▫ Registers used for operands and results of ALU
instructions
▫ Only load and store instructions reference memory
• Other machines have a mix of register-memory and
memory-memory instructions
9
Instructions/Register Trade-Offs
• 3-address machines have shortest code but large
number of bits per instruction
• 0-address machines have longest code but small
number of bits per instruction
▫ Still require 1-address (push, pop) instructions
• General register machines use short internal register
addresses in place of long memory addresses
• Load-store machines only allow memory addresses
in data movement instructions (load, store)
• Register access is much faster than memory access
• Short instructions are faster
10
Addressing Modes
• Addressing mode is hardware support for a useful
way of determining a memory address
• Different addressing modes solve different HLL
problems
▫ Some addresses may be known at compile time, e.g.
global vars.
▫ Others may not be known until run time, e.g. pointers
▫ Addresses may have to be computed
Record (struct) components:
variable base(full address) + const.(small)
Array components:
const. base(full address) + index var.(small)
• Possible to store constant values without using
another memory cell by storing them with or
adjacent to the instruction itself.
11
SRC Memory
• 232 bytes of memory address space
• Access is 32 bit words
▫ 4 bytes make up word, requires 4 addresses
▫ Lower address contains most significant bits
(msb) – highest least significant bits (lsb)
1000
W0 1001
Bits 31 23 15 7 0
W1 1002
Address 1001 1002 1003 1004
W2 1003
Value W0 W1 W2 W3
W4 1004
1005
16
Trade-off between
- Fixed instruction size
- Wasted memory space
Ch3 -
single instruction
per clock cycle
18
SRC Characteristics
• (=) Load-store design - only memory access through load/store
instructions
• (–) Operations on 32-bit words only (no byte or half-word
operations)
• (=) Only a few addressing modes are supported
• (=) ALU instructions are 3-registertype
• (–) Branch instructions can branch unconditionally or conditionally
on whether the value in a specified register is = 0, <> 0, >= 0, or <
0.
• (–) Branch-and-link instructions are similar, but leave the value of
current PC in any register, useful for subroutine return.
• (–) Can only branch to an address in a register, not to a direct
address.
• (=) All instructions are 32-bits (1-word) long.
• Note:
▫ No multiply instruction (can be done based on addition)
▫ Immediate subtract not needed since constant in addi may be negative
(take care of sign bit)
22
• SRC
lar r0, Label3 ;load branch target address into register r0
br r0 ;branch
…
Label3 … ;branch address
25
• SRC assembly
.org 0
Cost: .equ 125 ;define symbolic constant
.org 1000 ;next word loaded at address 100010
Pseudo-Operations
• Not part of ISA but assembly specific
▫ Known as assembler directives
▫ No machine code generated – for use by
assembler, linker, loader
• Pseudo-ops
▫ .org = origin
▫ .equ = equate
▫ .dx = define (word, half-word, byte)
27
Synthetic Instructions
• Single instruction (not in machine language)
that assembler accepts and converts to single
instruction in machine language
▫ CLR R0 andi r0, r0, 0
▫ MOVE D0, D1 or r1, r0, r0
(Other instructions possible besides and and or)
• Only synthetic instructions in SRC are
conditional branches
▫ brzr r1, r2 br r1, r2, 010
if R[2] = 0
28
Miscellaneous Instructions
• nop – no operation
▫ Place holder or time waster
▫ Essential for pipelined implementations
• stop
▫ Halts program execution, sets Run to zeros
▫ Useful for debugging purposes
29
<> Bit index: selects bit or bit range from named memory
n..m Index range: from left index n to right index m; can be decreasing
2-Way Multiplexer
• Data from multiple sources can be selected for
transmission
37
m-Bit Multiplexer
Open-Collector Bus
• Bus is a shared datapath (as in previous slides)
• Multiplexer is difficult to wire
▫ Or-gate has large number of inputs (m x #gated
inputs)
• Open-collector NAND gate to the rescue
41
Wired-OR Bus
• Convert AND to OR using DeMorgan’s Law
• Single pull-up resistor for whole bus
• OR distributed over the entire connection
43
Tri-State Gate
• Controlled gating
▫ Only one gate active at a time
▫ Undefined output when not active
44
Tri-State Bus
Chapter 2 Summary
• Classes of computer ISAs
• Memory addressing modes
• SRC: a complete example ISA
• RTN as a description method for ISAs
• RTN description of addressing modes
• Implementation of RTN operations with digital
logic circuits
• Gates, strobes, and multiplexers