π Lecture 14 β External FALCON-A CPU
π Overview: This lecture continues the structural RTL description of the FALCON-A CPU, covering unconditional jump, shift, mov, call, ret, in, and out instructions. It then examines the external FALCON-A CPU interface, including control signals and bus activity, and provides an example problem to demonstrate how to determine bus logic levels and addressing modes during instruction execution.
ποΈ Topics Covered
The lecture covers the structural RTL for unconditional jump, shift (shiftr, shiftl, asr), mov, movi, in, out, call, and ret instructions. It details control signals required at different timing steps during instruction fetch and execution. It then introduces the external FALCON-A CPU interface with address, data, and control buses. The lecture concludes with an example problem that requires determining address bus, data bus, and control signal values for given instructions using a memory map and register map.
π Lecture Summary
Un-conditional jump instruction (op-code=20)
The unconditional jump instruction with op-code 20 is followed by a 3-bit identifier for register ra and an 8-bit constant c2.
π Formula: For jump [ra + constant], (ra=0): PC β PC + (8Ξ±C2<7>)Β©C2<7..0>, (raβ 0): PC β R[ra] + (8Ξ±C2<7>)Β©C2<7..0>
The assembler allows forms: jump [ra + constant], jump [ra + variable], jump [ra + address], jump [ra + label]. The jump range is β128 to 127 due to the 8-bit constant c2. The target address must be even because each instruction is 2 bytes. Types of unconditional jumps include direct, indirect, PC-relative, and register relative. When ra=0, it is a PC-relative near jump; when raβ 0, it is a register-relative far jump.
Structural RTL description for unconditional jump instruction (jump [ra+c2])
In steps T0-T2, the jump instruction is fetched. In T3, if ra field is zero, the contents of PC are placed in temporary register A; otherwise, the contents of register ra are placed in A. The comma indicates these are concurrent, and only one executes. In T4, the constant c2 is sign-extended and added to the contents of A, placing the effective address in buffer register C. In T5, the contents of C are loaded into PC.
π‘ Why this matters: Understanding this RTL sequence explains how both PC-relative and register-relative jumps are implemented using a single set of hardware steps.
Structural RTL for the shift instruction (shiftr ra, rb, c1)
First three steps fetch the shift instruction. c1 is a 5-bit constant from the lower 5 bits of the instruction register IR. In T3, the 5-bit register βnβ is loaded from the count field. In T4, depending on βNβ (the decimal value of βnβ), the contents of register rb are shifted right by N bits. Zeros are replicated N times and concatenated with the shifted bits (15...N). In T5, the contents of C are transferred to destination register ra.
For shiftl and asr, similar tables apply. In asr (arithmetic shift right), instead of copying zeros, the sign bit from the original data is copied to the leftmost position.
π Definition β βnβ vs βNβ: βnβ indicates the register storing the count; βNβ indicates the decimal value of the bits in register βnβ.
Other instructions: mov, call, ret
These instructions were not available in the SRC processor.
Structural RTL for the mov instruction (mov ra, rb)
Data in register rb (source) is moved to register ra (destination). In steps T0-T2, the mov instruction is fetched. In T3, the contents of register rb are placed in buffer register C through the ALSU unit. In T4, buffer register C transfers data to register ra through the internal uni-bus.
Structural RTL for the mov immediate instruction (movi ra, c2)
Constant c2 is moved into destination register ra. First three steps fetch the move immediate instruction. In T3, constant c2 is placed into buffer register C. Since C is 16-bit and c2 is 8-bit, the remaining leftmost bits are concatenated with the sign bit (bit <7>). If the number is negative, sign bit is β1β; if positive, sign bit is β0β. In T4, the contents of C are taken to destination register ra.
Structural RTL for the in instruction (in ra, c2)
FALCON-A has βinβ and βoutβ instructions not present in SRC. For FALCON-A, assume interconnection with input and output addresses up to 0..255.
First three steps fetch the instruction. In T3, IO[c2] indicates going to the IO address specified by c2 (a positive constant), and data is taken to buffer register C. In T4, data is transferred from C to destination register ra.
Structural RTL for the out instruction (out ra, c2)
This is opposite to the βinβ instruction. First three instructions fetch the instruction. In T3, contents of register ra are placed into buffer register C. In T4, data from C is placed at the output port indicated by constant c2.
Structural RTL for the call instruction (call ra, rb)
Control is given to a procedure, subroutine, or another address. First three steps fetch the call instruction. In T3, the present contents of PC are stored in buffer register C. In T4, data from C is transferred to register ra, which will contain the original PC contents (a return pointer). In T5, contents of register rb (the target address) are placed in C. In T6, contents of C are placed in PC, so PC indicates the new execution position.
π‘ Why this matters: The call instruction saves the return address in ra before jumping to the subroutine address in rb, enabling proper return after subroutine completion.
Structural RTL for return instruction (ret ra)
After instruction fetch in steps T0-T2, the register data in ra is placed in buffer register C through the ALSU unit. In T4, PC is loaded with the contents of this buffer register.
Control signals required at different timing steps of FALCON-A instructions
The table shows time steps, structural RTLs, and corresponding control signals. In step T0, the internal bus is active, placing PC contents in MAR while PC is incremented by 2 and placed in C. Control signals: LMAR enables writing to MAR; PCout makes PC contents available; INC2 increments PC; LC writes data from ALSU output to buffer register C.
In T1, data from memory location addressed by MAR is read into MBR. MARout enables the MAR tri-state buffer; MRead enables memory read; Cout enables buffer register C to provide data to bus; LPC enables PC to read from C; LMBR enables reading data from memory into MBR.
In T2, IR is loaded with data from MBR. Control signals: MBRout enables MBR tri-state buffers; LIR is the load signal for IR register.
In SRC, the fetch operation uses INC4 instead of INC2 because the instruction length is 4 bytes. For all instructions, the fetch cycle is the same; execution phase control signals vary per instruction.
π‘ Why this matters: Understanding control signals is essential for knowing which operations occur at each timing step and for designing the control unit.
External FALCON-A CPU Interface
The processor generates control signals used by memory or I/O to read/write data. The external interface consists of:
- 16-bit address bus
- 16-bit data bus
- Control bus with signals: MRead, MWrite, IORead, IOWrite
It is assumed that memory read is fast enough, so data is available in a fixed time interval (T2 in this example). For slow data transfer, handshaking with idle states would be used.
Example Problem
Given: PC = C348h, memory storage is big-endian, memory contents are properly aligned, a memory map and register map are provided.
(a) Determine logic levels on external FALCON-A buses for each instruction. (b) Specify memory-addressing modes.
Solution for Load instruction (RTL: MAR β R[5] + 12, MBR β Mem[MAR], R[3] β MBR):
- Address bus: Contents of r5 (1234h) + 12 decimal (Ch) = 1240h
- Data bus: Contents of memory location 1240h (from memory map) = 785h
- Control signals: MRead = 1, MWrite = 0
For instruction involving only registers: No external bus activity, so address bus, data bus, and control bus columns contain β?β or are unknown.
For Jump instruction (PC β PC + offset 52): External bus remains inactive, control signals are zero.
For Store instruction (RTL: MAR β R[3] + 17, Mem[MAR] β R[6]):
- This is a memory write operation: MWrite = 1, MRead = 0
- Effective address = R[3] contents + 17 decimal
- Convert 17 to hex (11h), add to R[3] contents (from register map) to get address
Addressing Modes
The table lists the addressing mode for each instruction in the example, based on how the effective address is computed.
β Key Takeaways
The FALCON-A CPU extends the SRC instruction set with in, out, mov, call, and ret instructions, each with specific structural RTL descriptions. All instructions share a common three-step fetch cycle (T0-T2) with specific control signals (PCout, LMAR, INC2, LC, Cout, LPC, MRead, LMBR, MBRout, LIR). The jump instruction uses sign-extended 8-bit constant c2, with PC-relative (ra=0) or register-relative (raβ 0) addressing. The external CPU interface includes a 16-bit address bus, 16-bit data bus, and control signals (MRead, MWrite, IORead, IOWrite). For exam problems involving memory maps and register maps, it is critical to determine address bus values by adding register contents to displacements (converted to hex), data bus values from memory contents at that address, and appropriate control signals for read vs. write operations.
π§ Quick Revision Questions
- For the jump instruction [ra + c2], what determines whether the jump is PC-relative or register-relative?
- Write the structural RTL steps T3-T5 for the shiftr instruction, explaining what happens in each step.
- What three control signals are activated in step T0 of the fetch cycle, and what does each accomplish?
- In the external FALCON-A interface, what are the sizes of the address bus and data bus, and what control signals are present?
- For a store instruction with R[3] = C2EFh and displacement = 17 decimal, what is the effective address placed on the address bus?
π Lecture 15 β Logic Design and Control Signals Generation in SRC
π Overview: This lecture focuses on the logic design for the uni-bus SRC, detailing the control signals necessary for instruction fetch and execution. It explores how the control path ensures synchronized operation of the data path components, includes external CPU interface details, and provides examples to solidify understanding of control signal generation.
ποΈ Topics Covered
The lecture covers identifying control signals for the fetch operation, the uni-bus SRC implementation with external CPU bus activity, memory address register (MAR) and memory buffer register (MBR) circuitry, register connections and alternate control circuitry, control signals for specific instructions like add, addi, and ld, and the process of sign extension.
π Lecture Summary
Logic Design for the Uni-bus SRC
This section bridges behavioral and structural RTL by introducing the control path. The control unit generates signals to coordinate the data path's components, ensuring instructions execute correctly. Key topics include identifying control signals, the external CPU interface, MAR/MBR circuitry, register connections, and sign extension. These elements work together to enable smooth, consistent operations in the SRC.
Identifying control signals
Control signals are required for every instruction in the SRC's instruction set. They select ALU functions, registers, or memory locations. For the fetch operation, control signals are issued in sequence during time slots T0, T1, and T2, with signals in each slot activating simultaneously.
Control signals for the fetch operation (Table 1): In T0, PCout writes the Program Counter to the internal bus, LMAR loads it into the Memory Address Register, INC4 increments PC by 4 in the ALSU (result stored in C), and LC enables writing to register C. In T1, LMBR enables writing to the MBR from the bus, MRead gates memory data into MBR, MARout enables MAR's tri-state buffers to the address bus, Cout writes register C onto the bus, and LPC loads the incremented value into PC. In T2, MBRout enables MBR output, and LIR loads the instruction into the Instruction Register.
Uni-bus SRC implementation
The uni-bus data path (Fig. 1) uses these control signals in mutually exclusive time steps for the instruction fetch cycle. Similar signals handle instruction execution. The external CPU interface includes address/data buses and memory read/write control signals. π‘ Why this matters: This implementation shows how control signals coordinate all components to fetch and execute instructions correctly.
Example problem with Table 2: Given PC = 000DC348h, memory map (Fig. 3), and register map (Fig. 4), the solution (Fig. 5) determines logic levels on external buses for instructions like ld, add, st, and beq. Part (b) specifies addressing modes (e.g., ld uses displacement, add uses register, st uses displacement, beq uses PC-relative). Notes: Relative addressing is always PC-relative; displacement is same as based/indexed/register relative.
MAR circuitry (Fig. 6): MAR loads from the internal CPU bus via LMAR and drives the external address bus via MARout, which controls tri-state buffers. It stores addresses for memory/I/O access.
MBR circuitry (Fig. 7): MBR loads from the internal bus or external data bus, and drives both buses. Tri-state buffers are at connection points. It holds data read from or to be written to memory.
Register connections (Fig. 8): The register file with general-purpose registers is programmer-visible. ra, rb, rc fields from the IR specify registers. Control signals RAE, RBE, RCE select a field for a 5-to-32 decoder, outputting a signal for the specific register. BUS2R enables writing to a register from the bus, and R2BUS enables reading a register onto the bus.
Alternate control circuitry for register selection (Fig. 9): This implementation uses a separate 5-to-32 decoder for each register field (ra, rb, rc). Decoder outputs enable the decoded register if RAE, RBE, or RCE is active. It illustrates multiple design possibilities.
Control signals Generation in SRC
Control signals for the add instruction: add ra, rb, rc. Table 4 lists signals per time step. In T3: RBE selects rb, R2BUS reads it to bus, LA writes to register A. In T4: RCE selects rc, R2BUS reads it, ADD selects add function in ALSU, LC writes result to C. In T5: Cout reads C, RAE selects ra, BUS2R writes result to ra.
Sign extension: When copying constant values to 32-bit registers, sign extension copies the most significant bit (MSB) to all additional leftmost bits. For the 17-bit constant c2, bus bits 31-17 become c2<16>. A 15-line tri-state buffer performs this (Fig. 10), with c2<16> applied to all its inputs.
π Definition β Sign extension: Copying the MSB of a number to all additional bits when widening its representation in 2's complement form.
π Formula: bus<31:17> = c2<16> β "The high-order bits of the bus equal the sign bit of the constant."
π Example: Extend c2 = 0b1_0000_0000_0000_0001 (17-bit, negative) to 32 bits: new value = 0b1111_1111_1111_1111_1000_0000_0000_00001.
Structural RTL for the addi instruction: addi ra, rb, c2. Control signals (Table 5) are same as add, except in T4: c2out enables the sign-extended constant onto the bus, ADD adds, LC stores result in C.
To place a 0 on the bus: When rb field is 0 (e.g., in ld and st instructions), the circuit (Fig. 11) outputs a hardwired 0 from a tri-state buffer onto the bus, rather than enabling register R0's output. An alternate circuit (Fig. 12) does the same.
Control signals for the ld instruction: ld ra, c2(rb). Table 6 shows RTL and signals. Steps T0-T2 are fetch. In T3: RBE, R2BUS, LA load rb into A. In T4: c2out, ADD, LC compute effective address in C. In T5: Cout, LMAR load MAR with the address. In T6: MARout outputs address, MRead reads memory, LMBR loads data into MBR. In T7: MBRout reads MBR to bus, RAE selects ra, BUS2R writes loaded data to ra.
β Key Takeaways
For the exam, you must remember the sequence of control signals for instruction fetch and specific instructions like add, addi, and ld. Understand the roles of MAR and MBR in memory access and how tri-state buffers enable bus sharing. Sign extension is critical for handling constant values, and special circuits place zero on the bus when the rb field is zero. The control signals (e.g., PCout, LMAR, R2BUS) always follow a strict timing order across T0-T7.
π§ Quick Revision Questions
- What are the control signals issued during time step T0 of the instruction fetch phase, and what does each do?
- In the
addinstruction, which control signals are activated at time step T4, and what is their purpose? - How does the sign extension of the constant
c2work in the SRC? - What is the difference in control signals between the
addandaddiinstructions? - List the control signals for the
ldinstruction at time steps T5, T6, and T7, explaining each action briefly.
π Lecture 16 β Control Unit Design
π Overview: This lecture continues the discussion of control signal generation for SRC instructions, covering store, branch, branch-and-link, and shift instructions. It then introduces the control unitβs role in generating timing and control signals, compares hardwired versus microprogrammed design approaches, and presents a 2-bus implementation of the SRC data path.
ποΈ Topics Covered
Control signal generation for the store instruction, branch and branch-link instructions, and the shift right instruction are detailed. The control unitβs design is then examined, focusing on its inputs, the hardwired approach using Boolean equations, and the effect of real gate propagation delays. Finally, the 2-bus SRC data path implementation and its structural RTL are presented.
π Lecture Summary
Control Signals Generation in SRC (continued...)
The lecture continues from the previous one, detailing additional control signals. For the store instruction st ra, c2(rb), the time step operations are similar to the load instruction, with differences in steps T6 and T7. The control signals for branch instructions like brzr rb, rc involve the LCON signal to enable the condition (CON) circuitry, RCE to read the register rc, and R2BUS to allow the bus to read from the selected register. At step T4, RBE reads the register rb (the branch target address) and LPC is issued conditionally (if CON=1) to update the program counter. For branch and link instructions like brlzr ra, rb, rc, an additional step T4 is used for the link operation, shifting the simple branchβs T4 to T5. For the shift right instruction shr, the five bits of n are applied to the select inputs of the barrel shifter, and the control signal SHR is activated.
The Control Unit
The control unit (CU) generates both control signals and timing signals, synchronizing internal and external events. It instructs the data path on what to do every clock cycle during instruction execution. CU design is critical, as most processor errors occur here. Two primary design approaches exist:
- Hardwired approach: Faster but complex circuitry.
- Microprogrammed approach: Slower but more flexible.
Finite-state machine concepts represent the CU, with each state corresponding to one clock cycle (timing step). The CU has four sets of inputs:
- Output of the timing step generator (T0-T7).
- Op-code (decoded from the Instruction Register).
- Data path generated signals (e.g., CON).
- Signals from external events (e.g., Interrupt).
The complexity of the control unit depends on the number of states, number of inputs, and number of outputs.
Hardwired Implementation of the Control Unit
In hardwired implementation, the operation code (op-code) field of the Instruction Register is decoded. For a processor like the FALCON-A with a 16-bit instruction, the 5 most significant bits (or IR<31..27> for the 32-bit SRC) are fed to a 5-to-32 decoder. Only one of the 32 outputs (op0 to op31) is active at a time, corresponding to the executing instruction.
To design the CU, Boolean equations are written by browsing structural descriptions to see which control signals appear in different timing steps. Each instruction has a table defining structural RTL and control signals. The equation is a logical combination (AND and OR) of control signals. For example, the equation for PCout is:
PCout = T0 + T3.(OP20 + OP22) + T4.(OP16 + OP17 + OP18 + OP19)
This means PCout is active in T0 always, OR in T3 if the op-code is 20 or 22 (jump/subroutine call), OR in T4 if the op-code is 16-19 (conditional jumps). Similarly, the equation for LPC is:
LPC = T1 + T5.OP20 + T6.CON.(OP16 + OP17 + OP18 + OP19)
These equations are implemented using logic circuits with AND/OR gates.
π Definition β CON: A control signal that is set to 1 only if the specified condition for a conditional branch is met.
π Example: The logic circuit for PCout combines T0, T3 ANDed with OR of OP20 and OP22, and T4 ANDed with OR of OP16 through OP19, all ORed together.
π‘ Why this matters: These Boolean equations form the blueprint for the physical logic gates in the control unit.
Effect of using βrealβ Gates
In real circuits, gates have propagation delays, and cascading gates adds delays. This places an upper limit on the clock frequency controlling timing intervals (T0-T7). For example, transferring contents of register R1 to R2 requires a minimum time t_min, so the maximum clock frequency is 1/t_min. Students are encouraged to study the textβs Example 4.1.
2-Bus Implementation of the SRC Data Path
The 2-bus SRC data path has an βinβ bus for writing data to components and an βoutβ bus for reading data from components. The structural RTL for the sub instruction using this implementation is illustrated. The first three steps are for instruction fetch; at step T3, register R[rb] is written to register A. At step T4, the subtracted result from the ALSU is assigned to register R[ra], requiring no temporary register due to the two buses.
π Formula: Result = R[ra] β R[rb] - R[rc] (for the sub instruction).
Control signals for the fetch operation
The control signals for the instruction fetch phase are the same for all instructions.
At time step T0:
- PCout: Enables read of Program Counter onto the βoutβ bus.
- LMAR: Loads the Memory Address Register.
- C=B: Copies value from βoutβ bus to βinβ bus for loading into MAR.
At time step T1:
- PCout: Value of PC on βoutβ bus.
- INC4: ALSU performs increment-by-four operation.
- LPC: Enables write of new PC value from βinβ bus.
- MRead: Enables memory word read.
- MARout: Supplies address to memory via external bus.
- LMBR: Stores memory word into Memory Buffer Register.
At time step T2:
- MBRout: Reads MBR contents onto βoutβ bus.
- C=B: Copies value from βoutβ to βinβ bus for loading into MAR.
- LIR: Loads the instruction into the Instruction Register.
At time step T3, execution begins, with control signals depending on the actual instruction. The memory is assumed to be fast enough to respond; if not, wait states are inserted. Control signals within each time slot are activated simultaneously, while those for successive slots are sequential.
β Key Takeaways
The control unit generates all timing and control signals for the processor, with two main design approaches: hardwired (faster, complex) and microprogrammed (slower, flexible). Hardwired design uses Boolean equations derived from RTL descriptions to create logic circuits for each control signal (e.g., PCout, LPC). Real gate propagation delays limit the maximum clock frequency. The 2-bus SRC data path uses separate βinβ and βoutβ buses for efficient data movement, reducing the need for temporary registers during execution. Instruction fetch control signals are consistent across all instructions, while execution-phase signals are instruction-specific.
π§ Quick Revision Questions
- What are the four sets of inputs to the hardwired control unit?
- Write the Boolean equation for
PCoutin the hardwired control unit and explain each term. - Why does the propagation delay of real gates limit the maximum clock frequency?
- In the 2-bus SRC data path, why is no temporary register needed for the
subinstruction at step T4? - What is the purpose of the
C = Bcontrol signal in the 2-bus implementation during instruction fetch?
π Lecture 17 β Machine Reset and Machine Exceptions
π Overview: This lecture covers two critical mechanisms for controlling processor state: the machine reset operation, which initializes the processor to a known state, and machine exceptions, which interrupt normal instruction flow to handle internal or external events. Both are essential for reliable computer operation, debugging, and system initialization.
ποΈ Topics Covered
The lecture begins with a 3-bus implementation of the SRC data path, showing how instructions like subtract are fetched and executed in two time steps. It then covers the machine reset operation in detail, including behavioral and structural RTL for both hard and soft resets, with a concrete example using the subtract instruction. Finally, it discusses machine exceptions, their processing mechanisms (priority resolution, device identification, state saving), and various types including program exceptions, hardware exceptions, and interrupts.
π Lecture Summary
A 3-bus Implementation for the SRC
A 3-bus implementation of the data-path for the SRC is presented, using two buses βAβ and βBβ for reading, and a bus βCβ for writing. All special purpose and general purpose registers have two read ports and one write port in this architecture.
Structural RTL for the Subtract Instruction using the 3-bus Data Path Implementation
The syntax of the subtract instruction is sub ra, rb, rc. The structural RTL for implementing this instruction requires only two time steps for the instruction fetch phase. At time step T0, the Memory Address Register (MAR) receives the value of the Program Counter (PC), then the Memory Buffer Register (MBR) receives the memory word indexed by the MAR, and the PC value is incremented. At time step T1, the instruction register (IR) is assigned the instruction word loaded into the MBR. This concludes instruction fetch. In the next time step, T2, the instruction is executed by subtracting the value of register rc from rb, and assigning the result to register ra. At the end of each sequence, the timing step generator is initialized to T0.
Control Signals for the Fetch Operation
The lecture lists control signals for the instruction fetch phase, noting that control signals for the execute phase can be written similarly.
The Machine Reset
Reset operation The reset operation is required to change the processor's state to a known, defined value. The two essential features are clearing the control step counter and reloading the PC to a predefined value. The control step counter is set to zero so operation restarts from instruction fetch. The PC is reloaded to execute a specific recovery or initializing program.
In most implementations, the reset instruction also clears interrupt enable flags to disable interrupts during initialization. If a condition code register is present, it is usually cleared too. External flags and processor state registers are typically cleared.
The reset instruction is mainly used for debugging purposes, as most processors halt operations immediately or within a few cycles. The processor state may then be examined.
Some processors have two types: Soft reset implies initializing PC and interrupt flags. Hard reset initializes other processor state registers in addition to PC and interrupt enable flags. The software reset instruction asserts the external reset pin.
Reset operation in SRC
Hard Reset: The SRC performs a hard reset upon receiving a start (Strt) signal, initializing PC and general registers.
Soft Reset: The SRC performs a soft reset upon receiving a reset (rst) signal, initializing PC only. The reset signal in SRC is assumed to be external and asynchronous.
PC Initialization: Two approaches exist. The Direct Approach loads the PC with the address of the startup routine upon resetting. The Indirect Approach initializes the PC with the address where the address of the startup routine is located; the reset instruction loads the PC with the address of a jump instruction, which contains the address of the required routine. An example is the 8086 processor, which upon reset initializes PC with address FFFF0H, containing a jump instruction to the bootstrap loader program.
Behavioral RTL for SRC Reset
The original behavioral RTL for SRC without reset was:
Instruction_Fetch :=(! Run&Strt: (Run β 1; instruction_Fetch, Run : (IR β M [PC]; PC β PC+4; instruction_execution))
The modified RTL after adding reset capability is:
Instruction_Fetch:=(! Run&Strt :( Run β 1, PC, R [0...31] β 0), Run&!Rst :( IR β M [PC], PC β PC+4, instruction_execution); Run&Rst:( Rst β 0, PC β 0); instruction_Fetch)
To implement these changes, the following modifications are required: a check for the reset signal on each clock cycle, a control signal for clearing the PC, and a control signal to load zero to the control step counter.
Example: The sub instruction with RESET processing In step T0, if Rst is not asserted, the new instruction address is delivered to memory and PC is incremented by 4. If Rst is asserted, Rst is immediately cleared, PC is cleared to zero, and T (step counter) is set to zero. This behavior is the same for all steps. In step T1, if Rst is not asserted, the memory word value is stored in the memory data register and PC is set to its incremented value. In step T2, memory data transfers to IR. In step T3, register operand values are read. In step T4, the mathematical operation executes. In step T5, the calculated value is written back to the register file. During all steps, if Rst is asserted, PC and step counter are set to zero.
π‘ Why this matters: This demonstrates how reset must be handled at every clock cycle, even in the middle of multi-cycle instruction execution, ensuring the processor can be reliably brought to a known state regardless of when the reset signal arrives.
Machine Exceptions
Anything that interrupts the normal flow of execution of instructions in the processor is called an exception. Exceptions may be generated by an external or internal event such as a mouse click or an attempt to divide by zero. External exceptions or interrupts are generally asynchronous (do not depend on the system clock) while internal exceptions are synchronous (paced by internal clock). The exception process allows instruction flow to be modified in response to internal or external events or anomalies.
Exception Processing A generalized exception handler should include:
-
Logic to resolve priority conflicts β for nested exceptions, the processor must decide which has higher priority. For example, a timer interrupt might have higher priority than keyboard input.
-
Identification of interrupting device β two basic approaches exist: exception vectors (containing the address of the exception handling routine, filled by the interrupting process when acknowledged) and the βinformationβ register (using one general purpose exception handler, saving PC and loading general purpose register address; the interrupting process fills the information register with identification data).
-
Saving the processor state β must be saved before jumping to the exception handler, including current PC value, general purpose registers, condition vector, and external flags.
-
Exception disabling during critical operation β processor must disable interrupts during context switching to prevent another exception from disrupting the transition.
Examples of Exceptions
- Reset Exception β treated as an exception by some machines (e.g., SPARC and MC68000)
- Machine Check β external exception caused by memory failure
- Data Access Exception β generated by memory management unit to protect against illegal accesses
- Instruction Access Exception β similar to data access exception
- Alignment Exception β blocks misaligned data access
Types of Exceptions
-
Program Exceptions β raised during instruction decoding and execution; examples include illegal instruction (executing an instruction not in the instruction set) and privileged instruction exception.
-
Hardware Exceptions β various kinds; e.g., a timer raising an exception when it counts down to zero.
-
Trace and Debugging Exceptions β enabled through traps; the exception handler called after each instruction execution allows examination of program variables.
-
Non-Maskable Exceptions β high priority exceptions reserved for catastrophic events such as power loss. These cannot be suppressed by the processor under any condition. In case of power loss, the processor might try to save system state to hard drive or alert an alternate power supply.
-
Interrupts (External Exceptions) β exception handlers written for external interrupts, allowing programs to respond to events like keyboard or mouse events.
π‘ Why this matters: Understanding the exception hierarchy and processing mechanisms is critical for designing robust systems that can handle multiple simultaneous events, recover from errors, and maintain system integrity.
β Key Takeaways
The 3-bus SRC implementation uses two read buses and one write bus, requiring only two time steps for instruction fetch and one for execute in the subtract example. The machine reset operation has two types: hard reset (initializing PC, general registers, and step counter via Strt signal) and soft reset (initializing only PC via rst signal), both tested on every clock cycle. Exception processing requires mechanisms for priority resolution, device identification (via exception vectors or information registers), state saving, and interrupt disabling during critical operations. Exceptions range from program exceptions (illegal instructions) to hardware exceptions (timers), non-maskable exceptions (power loss), and external interrupts (keyboard/mouse). The reset operation itself can be implemented as an exception in some architectures like SPARC and MC68000.
π§ Quick Revision Questions
- What are the two essential features of a reset operation, and why is each needed?
- How does the behavioral RTL for SRC change when adding reset capability, and what three hardware modifications are required?
- What happens in each time step (T0 through T5) when the subtract instruction is executed with and without the Rst signal asserted?
- List four mechanisms that a generalized exception handler must include, and explain the two approaches for identifying the interrupting device.
- What is the difference between non-maskable exceptions and interrupts, and give an example of each.