marie
DESCRIPTION
MARIE: A Simple Computer Based on slides from Jones & Bartlett Chapter 4 Objectives • Be able to explain how each component contributes to program execution, and understand both machine and control level details of a simple computer. • Know how the program assembly process works. MARIE: A Simple Computer 1 COMP 228, Fall 2009TRANSCRIPT
![Page 1: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/1.jpg)
MARIE: A Simple Computer
Based on slides from Jones & Bartlett
![Page 2: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/2.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 1
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.
![Page 3: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/3.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 2
4.2 CPU Basics
• The computer’s CPU fetches, decodes, and executes program instructions.
• The two principal parts of the CPU are the datapathand 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.
![Page 4: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/4.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 3
• 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
4.2 CPU Basics
![Page 5: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/5.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 4
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:
![Page 6: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/6.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 5
• 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.
4.3 The Bus
![Page 7: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/7.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 6
4.3 The Bus
![Page 8: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/8.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 7
• 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.
4.3 The Bus
![Page 9: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/9.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 8
– Distributed using self-detection:Devices decide which gets the bus among themselves.
– Distributed using collision-detection: Any device can try to use the bus. If its data collides with the data of another device, it tries again [e.g. Ethernet]
– Daisy chain: Permissions are passed from the highest-priority device to the lowest [serially linking a set of I/O devices]
– Centralized parallel: Each device is directly connected to an arbitration circuit
• 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:
4.3 The Bus
![Page 10: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/10.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 9
4.3 The Bus
orReq
Ack
Req 1Ack 1
Arbiter
Arbiter
Req 3Ack 3
Daisy-chained arbitration
Centralized arbitration
Dev 1 Dev 2 Dev 3
ID vector
![Page 11: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/11.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 10
Clicker 4.1
What is the main advantage of daisy-chained arbitration (over the other schemes)?
A: Easy to useB: CheapC: FastD: Something else
![Page 12: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/12.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 11
Clicker 4.2
Bus arbitration ensures:
A: Only one slave can become a data destination (receiver)
B: Only one master can become a data source (sender)
C: Identification of a master/slave pair
![Page 13: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/13.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 12
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.
![Page 14: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/14.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 13
• 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.
4.4 Clocks
![Page 15: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/15.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 14
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 trueB: Neither 1 nor 2 is trueC: 1 is trueD: 2 is true
![Page 16: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/16.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 15
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.
![Page 17: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/17.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 16
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 word-addressable, 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)
![Page 18: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/18.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 17
Memory Organization
Address Content (Hex)0000
FFFF
F0F0F0F0ABCDEF0
ABCDEF0
Schematic Diagram of a 64K x 4 byte Memory
![Page 19: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/19.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 18
• 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).
4.6 Memory Organization
![Page 20: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/20.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 19
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: 8 columns and 2 rowsB: 4 columns and 4 rowsC: 16 columns and 2 rowsD: 16 columns and 1 row
![Page 21: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/21.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 20
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: 1B: 2C: 3D: 4
![Page 22: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/22.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 21
Memory Organization
3-to-8 decoder
RAM 0RAM 6RAM 7
RAM 8RAM 14RAM 15
::::
::::
A29 A28 A27 A26 A25 A0:::::::
These 27 address bits connect to the 27 address pins of each RAM chip
30 address bits from processor
2 byte data to/from processor
1 byte
1 byte
CS0CS6CS7
CS = chip select: when set (=1) the corresponding chip is enabled to input/output the 1-byte data from memory A26…A0
![Page 23: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/23.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 22
• 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.
4.6 Memory Organization
![Page 24: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/24.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 23
Low-Order Interleaving
High-Order Interleaving
4.6 Memory Organization
![Page 25: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/25.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 24
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: 16B: 8C: 4D: None of the above
![Page 26: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/26.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 25
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.
![Page 27: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/27.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 26
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.
![Page 28: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/28.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 27
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.
4.8 MARIE
![Page 29: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/29.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 28
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.
![Page 30: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/30.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 29
Clicker 4.7
How many distinct opcodes can MARIE support?
A: 4B: 8C: 16D: More than 16
![Page 31: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/31.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 30
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.
![Page 32: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/32.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 31
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.
![Page 33: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/33.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 32
4.8 MARIE
This is the MARIE architecture shown graphically.
![Page 34: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/34.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 33
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.
![Page 35: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/35.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 34
4.8 MARIE
This is the MARIE CPU internal shown graphically. The internal CPU bus is drawn in U-shape.
![Page 36: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/36.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 35
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.
![Page 37: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/37.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 36
4.8 MARIE
• This is the format of a MARIE instruction:
• The fundamental MARIE instructions are:
![Page 38: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/38.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 37
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)
![Page 39: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/39.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 38
MARIE PROGRAM
S1, Load Count // AC = M[Count] Add One // AC =+ ACStore Count // M[Count] = ACInput // AC = InREGSubt H30 // AC = AC – M[H30] Add Sum // AC = AC + M[Sum]Store Sum // M[Sum] = ACSkipcond 000 // PC =+ if AC < 0Jump S1 // PC = S1Halt
Count, Dec 0One, Dec 1H30, Dec 48Sum, Dec 0
![Page 40: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/40.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 39
• Load X contains the opcode ‘Load’ and the operand ‘X’written symbolically.
• In machine code, Load = 0001 (Hex 1), whereas X is a 12-bit 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.
4.8 MARIE
![Page 41: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/41.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 40
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)
![Page 42: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/42.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 41
4.8 MARIE
• This is a bit pattern for a SKIPCOND instruction as it would appear in the IR:
• 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?
![Page 43: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/43.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 42
4.8 MARIE
• Each of our instructions actually consists of a sequence of smaller instructions called micro-operations. 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.
![Page 44: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/44.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 43
4.8 MARIE
• The RTL for executing the LOAD instruction is:
• Similarly, the RTL for executing the ADD instruction is:
MAR ← XMBR ← M[MAR]AC ← AC + MBR
MAR ← XMBR ← M[MAR] AC ← MBR
![Page 45: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/45.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 44
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 thenIf AC < 0 then PC ← PC + 1
else If IR[11 - 10] = 01 thenIf AC = 0 then PC ← PC + 1
else If IR[11 - 10] = 10 thenIf AC > 0 then PC ← PC + 1
![Page 46: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/46.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 45
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: PC becomes 100B: PC becomes 101C: PC becomes 102D: All of the above is possible
![Page 47: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/47.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 46
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.
![Page 48: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/48.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 47
4.9 Instruction Processing
![Page 49: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/49.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 48
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.
![Page 50: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/50.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 49
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.”
![Page 51: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/51.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 50
4.9 Instruction Processing
![Page 52: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/52.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 51
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.
![Page 53: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/53.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 52
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.
![Page 54: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/54.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 53
• Consider the simple MARIE program given below. We show a set of mnemonic instructions stored at addresses 100 - 106 (hex):
4.10 A Simple Program
![Page 55: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/55.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 54
Clicker 4.9
What is the consequence (change of program data/state) after executing the previous program?
1: PC = 1032: M[106] = 001C3: AC = 001C
A: All of the aboveB: 1 and 2C: 1 and 3D: 2 and 3
![Page 56: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/56.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 55
• 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:
4.10 A Simple Program
![Page 57: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/57.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 56
• Our second instruction is ADD 105 stored at location 101:
4.10 A Simple Program
![Page 58: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/58.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 57
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.
![Page 59: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/59.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 58
• 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.
4.11 A Discussion on Assemblers
![Page 60: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/60.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 59
• 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.
4.11 A Discussion on Assemblers
![Page 61: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/61.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 60
• After the second pass, the assembly is complete.
4.11 A Discussion on Assemblers
![Page 62: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/62.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 61
Clicker 4.10Consider the sample program:
S, Load WSkipcond 000HaltJump S
W, Dec 100How many entries (rows) are there in the symbol table generated by
the assembler?A: 1B: 2C: 3D: 4
![Page 63: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/63.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 62
Clicker 4.11
How many pseudo-op’s (assembler directives) are there in the previous program?
A: 1B: 2C: 3D: 4
![Page 64: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/64.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 63
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.
![Page 65: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/65.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 64
• 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 ← XMBR ← M[MAR]MAR ← MBR ; one more roundMBR ← M[MAR]AC ← AC + MBR
4.12 Extending Our Instruction Set
![Page 66: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/66.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 65
Clicker 4.12
Suppose: AC = 1000M[100] = 200M[200] = 400
What is the consequence of executing AddI 200?
A: AC = 1200B: AC = 1400C: AC = 1600D: None of the above
![Page 67: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/67.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 66
• 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 ← PCMAR ← X (i.e. IR[11-0])M[MAR] ← MBRPC ← MAR PC ← PC + 1
Does JNS permit recursive calls?
4.12 Extending Our Instruction Set
![Page 68: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/68.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 67
Clicker 4.13
Suppose: PC = 400What is the consequence of executing the instruction Jns 100?1. PC = 1002. M[100] = 401
A: 1 and 2B: 1 only.C: 2 only.D: None of the above.
![Page 69: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/69.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 68
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 XMBR M[MAR]PC MBR
![Page 70: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/70.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 69
Using Jns and JumpI for Subroutine
::::::Jns X //calls subroutine at X
S, ::::::
X, Dec 0 //return address (S) saved here::::::JumpI X //return to caller indirectly::::::
![Page 71: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/71.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 70
• 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:
• We put our new instructions to work in the program on the following slide.
AC ← 0
4.12 Extending Our Instruction Set
![Page 72: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/72.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 71
100 | LOAD Addr101 | STORE Next102 | LOAD Num103 | SUBT One 104 | STORE Ctr105 |Loop LOAD Sum 106 | ADDI Next107 | STORE Sum 108 | LOAD Next 109 | ADD One10A | STORE Next 10B | LOAD Ctr10C | SUBT One10D | STORE Ctr
10E | SKIPCOND 00010F | JUMP Loop110 | HALT111 |Addr HEX 118112 |Next HEX 0113 |Num DEC 5114 |Sum DEC 0115 |Ctr HEX 0116 |One DEC 1117 | DEC 10118 | DEC 15119 | DEC 211A | DEC 2511B | DEC 30
4.12 Extending Our Instruction Set
![Page 73: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/73.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 72
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 andmicroprogrammed 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.
![Page 74: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/74.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 73
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 ← XMBR ← M[MAR]AC ← AC + MBR
![Page 75: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/75.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 74
4.13 A Discussion on Decoding
• Each of MARIE’sregisters 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?
![Page 76: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/76.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 75
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.
![Page 77: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/77.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 76
4.13 A Discussion on Decoding
This register is enabled for reading when P0=P1=1 and P2=0, and it is enabled for writing when P3=P4=1 and P5=0
![Page 78: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/78.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 77
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
![Page 79: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/79.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 78
4.13 A Discussion on Decoding
• Consider MARIE’s Add instruction. It’s RTL is:MAR ← XMBR ← 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 datapathaddress 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.
![Page 80: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/80.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 79
4.13 A Discussion on Decoding
• Here is the complete signal sequence for MARIE’sAdd instruction:
P0 P1 P2 P3 T0: MAR ← XP0 P2 T1: MBR ← M[MAR]
A0 P0 P1 P2 P5 T2: AC ← AC + MBRCr T3: [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..
![Page 81: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/81.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 80
4.13 Decoding
P0 P1 P2 P3 T0: MAR ← XP0 P2 T1: MBR ← M[MAR]
A0 P0 P1 P2 P5 T2: AC ← AC + MBRCr T3: [Reset counter]
• Notice the concurrent signal states during each machine cycle: C0 through C3.
![Page 82: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/82.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 81
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.
![Page 83: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/83.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 82
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?
![Page 84: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/84.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 83
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.
![Page 85: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/85.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 84
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.
![Page 86: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/86.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 85
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.
![Page 87: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/87.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 86
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.
![Page 88: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/88.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 87
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?
![Page 89: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/89.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 88
• 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.
Chapter 4 Conclusion
![Page 90: marie](https://reader034.vdocuments.us/reader034/viewer/2022042902/568c37b41a28ab02359c7f92/html5/thumbnails/90.jpg)
COMP 228, Fall 2009 MARIE: A Simple Computer 89
• Computers run programs through iterative fetch-decode-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.
Chapter 4 Conclusion