MARIE: A Simple Computer Based on slides from Jones & Bartlett
Chapter 4 Objectives • Learn the components common to every modern computer system. • Be able to explain how each component contributes to program execution, and understand both machine and control level details of a simple computer. • Understand a simple architecture invented to illuminate these basic concepts, and how it relates to some real architectures. • Know how the program assembly process works. COMP 228, Fall 2009
MARIE: A Simple Computer
1
4.2 CPU Basics • The computer’s CPU fetches, decodes, and executes program instructions. • The two principal parts of the CPU are the datapath and the control unit. – The datapath consists of an arithmetic-logic unit and storage units (registers) that are interconnected by a data bus. The latter can also connect to the main memory. – A datapath is a connection from some register/memory to other registers/memory, through bus/wires or ALU. – Various CPU components perform sequenced operations according to signals provided by its control unit.
COMP 228, Fall 2009
MARIE: A Simple Computer
2
4.2 CPU Basics • Registers are inside the CPU and hold data that can be readily accessed by other components. • They can be implemented using D flip-flops. – A 32-bit register requires 32 D flip-flops.
• The arithmetic-logic unit (ALU) carries out logical and arithmetic operations as directed by the control unit. • The control unit determines which actions to carry out according to the contents of its ‘von Neumann’ registers (Instruction Register, Program Counter, Status Register) by enabling some datapaths COMP 228, Fall 2009
MARIE: A Simple Computer
3
4.3 The Bus • The CPU shares data with other system components by way of a data bus. – A bus is a set of wires that simultaneously convey a single bit along each line.
• Two types of buses are commonly found in computer systems: point-to-point, and multipoint buses. This is a point-to-point bus configuration:
COMP 228, Fall 2009
MARIE: A Simple Computer
4
4.3 The Bus • Buses consist of data lines, control lines, and address lines. • While the data lines convey bits from one device to another, control lines determine the direction of data flow, and when each device can access the bus. • Address lines determine the location of the source or destination of the data. The next slide shows a model bus configuration.
COMP 228, Fall 2009
MARIE: A Simple Computer
5
4.3 The Bus
COMP 228, Fall 2009
MARIE: A Simple Computer
6
4.3 The Bus • A multipoint bus is shown below. • Because a multipoint bus is a shared resource, access to it is controlled through protocols, which are built into the hardware.
COMP 228, Fall 2009
MARIE: A Simple Computer
7
4.3 The Bus • In a master-slave configuration, where more than one device can be the bus master, concurrent bus master requests must be arbitrated. • Four categories of bus arbitration are possible:
– Daisy chain: Permissions – Distributed using self-detection: are passed from the highestDevices decide which gets the bus priority device to the lowest among themselves. [serially linking a set of I/O – Distributed using collisiondevices] detection: Any device can try to – Centralized parallel: Each use the bus. If its data collides with the data of another device, device is directly connected it tries again [e.g. Ethernet] to an arbitration circuit
COMP 228, Fall 2009
MARIE: A Simple Computer
8
4.3 The Bus ID vector Req
or
Arbiter Ack
Dev 1
Dev 2
Dev 3
Daisy-chained arbitration Arbiter
Req 1 Ack 1 Req 3 Ack 3
Centralized arbitration
COMP 228, Fall 2009
MARIE: A Simple Computer
9
Clicker 4.1 What is the main advantage of daisy-chained arbitration (over the other schemes)? A: B: C: D:
Easy to use Cheap Fast Something else
COMP 228, Fall 2009
MARIE: A Simple Computer
10
Clicker 4.2 Bus arbitration ensures: A: B: C:
Only one slave can become a data destination (receiver) Only one master can become a data source (sender) Identification of a master/slave pair
COMP 228, Fall 2009
MARIE: A Simple Computer
11
4.4 Clocks • Most computers are synchronous and contain at least one clock that synchronizes the activities of its components. • A clock cycle is the basic unit of time for moving data from a source to a destination (register), through wires or logic gates (that performs data transformation). • The clock frequency, measured in megahertz or gigahertz, determines the speed with which a basic register transfer is carried out. • Clock cycle time is the reciprocal of clock frequency. – An 800 MHz clock has a cycle time of 1.25 ns.
COMP 228, Fall 2009
MARIE: A Simple Computer
12
4.4 Clocks • Clock speed should not be confused with CPU performance. • The CPU time required to run a program is given by the general performance equation:
– We can improve CPU throughput when we reduce the number of instructions in a program, reduce the number of cycles per instruction, or reduce the number of nanoseconds per clock cycle. – Note that average cycle per instruction (instruction rate) is dependent on computer architecture and organization. COMP 228, Fall 2009
MARIE: A Simple Computer
13
Clicker 4.3 Consider the truthfulness of the following claims about two computers with identical ISA. 1. The computer with the faster clock executes each instruction faster. 2. The computer running a shorter version of the program (by a different compiler) will be faster. A: 1 and 2 are true B: Neither 1 nor 2 is true C: 1 is true D: 2 is true COMP 228, Fall 2009
MARIE: A Simple Computer
14
4.5 The Input/Output Subsystem • A computer communicates with the outside world through its input/output (I/O) subsystem. • I/O devices connect to the CPU through various interfaces. • I/O can be memory-mapped -- where the I/O device behaves like main memory from the CPU’s point of view. • I/O can be instruction-based, where the CPU has a specialized I/O instruction set that sees separate addresses from other instructions We study I/O in detail in chapter 7. COMP 228, Fall 2009
MARIE: A Simple Computer
15
4.6 Memory Organization • Computer memory consists of a linear array of addressable storage cells that are similar to registers. • Memory can be byte-addressable, or wordaddressable, where a word typically consists of two or more bytes, according to the system specification. • Memory is constructed of RAM chips, often referred to in terms of length × width. • Example: if the memory word size of the machine is 16 bits, then a 4M × 16 RAM chip gives us 4M locations each containing 16 bits (hence 8 Mbytes altogether) COMP 228, Fall 2009
MARIE: A Simple Computer
16
Memory Organization Address 0000
FFFF
Content (Hex) F0F0F0F0 ABCDEF0
ABCDEF0
Schematic Diagram of a 64K x 4 byte Memory
COMP 228, Fall 2009
MARIE: A Simple Computer
17
4.6 Memory Organization • How does the computer access a memory location corresponding to a particular address? • We observe that 4M can be expressed as 2 2 × 2 20 = 2 22 words. • The memory locations for this memory are numbered 0 through 2 22 -1. • Thus, the memory bus of this system requires at least 22 address lines. – The address lines “count” from 0 to 222 - 1 in binary. Each line is either “1” or “0”. Together, these 22 bits distinctly identify the location being accessed (addressed). COMP 228, Fall 2009
MARIE: A Simple Computer
18
Clicker 4.4 We use 128M x 1 byte RAM chips to build a 1G x 2 byte Memory system. The RAM chips can be arranged into a 2-D array consisting of: A: B: C: D:
8 columns and 2 rows 4 columns and 4 rows 16 columns and 2 rows 16 columns and 1 row
COMP 228, Fall 2009
MARIE: A Simple Computer
19
Clicker 4.5 For the previous memory system, we can use the k least significant bits of the memory address to select the column for read/write. The value of k is: A: 1 B: 2 C: 3 D: 4
COMP 228, Fall 2009
MARIE: A Simple Computer
20
Memory Organization RAM 7
RAM 6
RAM 15
RAM 14
::::
RAM 0
1 byte
2 byte data to/from processor
::::
RAM 8
1 byte
CS7
CS0
CS6
3-to-8 decoder
A29 A28 A27
CS = chip select: when set (=1) the corresponding chip is enabled to input/output the 1-byte data from memory A26…A0
These 27 address bits connect to the 27 address pins of each RAM chip A26 A25
:::::::
A0
30 address bits from processor COMP 228, Fall 2009
MARIE: A Simple Computer
21
4.6 Memory Organization • Physical memory usually consists of multiple RAM chip. • Access is more efficient when memory is organized into banks of chips with the addresses interleaved across the chips. This enables concurrent accesses. • With low-order interleaving, the low order bits of the address specify which memory bank contains the address of interest. • Accordingly, in high-order interleaving, the high order address bits specify the memory bank. The next slide illustrates these two ideas. COMP 228, Fall 2009
MARIE: A Simple Computer
22
4.6 Memory Organization
Low-Order Interleaving
High-Order Interleaving COMP 228, Fall 2009
MARIE: A Simple Computer
23
Clicker 4.6 If we use low-order interleaving in a 16-way interleaved memory system, and we wish to access memory location 0, 2, 4, 6, 8, ‌ How many memory banks can be active at the same time? A: 16 B: 8 C: 4 D: None of the above COMP 228, Fall 2009
MARIE: A Simple Computer
24
4.7 Interrupts • The execution of a program is may be affected when an event of higher-priority occurs. The CPU is alerted to such an event through an interrupt signal. • Interrupts can be triggered by I/O requests, arithmetic errors (such as division by zero), or when an invalid instruction is encountered. • Each interrupt is associated with a procedure that directs the actions of the CPU when an interrupt occurs. – Non-maskable interrupts are high-priority interrupts that cannot be disabled (masked-off). When it occurs, the CPU must suspend the program it is executing to take care of it. – An example is Power Failure. COMP 228, Fall 2009
MARIE: A Simple Computer
25
4.8 MARIE • We can now bring together many of the ideas that we have discussed to this point using a very simple model computer. • Our model computer, the Machine Architecture that is Really Intuitive and Easy, MARIE, was designed for the singular purpose of illustrating basic computer system concepts. • While this system is too simple to do anything useful in the real world, a good understanding of its functions will enable you to comprehend system architectures that are much more complex. COMP 228, Fall 2009
MARIE: A Simple Computer
26
4.8 MARIE Generally an instruction word contains: 1. An opcode that identifies the operation to be performed by the processor. 2. Identification of k (k > 0) operands involved. An operand can be in a register or in a memory location. Machines that restricts k to 1 is called a 1-address machine. Most contemporary machines are either 2- or 3-address machines.
COMP 228, Fall 2009
MARIE: A Simple Computer
27
4.8 MARIE The MARIE computer is a 1-address machine with the following characteristics: • • • • •
Binary, two's complement data representation. Fixed word length data and instructions. 4K words of word-addressable main memory. 16-bit data words. 16-bit instructions, 4 for the opcode and 12 for the address. • A 16-bit arithmetic logic unit (ALU). • Seven registers for control and data movement.
COMP 228, Fall 2009
MARIE: A Simple Computer
28
Clicker 4.7 How many distinct opcodes can MARIE support? A: B: C: D:
4 8 16 More than 16
COMP 228, Fall 2009
MARIE: A Simple Computer
29
4.8 MARIE MARIE’s seven registers are: • Accumulator, AC, a 16-bit register that holds a conditional operator (e.g., "less than") or one operand of a two-operand instruction. • Memory address register, MAR, a 12-bit register that holds the memory address of an instruction or the operand of an instruction. • Memory buffer register, MBR, a 16-bit register that holds the data after its retrieval from, or before its placement in memory. COMP 228, Fall 2009
MARIE: A Simple Computer
30
4.8 MARIE MARIE’s seven registers are: • Program counter, PC, a 12-bit register that holds the address of the next program instruction to be fetched and executed. This is the control flow pointer. • Instruction register, IR, which holds an instruction to be executed. • Input register, InREG, an 8-bit register that holds data read from an input device. • Output register, OutREG, an 8-bit register, that holds data that is ready for the output device. COMP 228, Fall 2009
MARIE: A Simple Computer
31
4.8 MARIE This is the MARIE architecture shown graphically.
COMP 228, Fall 2009
MARIE: A Simple Computer
32
4.8 MARIE • The registers are interconnected via an internal CPU bus within the CPU. • MBR, MAR, InReg and OutReg connect with the other components (memory, keyboard/display) via a system bus external to the CPU. • Additional point-to-point connections are also provided between the accumulator and the memory buffer register, and the ALU and the accumulator and memory buffer register to enhance performance. • This permits data transfer between these devices without use of the internal CPU bus. COMP 228, Fall 2009
MARIE: A Simple Computer
33
4.8 MARIE
This is the MARIE CPU internal shown graphically. The internal CPU bus is drawn in U-shape.
COMP 228, Fall 2009
MARIE: A Simple Computer
34
4.8 MARIE • A computer’s instruction set architecture (ISA) specifies the format of its instructions and the primitive operations that the machine can perform. • The ISA is an interface between a computer’s hardware and its software. • Many ISAs include hundreds of different instructions for processing data and controlling program execution. • The MARIE ISA consists of only thirteen instructions.
COMP 228, Fall 2009
MARIE: A Simple Computer
35
4.8 MARIE • This is the format of a MARIE instruction: • The fundamental MARIE instructions are:
COMP 228, Fall 2009
MARIE: A Simple Computer
36
MARIE ISA • • • • • • • • • • • • • • •
Suppose AC = F0F0, M[100] = 1010, PC = 200, InREG = 34 If M[200] contains the instruction below Instruction Consequence Case: Load 100 AC = 1010, PC = 201 Add 100 AC = F0F0 + 1010 = 0100, PC = 201 Subt 100 AC = F0F0 – 1010 = F0F0 + EFF0 = E0E0, PC = 201 Store 100 M[100] = AC = F0F0, PC = 201 Skipcond 000 PC = 202 (because AC is negative) Skipcond 400 PC = 201 (because AC is not equal to 0) Skipcond 800 PC = 201 (because AC is not positive) Jump 100 PC = 100 Input AC = 0034, PC = 201 Output OutREG = F0, PC = 201 Halt PC = 200 or 201 (returns control to system)
COMP 228, Fall 2009
MARIE: A Simple Computer
37
MARIE PROGRAM S1,
Count, One, H30, Sum, COMP 228, Fall 2009
Load Count Add One Store Count Input Subt H30 Add Sum Store Sum Skipcond 000 Jump S1 Halt Dec Dec 1 Dec 48 Dec 0
// AC = M[Count] // AC =+ AC // M[Count] = AC // AC = InREG // AC = AC – M[H30] // AC = AC + M[Sum] // M[Sum] = AC // PC =+ if AC < 0 // PC = S1 0
MARIE: A Simple Computer
38
4.8 MARIE • Load X contains the opcode ‘Load’ and the operand ‘X’ written symbolically. • In machine code, Load = 0001 (Hex 1), whereas X is a 12bit memory address. • Often a programmer can refer to this address X symbolically, and the assembler (translater) will transform it properly into an assigned memory location. • For example, if the assigned location for X is 3, then the instruction can be written equivalently as Load 3 or in hex notation 1003. COMP 228, Fall 2009
MARIE: A Simple Computer
39
4.8 MARIE • This is a bit pattern for a LOAD instruction as it would appear in the IR:
• We see that the opcode is 1 and the address from which to load the data is 3 (in decimal)
COMP 228, Fall 2009
MARIE: A Simple Computer
40
4.8 MARIE â&#x20AC;˘ This is a bit pattern for a SKIPCOND instruction as it would appear in the IR:
â&#x20AC;˘ We see that the opcode is 8 and bits 11 and 10 are 10, meaning that the next instruction will be skipped if the value in the AC is greater than zero. What is the hexadecimal representation of this instruction? COMP 228, Fall 2009
MARIE: A Simple Computer
41
4.8 MARIE • Each of our instructions actually consists of a sequence of smaller instructions called microoperations. Each micro-operation involves a datapath. • The exact sequence of micro-operations that are carried out by an instruction can be specified using register transfer language (RTL). • In the MARIE RTL, we use the notation M[X] to indicate the actual data value stored in memory location X, and ← to indicate the transfer of bytes to a register or memory location. COMP 228, Fall 2009
MARIE: A Simple Computer
42
4.8 MARIE • The RTL for executing the LOAD instruction is: MAR ← X MBR ← M[MAR] AC ← MBR
• Similarly, the RTL for executing the ADD instruction is: MAR ← X MBR ← M[MAR] AC ← AC + MBR
COMP 228, Fall 2009
MARIE: A Simple Computer
43
4.8 MARIE • Recall that SKIPCOND skips the next instruction according to the value of the AC. • The RTL for the this instruction is the most complex in our instruction set: If IR[11 - 10] = 00 If AC < 0 then else If IR[11 - 10] If AC = 0 then else If IR[11 - 10] If AC > 0 then COMP 228, Fall 2009
then PC ← PC + 1 = 01 then PC ← PC + 1 = 10 then PC ← PC + 1
MARIE: A Simple Computer
44
Clicker 4.8 What is the consequence in executing the skipcond 800 [i.e., 8800] instruction that is stored in memory location 100? Assume AC = FFFF (hex) A: B: C: D:
PC becomes 100 PC becomes 101 PC becomes 102 All of the above is possible
COMP 228, Fall 2009
MARIE: A Simple Computer
45
4.9 Instruction Processing • The fetch-decode-execute cycle is the series of steps that a computer carries out when it runs a program. • We first have to fetch an instruction from memory, and place it into the IR. • Once in the IR, it is decoded to determine what needs to be done next. • If a memory value (operand) is involved in the operation, it is retrieved and placed into the MBR. • With everything in place, the instruction is executed. The next slide shows a flowchart of this process. COMP 228, Fall 2009
MARIE: A Simple Computer
46
4.9 Instruction Processing
COMP 228, Fall 2009
MARIE: A Simple Computer
47
4.9 Instruction Processing • All computers provide a way of interrupting the fetch-decode-execute cycle. • Interrupts occur in cases such as when: – A user break (e.,g., Control+C) is issued – I/O is requested by the user or a program – A critical error occurs
• Interrupts can be caused by hardware or software. – Software interrupts are also called traps. COMP 228, Fall 2009
MARIE: A Simple Computer
48
4.9 Instruction Processing • Interrupt processing involves adding another step to the fetch-decode-execute cycle as shown below.
The next slide shows a flowchart of “Process the interrupt.” COMP 228, Fall 2009 MARIE: A Simple Computer
49
4.9 Instruction Processing
COMP 228, Fall 2009
MARIE: A Simple Computer
50
4.9 Instruction Processing • For general-purpose systems, it is common to disable all interrupts during the time in which an interrupt is being processed. – Typically, this is achieved by setting a bit in the flags register.
• Interrupts that are ignored in this case are called maskable. • Nonmaskable interrupts are those interrupts that must be processed in order to keep the system in a safe condition. COMP 228, Fall 2009
MARIE: A Simple Computer
51
4.9 Instruction Processing • Interrupts are very useful in processing I/O. • However, interrupt-driven I/O is complicated, and is beyond the scope of our present discussion. – We will look into this problem in more detail in Chapter 7.
• MARIE, being the simplest of simple systems, uses a modified form of programmed I/O. • All output is placed in an output register, OutREG, and the CPU polls the input register, InREG, until input is sensed, at which time the value is copied into the accumulator. COMP 228, Fall 2009
MARIE: A Simple Computer
52
4.10 A Simple Program â&#x20AC;˘ Consider the simple MARIE program given below. We show a set of mnemonic instructions stored at addresses 100 - 106 (hex):
COMP 228, Fall 2009
MARIE: A Simple Computer
53
Clicker 4.9 What is the consequence (change of program data/state) after executing the previous program? 1: PC = 103 2: M[106] = 001C 3: AC = 001C A: B: C: D:
All of the above 1 and 2 1 and 3 2 and 3
COMP 228, Fall 2009
MARIE: A Simple Computer
54
4.10 A Simple Program • Let’s look at what happens inside the computer when it performs the fetch-and-execute cycle of an instruction • This is the LOAD 104 instruction stored at location 100:
COMP 228, Fall 2009
MARIE: A Simple Computer
55
4.10 A Simple Program â&#x20AC;˘ Our second instruction is ADD 105 stored at location 101:
COMP 228, Fall 2009
MARIE: A Simple Computer
56
4.11 A Discussion on Assemblers • Mnemonic (symbolic) instructions, such as LOAD 104, are easy for humans to write and understand. • These mnemonic instructions are call assembly instructions. • Assemblers translate instructions that are comprehensible to humans into the machine (binary) language that is comprehensible to the hardware system – We note the distinction between an assembler and a compiler: In assembly language, there is a one-to-one correspondence between an executable mnemonic (assembly) instruction and its machine code. With compilers, this is not usually the case. COMP 228, Fall 2009
MARIE: A Simple Computer
57
4.11 A Discussion on Assemblers • Assemblers create an object program file from mnemonic source code in two passes (typically). • During the first pass, the assembler assembles as much of the program is it can, while it builds a symbol table that contains all symbols in the program that correspond to memory locations (addresses). These symbolic addresses appear in the first column of the source code. • During the second pass, the instructions are completed using the actual memory addresses from the symbol table.
COMP 228, Fall 2009
MARIE: A Simple Computer
58
4.11 A Discussion on Assemblers • Consider our example program (top). X, Y and Z
are symbolic locations. – Note that we have included two pseudo-ops HEX and DEC that direct the assembler to initialize some data locations with values.
• During the first pass, we have a symbol table and the partial instructions shown at the bottom.
COMP 228, Fall 2009
MARIE: A Simple Computer
59
4.11 A Discussion on Assemblers â&#x20AC;˘ After the second pass, the assembly is complete.
COMP 228, Fall 2009
MARIE: A Simple Computer
60
Clicker 4.10 Consider the sample program: S,
W,
Load Skipcond Halt Jump Dec
W 000 S 100
How many entries (rows) are there in the symbol table generated by the assembler? A: 1 B: 2 C: 3 D: 4 COMP 228, Fall 2009
MARIE: A Simple Computer
61
Clicker 4.11 How many pseudo-opâ&#x20AC;&#x2122;s (assembler directives) are there in the previous program? A: B: C: D:
1 2 3 4
COMP 228, Fall 2009
MARIE: A Simple Computer
62
4.12 Extending Our Instruction Set • So far, all of the MARIE instructions that we have discussed use a direct addressing mode. • This means that the address of the operand is explicitly stated in the instruction. • It is often useful to employ indirect addressing, where the address of the address of the operand is given in the instruction. – If you have ever used pointers in a program, you are already familiar with indirect addressing.
COMP 228, Fall 2009
MARIE: A Simple Computer
63
4.12 Extending Our Instruction Set • To help you see what happens at the machine level, we have included an indirect addressing mode instruction to the MARIE instruction set. • The ADDI instruction specifies the address of the address of the operand. The following RTL tells us what is happening at the register level: MAR ← X MBR ← M[MAR] MAR ← MBR ; one more round MBR ← M[MAR] AC ← AC + MBR COMP 228, Fall 2009
MARIE: A Simple Computer
64
Clicker 4.12 Suppose:
AC = 1000 M[100] = 200 M[200] = 400 What is the consequence of executing AddI 200? A: B: C: D:
AC = 1200 AC = 1400 AC = 1600 None of the above
COMP 228, Fall 2009
MARIE: A Simple Computer
65
4.12 Extending Our Instruction Set • Another helpful programming tool is the use of subroutines (procedures). • The jump-and-store instruction, JNS, gives us limited subroutine functionality. The details of the JNS instruction are given by the following RTL: MBR ← PC MAR ← X (i.e. IR[11-0]) M[MAR] ← MBR PC ← MAR PC ← PC + 1 COMP 228, Fall 2009
MARIE: A Simple Computer
Does JNS permit recursive calls?
66
Clicker 4.13 Suppose: PC = 400 What is the consequence of executing the instruction Jns 100? 1. PC = 100 2. M[100] = 401 A: B: C: D:
1 and 2 1 only. 2 only. None of the above.
COMP 228, Fall 2009
MARIE: A Simple Computer
67
Extending Our Instruction Set
• To allow control flow to go to a dynamically changed address (hence instruction), the Jump X instruction can be extended to become JumpI X. • Semantics of JumpI X (in RTL) MAR Í X MBR Í M[MAR] PC Í MBR
COMP 228, Fall 2009
MARIE: A Simple Computer
68
Using Jns and JumpI for Subroutine
:::::: S, X,
Jns ::::::
X
Dec 0 :::::: JumpI X ::::::
COMP 228, Fall 2009
//calls subroutine at X
//return address (S) saved here //return to caller indirectly
MARIE: A Simple Computer
69
4.12 Extending Our Instruction Set • Our last helpful instruction is the CLEAR instruction. • All it does is set the contents of the accumulator to all zeroes. • This is the RTL for CLEAR: AC ← 0 • We put our new instructions to work in the program on the following slide.
COMP 228, Fall 2009
MARIE: A Simple Computer
70
4.12 Extending Our Instruction Set 100 101 102 103 104 105 106 107 108 109 10A 10B 10C 10D
| | | | | |Loop | | | | | | | |
LOAD Addr STORE Next LOAD Num SUBT One STORE Ctr LOAD Sum ADDI Next STORE Sum LOAD Next ADD One STORE Next LOAD Ctr SUBT One STORE Ctr
COMP 228, Fall 2009
10E 10F 110 111 112 113 114 115 116 117 118 119 11A 11B
| | | |Addr |Next |Num |Sum |Ctr |One | | | | |
MARIE: A Simple Computer
SKIPCOND 000 JUMP Loop HALT HEX 118 HEX 0 DEC 5 DEC 0 HEX 0 DEC 1 DEC 10 DEC 15 DEC 2 DEC 25 DEC 30
71
4.13 A Discussion on Decoding • A computer’s control unit keeps things synchronized, making sure that bits flow to the correct components as the components are needed. • There are two general ways in which a control unit can be implemented: hardwired control and microprogrammed control. – With microprogrammed control, a small program is placed into read-only memory in the microcontroller. – Hardwired controllers implement this program using digital logic components.
COMP 228, Fall 2009
MARIE: A Simple Computer
72
4.13 A Discussion on Decoding • Your text provides a complete list of the register transfer language for each of MARIE’s instructions. • The micro-operations given by each RTL define the operation of MARIE’s control unit. • Each micro-operation consists of a distinctive signal pattern that is interpreted by the control unit and results in the execution of an instruction. – Recall, the RTL for the Add instruction is: MAR ← X MBR ← M[MAR] AC ← AC + MBR COMP 228, Fall 2009
MARIE: A Simple Computer
73
4.13 A Discussion on Decoding • Each of MARIE’s registers and main memory have a unique address along the datapath. • The addresses take the form of signals issued by the control unit. How many signal lines does MARIE’s control unit need? COMP 228, Fall 2009
MARIE: A Simple Computer
74
4.13 A Discussion on Decoding • Let us define two sets of three signals. • One set, P0, P1, P2, controls reading from memory or a register, and the other set consisting of P3, P4, P5, controls writing to memory or a register. The next slide shows a close up view of MARIE’s MBR. COMP 228, Fall 2009
MARIE: A Simple Computer
75
4.13 A Discussion on Decoding
This register is enabled for reading when P0=P1=1 and P2=0, and it is enabled MARIE: for writing when P3=P4=1 and P5=0 COMP 228, Fall 2009 A Simple Computer
76
4.13 A Discussion on Decoding • Careful inspection of MARIE’s RTL reveals that the ALU has only three operations: add, subtract, and clear. – We will also define a fourth “do nothing” state.
• The entire set of MARIE’s control signals consists of: – Register controls: P0 through P5. – ALU controls: A0 through A3 – Timing: T0 through T7 and counter reset Cr
COMP 228, Fall 2009
MARIE: A Simple Computer
77
4.13 A Discussion on Decoding • Consider MARIE’s Add instruction. It’s RTL is: MAR ← X MBR ← M[MAR] AC ← AC + MBR
• After an Add instruction is fetched, the address, X, is in the rightmost 12 bits of the IR, which has a datapath address of 7. • X is copied to the MAR, which has a datapath address of 1. • Thus we need to raise signals P2, P1, and P0 to read from the IR, and signal P3 to write to the MAR. COMP 228, Fall 2009
MARIE: A Simple Computer
78
4.13 A Discussion on Decoding • Here is the complete signal sequence for MARIE’s Add instruction:
A0
P0 P1 P2 P3 P0 P2 P0 P1 P2 P5 Cr
T0: T1: T2: T3:
MAR ← X MBR ← M[MAR] AC ← AC + MBR [Reset counter]
• These signals are ANDed with combinational logic to bring about the desired machine behavior. • The next slide shows the timing diagram for this instruction.. COMP 228, Fall 2009
MARIE: A Simple Computer
79
4.13 Decoding • Notice the concurrent signal states during each machine cycle: C0 through C3. P0 P1 P2 P3 P0 P2 A0 P0 P1 P2 P5 Cr
COMP 228, Fall 2009
T0: T1: T2: T3:
MAR ← X MBR ← M[MAR] AC ← AC + MBR [Reset counter]
MARIE: A Simple Computer
80
4.14 Real World Architectures • MARIE shares many features with modern architectures but it is not an accurate depiction of them. • In the following slides, we briefly examine two machine architectures. • We will look at an Intel architecture, which is a CISC machine and MIPS, which is a RISC machine. – CISC is an acronym for complex instruction set computer. – RISC stands for reduced instruction set computer. COMP 228, Fall 2009
MARIE: A Simple Computer
81
4.14 Real World Architectures • The classic Intel architecture, the 8086, was born in 1979. It is a CISC architecture. • It was adopted by IBM for its famed PC, which was released in 1981. • The 8086 operated on 16-bit data words and supported 20-bit memory addresses. • Later, to lower costs, the 8-bit 8088 was introduced. Like the 8086, it used 20-bit memory addresses. What was the largest memory that the 8086 could address? COMP 228, Fall 2009
MARIE: A Simple Computer
82
4.14 Real World Architectures • The 8086 had four 16-bit general-purpose registers that could be accessed by the half-word. • It also had a flags register, an instruction register, and a stack accessed through the values in two other registers, the base pointer and the stack pointer. • The 8086 had no built in floating-point processing. • In 1980, Intel released the 8087 numeric coprocessor, but few users elected to install them because of their cost. COMP 228, Fall 2009
MARIE: A Simple Computer
83
4.14 Real World Architectures • In 1985, Intel introduced the 32-bit 80386. • It also had no built-in floating-point unit. • The 80486, introduced in 1989, was an 80386 that had built-in floating-point processing and cache memory. • The 80386 and 80486 offered downward compatibility with the 8086 and 8088. • Software written for the smaller word systems was directed to use the lower 16 bits of the 32-bit registers. COMP 228, Fall 2009
MARIE: A Simple Computer
84
4.14 Real World Architectures • Current Pentium 4 running at 3.8 GHz is nearly 800 times faster than the 4.77 MHz of the 8086. • Speed enhancing features include multilevel cache and instruction pipelining. • Intel, along with many others, is incorporating many of the ideas of RISC architectures with microprocessors that are largely CISC.
COMP 228, Fall 2009
MARIE: A Simple Computer
85
4.14 Real World Architectures • The MIPS family of CPUs has been one of the most successful in its class. • In 1986 the first MIPS CPU was announced. • It had a 32-bit word size and could address 4GB of memory. • Over the years, MIPS processors have been used in general purpose computers as well as in games. • The MIPS architecture now offers 32- and 64-bit versions.
COMP 228, Fall 2009
MARIE: A Simple Computer
86
4.14 Real World Architectures • MIPS was one of the first RISC microprocessors. • The original MIPS architecture had only 55 different instructions, as compared with the 8086 which had over 100. • MIPS was designed with performance in mind: It is a load/store architecture, meaning that only the load and store instructions can access memory. • The large number of registers in the MIPS architecture keeps bus traffic to a minimum by keeping more program data in registers. • Locality of data enhances computer performance How does this design affect performance? COMP 228, Fall 2009
MARIE: A Simple Computer
87
Chapter 4 Conclusion • The major components of a computer system are its control unit, registers, memory, ALU, and data path. • A built-in clock keeps everything synchronized. • Control units can be microprogrammed or hardwired. • Hardwired control units give better performance, while microprogrammed units are more adaptable to changes. COMP 228, Fall 2009
MARIE: A Simple Computer
88
Chapter 4 Conclusion • Computers run programs through iterative fetchdecode-execute cycles. • Computers can run programs that are in machine language. • An assembler converts mnemonic code to machine language. • The Intel architecture is an example of a CISC architecture; MIPS is an example of a RISC architecture. COMP 228, Fall 2009
MARIE: A Simple Computer
89