LMC Flashcards
components of LMC
- mailboxes: 3 digits –> 100 is max
- counter: 2 buttons- 1 increments and other resets to 00
- calculator: 3 digits: 0-9, +, - buttons, flag for -ve results
- input/output trays: input by user, output sent to user
routine in LMC
- looks at counter for mailbox number
- increments counter by 1
- goes to mailbox + reads 3 digits
- completes action indicated by digits
- restarts…
how do instructions work
3 digits: first is opcode (instructions), last digits are operand (mailbox number)
opcode 1
add: go to specified mailbox, read 3 dig number at address, go to calculator and add number to that on calculator
opcode 2
subtract: go to specified mailbox, read 3 dig number at address, go to calculator and subtract number from that on calculator
opcode 3
store: go to calculator, read 3 dig value, go to specified mailbox and store value there (overriding currently stored value)
opcode 5
load: go to mailbox specified in instruction, read in the 3 dig number, and enter into calculator (overriding current value)
opcode 6
branch: set program counter to the 2 address specified in instruction, and start fetch of instruction
opcode 7
branch on zero: check calculator, if value = 0, set program counter to address specified in instruction and start fetch else continue with next instruction as normal
opcode 8
branch on positive: check calculator, if +ve (inc 0), set program counter to address specified in instruction and start fetch else continue with next instruction as normal
instruction 901
input: go to IN tray, read 3 dig number there, go to calculator and enter value there. only read one input slip, then remove it, any others are used for future visits
instruction 902
output: go to calculator, read 3 digit value there and leave slip with value on OUT tray
opcode 0
break
fetch
find the instruction to execute: reads program counter, goes to mailbox at that address in instruction, reads 3 dig value
execute e.g. store
target address remembered. 3 digits in calculator read, 3 digits written in mailbox at target address. program counter incremented
von neumann
- same memory for instructions and data
- memory is addressed linearly: there is a number for every mailbox
- memory addressed by location: contents is irrelevant
- instructions executed sequentially unless branch or reset
harvard
-separate memory for instructions and data:
-avoids potential for malware and bugs from self-modifying code
-simpler to read and analyse code
-quicker to execute as can access instructions and data simultaneously
modern processors have split cache so best of harvard and VN
five major components of a CPU
- memory (RAM)
- registers
- ALU
- control unit
- buses
memory (RAM)
mailboxes
registers
special memory locations that can be accessed very fast and are manipulated directly by the CU 1-128 bits: includes program counter (PC), instruction register (IR), accumulator
have a defined purpose and wired to perform that purpose
holds binary values temporarily for storage, manipulation, calculations
ALU
calculator
buses
bundles of tiny wires- electrical conductors i.e. lines carrying signals- that carry data between components: address, data, control, power
- -carries data between different points on CPU
- carries data between CPU and main memory/computer peripherals*
control unit
responsible for directing flow of data and instructions within the CPU- compromised of multiplexor and decoder
accumulator
register part of the ALU. holds data + interim and final results of calculations + data to be transferred between different memory locations + (I/O+memory)
registers int the CU
PC, IR, flags
PC
holds the address of the next instruction to be executed
IR
holds the instruction currently being executed
flags
1 bit memory to keep track of special conditions- grouped together in 1+ status registers
e.g. arithmetic carry, power failure, internal computer error, overflow
memory address register
holds address of the memory location to which data is to be written to
only written to
memory data register
holds value that is being stored to or retrieved from a memory location addressed by MAR
written to and from
types of bus
point to point- carries signal between specific source and specific destination
broadcast- carries signals to many different devices
bus interface bridges- allows communication between buses e.g. peripheral control interface bus, external bus, universal serial bus
translate cab.bc (subscript 3)
from units left then from radix right:
13^0 + 0 3^1 + 2* 3^2
+ 13^-1 + 23^-2
(a = 0, b = 1, c = 2)
group of
4 bits, 8 bits, 16 bits, 32 bits, 64 bits
4 = nibble 8 = byte 16 = half word 32 = word 64 = double word size of word = CPU dependent, some have 32/64 bit words
why hexadecimal
- more compact
- easier to read and write than binary
- easy to convert between binary and hex
converting dec to binary
repeatedly div by 2 until 0 or 2 is reached, the remainder is the binary digit (from radix point left) e.g. 13(10) to binary: 13 div 2 = 6 rem 1 6 div 2 = 3 rem 0 3 div 2 = 1 rem 1 1 div 2 = 0 rem 1 therefore answer is 1101
converting dec fraction to binary
repeatedly multiply fractional part by 2 until fractional part = 0, if result >= 1 then binary digit = 1. (from radix point right) e.g. 0.8125(10) to binary: 0.8125 * 2 = 1.625 (1) 0.625 * 2 = 1.25 (1) 0.25 *2 = 0.5 (0) 0.5 * 2 = 1 (1) therefore = 0.1101(2)
overflow error
when a computer attempts to handle a value too large for it. triggers the status register, but can cause errors.
binary multiplication
- just like long multiplication for decimal numbers
- efficiently achieved using left shifts and add operations
negative representation of numbers
sign and magnitude, ones complement, twos complement, adding a bias
sign and magnitude
left most bit is a flag bit, 1 = -ve, 0 = +ve
two representations for 0: 0000 0000, 1000 0000
binary arithmetic is messy
ones complement
flip all bits, left most bit is still a flag bit
two representations for 0: 0000 0000, 1111 1111
binary addition is a bit simpler
twos complement
flip all bits and add 1, left most bit is still a flag bit
one representation for 0 (1111 1111 = -1)
binary arithmetic is much simpler
adding a bias (negative binary representation)
add a bias of ((2^k-1) -1) then store in normal binary.
allows storage of numbers -((2^k-1) -1) –> (2^k-1)
higher order bit does not indicate sign
used for floating point storage
negative subtraction
twos complement the second number and add
overflow is ignored
floating point representation
sign bit + exponent + mantissa
exponent
a number between -126 and 127, stored with a bias + 127 so number stored is between 0 and 255
0 and 255 special meanings
0 exponent + 0 mantissa = 0
0 exponent + non 0 mantissa = subnormal numbers
255 exponent + 0 mantissa = +/- infinity
255 exponent + non 0 mantissa = not a number
mantissa
e.g. 1.01…. binary number scaled so that leading 1 preceding radix point, don’t store leading 1 (assume its there)
store only the 23 digits of the fractional part
e.g. translate 0 sign bit + 124 exponent + 1.25 mantissa
0 = +ve
124 - 127 = -3 exponent
1.25 mantissa
therefore overall = 1.25*2^-3 = 1.25/8 =0.15625
translate -12.375 to floating point representation
1100.011 (2)
for leading 1: 1.100011 * 2^3
mantissa: 100011000…
exponent: 3+127 = 130 (10) = 1000 0010
floating point issues.
rounding error- cannot represent all numbers e.g. 0.1
have to limit to certain number of binary digits
floating point operations result in…
FP number closest to the answer
underflow/overflow level
underflow level = 2^-126 (-126 = smallest number that can be represented by exponent)
overflow level = (2-2^-23) * 2^127 (23 = number of digits of mantissa)
ariane 5 issue and how to overcome
overflow error, could not convert 64 bit FP to 16 bit signed integer
overcome by check if number outside range before conversion: if too large then set at a max value
transistor
electrically controlled switch: two ports (drain and source) are connected depending on voltage of a 3rd port (gate)
nMOS transistor
when g = 0, switch is OFF d is not connected to s
g = 1, switch is ON, d is connected to s
(see image L5)
pMOS transistor
when g = 0, switch is ON, s is connected to d
g = 1, switch is OFF, s is not connected to d
(see image L5)
most common transistor
MOSFET: metal oxide semiconductor field effect transistor
element used is silicon
most common element used in MOSFET and why
silicon: semiconductor since conductivity changes over many orders of magnitude depending on small changes in levels of dopants
- poor conductor of electricity since all 4 outer electrons involved in bonding
dopants
impurities providing extra electrons or electron holes increasing conductivity
n-type silicon
overall negative charge, the dopant added is Arsenic, it has an extra electron not involved in bonding which can carry charge
p-type silicon
overall positive charge, the dopant added is boron- it is short an electron so leaves a positive electron hole which can move around the lattice
diode
at a junction between p-type and n-type silicon, current can only flow from p-type to n-type
what happens at a junction of n-type and p-type silicon
electrons in the n-type region and electron holes in the p-type region cancel each other out, creating a ‘depletion region’
there are no mobile charge carriers in this region
how is binary addition implemented
using gates implementing boolean algebra
AND algebraic expression
Y = A . B (dot in centre)
OR algebraic expression
Y = A + B
NOT algebraic expression
Y = A- (line above A)
p-type and n-type junction:
positive voltage applied to p and negative voltage applied to n
electron holes in p-type attracted towards n-type
electrons in n-type attracted towards p-type
depletion region squeezed out and current flows
p-type and n-type junction:
negative voltage applied to p and positive voltage applied to n
electron holes in p-type repelled by the n-type and electrons in the n-type repelled by the p-type
depletion region expands and creates a barrier to current flow
issue at p -type and n-type junction trends
trends break down at sufficient voltage