π Lecture 23 β I/O Subsystems
π Overview: This lecture introduces I/O subsystems, which are critical for computer performance. It explains the major components, interface types, design considerations, data transfer methods, and I/O buses, highlighting why improving I/O performance is as important as CPU performance.
ποΈ Topics Covered
The lecture covers an introduction to I/O subsystems and their differences from memory subsystems, major components including the I/O interface and peripherals, the computer interface and I/O ports, memory-mapped I/O versus isolated I/O, considerations during I/O subsystem design including data location, transfer, and synchronization, serial and parallel transfers with their types and error conditions, and I/O buses including arbitration and bandwidth issues, illustrated with examples.
π Lecture Summary
Introduction to I/O Subsystems
The terms "input" and "output" are from the CPU's point of view. In an input cycle, the CPU receives data from a peripheral device; in an output cycle, the CPU sends data to a peripheral device. I/O subsystems are similar to memory subsystems in that both exchange bits/bytes under CPU control, with the CPU sending address information that is decoded to select the appropriate device.
Memory and I/O subsystems differ in four key ways:
- Wider range of data transfer speed: I/O devices can be very slow (e.g., keyboard with seconds between keystrokes) or very fast (e.g., disk drive with microseconds/nanoseconds between bytes). Memory devices have a narrower speed range relative to the CPU.
- Asynchronous activity: Memory subsystems are almost always synchronous (governed by the CPU's clock). I/O subsystems generally require handshaking signals for asynchronous transfers.
- Larger degradation in data quality: I/O data can carry more noise (e.g., telephone line noise for modems, media defects on hard drives), requiring effective error detection and correction techniques.
- Mechanical nature of many I/O devices: Many I/O devices have mechanical parts with higher failure rates, causing interruptions that reduce throughput (e.g., a printer running out of paper requires CPU data to be buffered).
To deal with these differences, special software programs called device drivers are made part of the operating system, usually written in assembly language. Unlike memory subsystems where each location has a unique address from the CPU's address space, I/O devices typically use a group of contiguous addresses, with data exchanged byte-by-byte and stored in internal buffers if needed.
I/O subsystems were historically called the "orphans" of computer architecture because performance improvement was neglected. However, I/O performance is critical, especially for transaction processing systems like airline reservation systems or ATMs. The lecture provides an example: if a program takes 200 seconds (180 CPU + 20 I/O), and CPU performance improves 40% per year while I/O stays the same, after 7 years I/O time becomes 54.05% of elapsed timeβmaking I/O improvement as important as CPU improvement.
π‘ Why this matters: Neglecting I/O performance can dramatically limit overall system performance, even with a fast CPU.
Major Components of an I/O Subsystem
I/O subsystems have two major parts:
- The I/O interface: Electronic circuitry connecting the CPU to the I/O device.
- Peripherals: Devices used to communicate with the CPU (e.g., keyboard, monitor).
Computer Interface
A Computer Interface is a piece of hardware whose primary purpose is to connect computer elements (processor unit, memory subsystem, peripheral devices, buses/links) so that signal levels and timing requirements are matched.
An interface that connects the microcomputer bus to peripheral devices is called an I/O Port. I/O ports serve three purposes:
- Buffering data (holding temporarily) to and from the computer bus.
- Holding control information that dictates how a transfer is conducted (e.g., telling a printer to start a new page, telling a tape drive to rewind).
- Holding status information so the processor can monitor activity (e.g., printer out of paper, hard drive crash).
The term buffer refers to I/O registers in an interface where data, status, or control information is temporarily stored. A block of memory locations in main memory or peripheral devices can also be called a buffer. Special circuits for voltage/current matching are also called buffers.
The system bus (consisting of address bus, data bus, and control bus) serves as a backbone, connecting memory subsystems and I/O subsystems. I/O modules (examples: keyboard/mouse module, monitor module, hard disk module, modem module) are examples of I/O ports.
Memory Mapped I/O versus Isolated I/O
In isolated I/O, a separate address space of the CPU is reserved for I/O operations, totally different from the memory address space. The CPU has two distinct address spaces, and unique CPU instructions are associated with the I/O space. The x86 family (Pentium) with in and out instructions is a well-known example. The Pentium's I/O space is 64 Kbytes, organized as eight banks of 8 Kbytes each.
In memory-mapped I/O (used by processors like the SRC), there is no separate I/O space. Some address space from the memory address space is used to map I/O devices. The benefit is that all memory-accessing instructions can be used for I/O devices, eliminating the need for separate I/O instructions. The disadvantage is that the I/O interface becomes more complex, and if partial decoding is used, many memory addresses are consumed.
The CPU differentiates between the two address spaces using signals from the control bus. For the Pentium: during an in instruction, the IOR# signal becomes active and MEMR# is deactivated; during a mov instruction, MEMR# becomes active.
π Definition β Isolated I/O: A scheme where the CPU has a separate address space for I/O operations, distinct from the memory address space, accessed using unique I/O instructions. π Definition β Memory-Mapped I/O: A scheme where I/O devices share the memory address space, allowing all memory-accessing instructions to be used for I/O operations.
Considerations during I/O Subsystem Design
Data location: The designer must identify the device where the data to be accessed is available, its address, and how to collect the data. For example, if a record is stored in the fourth sector of the second track of the third platter on a hard drive, the particular hard drive must be selected and the address (platter, track, sector) must be provided.
Data transfer: This includes the direction of transfer (out of CPU or into CPU), the destination/source device, the amount of data (e.g., one bit for a mouse click, several kilobytes for a hard drive block), and the transfer rate (different for printers vs. hard drives).
Data synchronization: The CPU should input data only when the device is ready to provide it, and send data only when the device is ready to receive it. There are three basic schemes:
-
Synchronous transmission: The master (M) and slave (S) are permanently connected. The slave can transfer at the master's speedβno handshaking needed. The master activates the Read signal, data is provided by the slave, and the master uses the Enable signal to latch it. All activity is synchronous with the system clock. Example: register-to-register transfer within a CPU.
-
Semi-synchronous transmission: All activity is synchronous with the system clock, but when the slave cannot provide data within the allotted time, additional clock periods are added. The slave indicates readiness by activating the complete signal. Upon receiving this, the master activates the Enable signal to latch the data. Example: transfers between the CPU and main memory.
-
Asynchronous transmission: No common clock is required. The master and slave operate at different speeds. Handshaking signals coordinate the transfer: the master activates its Ready signal; the slave detects this, provides data, and activates its Acknowledge signal; the master latches data with the Enable signal; the master deactivates Ready; the slave removes data and deactivates Acknowledge.
π Definition β Handshaking signals: Additional signals used to coordinate asynchronous data transfers between devices operating at different speeds.
Serial and Parallel Transfers
Serial Transfer: Data bits in a "piece of information" (usually a byte or word) are transferred one bit at a time over a single pair of wires.
- Advantages: Easy to implement (using UARTs or USARTs), low cost (fewer wires), longer distance between transmitter and receiver.
- Disadvantages: Slow by nature, inefficient due to overhead.
Parallel Transfer: All data bits (usually 8 or 16) are transferred over separate lines simultaneously.
- Advantages: Fast compared to serial.
- Disadvantages: High cost (more lines), cost increases with distance, increased noise with distance.
π‘ Why this matters: The terms "serial" and "parallel" are with respect to the computer I/O ports, not the CPUβthe CPU always transfers data in parallel.
Types of serial communication:
- Asynchronous: Special bit patterns separate characters; "dead time" between characters can be any length; clocks at both ends need not have the same frequency (within limits).
- Synchronous: Characters are sent back-to-back; must include special "sync" characters at the beginning of each message and "idle" characters to fill gaps; characters must be precisely spaced; activity at both ends must be coordinated by a single clock (must be transmitted with data).
The maximum information rate of a synchronous line is higher than that of an asynchronous line with the same bit rate because asynchronous transmission uses extra bits with each character. A protocol is a set of rules understood by both sender and receiver.
Error conditions related to serial communication:
- Framing Error [A]: Occurs when a 0 is received instead of a stop bit (always a 1)βthe appropriate number of stop bits was not detected after the start bit.
- Parity Error [B]: Occurs when the parity of the received data does not match the expected parity. (Parity is the number of 1'sβeven or odd. A parity bit is an extra bit added for error detection/correction. For even parity, the total number of 1's including the parity bit is even.)
- Overrun Error [A]: The prior character was not yet read from the USART's "receive data register" by the CPU and was overwritten by the new received characterβthe first character is lost and must be retransmitted.
- Under-run Error [S]: If a character is not available at the beginning of an interval, the transmitter inserts an idle character until the end of the interval.
I/O Buses
Modern computers often use two separate buses: a memory bus for connecting the CPU to memory, and an I/O bus for connecting peripherals and I/O devices to the system. Examples of I/O buses include the PCI bus and the ISA bus. These provide an "abstract interface" that can be standardized for connecting a variety of peripherals.
Earlier generation computers used a single bus for both memory and I/O, sharing bandwidth. Modern architectures use separate buses for greater flexibility and upgradeability.
A main disadvantage of I/O buses is that every bus has a fixed bandwidth shared by all devices. Electrical constraints (transmission line effects, bus length) further reduce bandwidth. Designers must decide whether to sacrifice interface simplicity (connecting more devices) at the cost of bandwidth, or connect fewer devices for better bandwidth.
π Example #1: An I/O bus transfers 4 bytes per bus cycle at a maximum frequency of 30 MHz. Maximum bandwidth = 30 Γ 4 = 120 Mbytes/sec. A hard drive (40 Mbytes/sec) and video card (128 Mbytes/sec) together demand 168 Mbytes/secβexceeding the bus bandwidth. One or both components will operate at reduced bandwidth.
Bus arbitration: Most I/O buses have protocols defining how many devices can access the bus and what happens when multiple devices request it simultaneously. An arbitration scheme must be established. In SCSI, every device has an ID, and the device with the highest priority gets bus access first. This is easy to implement but can cause starvation (low-priority devices never get access). An alternative is to give highest priority to the device waiting the longest.
π Example #2: A bus requires 10 nsec for bus requests, 10 nsec for arbitration, and 15 nsec to complete an operation after access is granted. Total time = 35 nsec per I/O operation. Maximum IOPS = 1 / (35 Γ 10β»βΉ) = 28.6 million IOPS. Therefore, the bus cannot perform 50 million IOPS.
β Key Takeaways
I/O subsystems differ fundamentally from memory in speed range, synchrony, data quality, and mechanical nature, requiring special device drivers and careful design. There are two main I/O addressing schemes: isolated I/O with separate instructions and address space, and memory-mapped I/O that uses memory instructions but creates more complex interfaces. Data synchronization is achieved through synchronous, semi-synchronous, or asynchronous transmissionβeach with different handshaking requirements and speed capabilities. Serial transfer sends bits one at a time (cheaper, longer distance, slower), while parallel sends all bits simultaneously (faster, more expensive, shorter distance). I/O buses have fixed bandwidth that must be shared among all connected devices, requiring careful design and arbitration to avoid bottlenecks and starvation.
π§ Quick Revision Questions
- What are the four key differences between memory subsystems and I/O subsystems?
- Explain the difference between isolated I/O and memory-mapped I/O, giving an example processor for each.
- Describe the handshaking signals used in asynchronous transmission and their sequence.
- What are the four types of errors related to serial communication, and which ones are associated with asynchronous (A) and synchronous (S) transmission?
- In Example #2, why can the bus not perform 50 million IOPS, and what is the maximum number of IOPS it can achieve?
π Lecture 24 β Designing Parallel Input and Output Ports
π Overview: This lecture focuses on designing parallel I/O ports that interface the computer bus with peripheral devices. It covers the essential building blocks of address decoding and data isolation/capturing, explains the practical implementation of a skeleton address decoder (SAD), introduces the NUXI problem caused by endianness differences, and discusses variations in address decoder design based on CPU architecture. Understanding these concepts is critical for building functional and reliable I/O interfaces.
ποΈ Topics Covered
The lecture covers the design of parallel I/O ports, starting with the two key functions of address decoding and data isolation/capturing. It then provides a practical example of designing a 16-bit parallel output port for the FALCON-A CPU, including the implementation of the SAD and the use of LED branches for output display. The NUXI problem arising from endianness differences is introduced, followed by a detailed discussion on variations in address decoder implementation based on ISA design decisions, including examples for both FALCON-A and Pentium CPUs. Finally, a method for estimating delay intervals in software loops is presented.
π Lecture Summary
Designing Parallel I/O Ports
An I/O port is an interface that connects the computer bus (system bus or I/O bus) with I/O devices. During an I/O bus cycle, the CPU places a device address on the address bus, activates control signals for read or write, and then data is transferred over the data bus. The timing and voltage/current requirements of the I/O port must match those of the CPU. There are two important functions built into I/O ports: address decoding and data isolation (for input) or data capturing (for output).
π Definition β Address Decoder: An "Address Decoder" is a combinational (logic) circuit with n + r inputs and a single output, where n = the number of address lines into the decoder, and r = the number of control lines into the decoder. The output fD is active only when the corresponding address is present on the n address lines and the corresponding r control lines hold the "proper" (active or inactive) value. fD is inactive for all other situations.
π Formula/Analogy β Skeleton Address Decoder (SAD): Think of the address decoder as a βbig AND gateβ called a Skeleton Address Decoder or SAD. Its output is active only when the correct address is present and control signals hold proper values.
Suggestions for Address Decoder Design:
- Start by thinking of the address decoder as a βbig AND gateβ (SAD).
- Always write the port address in binary. Address lines that are 0 will be inverted before feeding into the βbig AND gateβ; other address lines will not be inverted.
- List relevant control signals. If the βproperβ value of a signal is 0, invert it before applying to the SAD.
- Determine if the decoder output should be active high or low based on the latch/buffer type. If active low is needed, invert the output of the βbig AND gateβ.
- Implement the SAD using any available method (e.g., HDL code, PLDs, or SSI building blocks).
Data Isolation or Capturing:
- For Input Ports: Use tri-state buffers to place data on the data bus only during the I/O read bus cycle. Their enable line is driven by the SAD output.
- For Output Ports: Use latches (or registers) to capture data from the data bus during the I/O write bus cycle and hold it for the peripheral device. Their clock/latch enable line is driven by the SAD output.
Example #1 β Designing a 16-bit Parallel Output Port for FALCON-A
Problem Statement: Design a 16-bit parallel output port mapped on address DEh of the I/O space of the FALCON-A CPU.
Solution:
- Start with a βbig AND gateβ (SAD) and write the address DEh in binary: 1101 1110.
- Associate CPU address lines: A7=1, A6=1, A5=0, A4=1, A3=1, A2=1, A1=1, A0=0.
- Since the I/O space is 256 bytes, address lines A15..A8 are donβt cares. A0 and A5 (which are 0) will be inverted before being applied to the SAD.
- The relevant control signal is IOW#. A logic 0 on this line indicates it is active, so it should be inverted before being applied to the SAD.
- For a 16-bit output port, two 8-bit registers are used. The SAD output connects to their enable inputs. D-inputs connect to the data bus, Q-outputs to the peripheral device.
π Formula β SAD Implementation: The SAD is an AND gate with 9 inputs (7 address lines + 2 inverted address lines + 1 inverted control signal). It can be implemented using an 8-input AND gate and a 2-input AND gate.
Example #2 β Displaying Output Data with LED Branches
Problem Statement: Given a 16-bit parallel output port at address DEh with 16 LED branches (LED on for 1, off for 0), which LEDs will be ON when the instruction out r2, 222 executes, assuming r2 contains 1234h?
Solution:
- 1234h in binary: 0001 0010 0011 0100
- Data bus bit associations: D15..D0 are associated with this bit pattern.
- The FALCON-A uses a byte-wide address space, a 16-bit data bus, and the big-endian data format. The upper byte (MSB) is transferred using address DEh, and the lower byte (LSB) using address DFh.
- The register mapped on address DEh uses D15..D8. The relevant bits are D12=1, D9=1, D5=1, D4=1, and D2=1.
- Therefore, LEDs L12, L9, L5, L4, and L2 will turn on.
The NUXI Problem
The NUXI problem arises from endianness differences. In the big-endian format, the least significant byte is transferred over the most significant side of the data bus, and vice versa for the little-endian format. When a little-endian computer exchanges data with a big-endian computer over a 16-bit parallel port, the data is received in a βswappedβ form. For example, the string βUNIXβ would be received as βNUXIβ. Special software is used to resolve this problem.
Variation in the Implementation of the Address Decoder
The previous implementation assumed the FALCON-A does not allow using part of its data bus during a transfer and that all port addresses are divisible by 2 (A0 is always 0). If a CPU allows using part of its data bus (e.g., 8 bits), the design changes.
In an alternate design, the enable inputs of the two 8-bit registers are not connected together. Since a 16-bit port uses two addresses (DEh and DFh), address line A0 cannot be used at the input of the big AND gate. Instead, A0 is used with two 2-input AND gates. The output of the AND gate where A0 is inverted enables the register at address DEh, and the gate where A0 is not inverted enables the register at address DFh.
If the assembler did not restrict port addresses to even values, the implications are significant. For example, executing out r2, 223 (address DFh) would not enable registers in the original design, but in the modified design, the high data byte would be sent to the register at address DFh over data lines D7..D0. The low data byte would be sent to address E0h in the next bus cycle, but it will be lost if no port exists there.
Pentium Example: The Pentium allows using part of its 32-bit data bus and accumulator. An 8-bit parallel output port at address FEF2h can be designed using the BE2# signal. The instruction sequence mov dx, 0FEF2h; mov al, 12h; out dx, al will send the data byte 12h to the 8-bit register over lines D23..D16.
π‘ Why this matters: ISA design decisions (e.g., address space organization, data bus width, endianness, and alignment restrictions) have a strong bearing on the implementation details and working of the computer.
Example #3 β Assembly Program to Turn on LEDs One by One
Problem Statement: Write an assembly language program to turn on 16 LEDs one by one on the output port from Example #1. Each LED should stay on for a noticeable duration.
Solution:
; Example_3.asmfa
mov r1, 0
out r1, 222 ; Turn all LEDs off
again:
delay1:
movi r2, 0
again1:
subi r2, r2, 1
jnz r2, [again1] ; Delay loop
out r1, 222 ; Turn on current LED
movi r5, 15 ; Loop counter for 15 remaining LEDs
again2:
shiftl r1, r1, 1
out r1, 222 ; Turn on next LED
delay2:
movi r2, 0
again3:
subi r2, r2, 1
jnz r2, [again3] ; Delay loop
subi r5, r5, 1
jnz r5, [again2] ; Loop for next LED
j [again] ; Start over from first LED
Estimating the Delay Interval
To estimate the delay introduced by a loop like again1, we can use the formula:
π Formula β Execution Time (ET): $$ ET = CPI \times IC \times T = \frac{CPI \times IC}{f} $$ Where:
- CPI = clocks per instruction
- IC = instruction count
- T = time period of the clock
- f = frequency of the clock
Example: Assuming FALCON-A operates at 1 MHz, subi takes 3 clock periods, and jnz takes 4 clock periods, the execution time for the again1 loop (executing 65,535 times) is:
$$
ET = (3+4) \times 65535 / (1 \times 10^6) = 0.459 \text{ sec}
$$
β Key Takeaways
The two essential building blocks of a parallel I/O port are an address decoder and data isolation/capturing logic. The address decoder, often implemented as a "big AND gate" (SAD), enables the port only when the correct address and control signals are present. Endianness (big-endian vs. little-endian) causes the NUXI problem when data is transferred between computers with different formats, requiring software resolution. ISA design decisions, such as data bus width, address alignment constraints, and the ability to use partial data buses, directly affect the complexity and feasibility of I/O port implementations. The execution time of software delay loops can be estimated using the formula ET = (CPI Γ IC) / f.
π§ Quick Revision Questions
- What are the two key functions that must be built into an I/O port, and how are they typically implemented for input and output ports?
- Explain the role of tri-state buffers in an input port and registers/latches in an output port.
- What is the NUXI problem, and why does it occur?
- In Example #2, if the FALCON-A used little-endian format instead of big-endian, which bits from D15..D0 would correspond to the MSB and LSB data bytes, and how would this change the calculation of which LEDs are on?
- Using the formula for execution time, calculate the delay for a loop that executes a
subiinstruction (3 clocks) and ajnzinstruction (4 clocks) 10,000 times on a CPU running at 2 MHz.
π Lecture 25 β Input Output Interface
π Overview: This lecture continues the design of I/O interfaces for the FALCON-A CPU, focusing on parallel input ports, memory-mapped I/O, and the Centronics printer interface. It covers critical concepts like partial decoding, data bus multiplexing, and the "wrap around" effect, showing how to connect real-world peripherals to a CPU.
ποΈ Topics Covered
This lecture begins by designing a 16-bit parallel input port at address 7Eh, including a complete assembly language program to monitor switches and blink LEDs. It then covers memory-mapped I/O ports, explaining the changes needed to map ports onto memory space. The concept of partial decoding and the resulting "wrap around" effect is explained in detail, followed by data bus multiplexing for connecting 8-bit peripherals to a 16-bit data bus. A generic I/O interface is introduced, and the lecture concludes with a thorough explanation of the Centronics Parallel Printer Interface, including its signals, timing, and a complete design example for the FALCON-A CPU.
π Lecture Summary
Designing a parallel input port
Designing a parallel input port is similar to an output port, but with key differences. The address decoder inverts A7 and A0 (for address 7Eh), uses the IOR# control signal instead of IOW#, and uses tri-state buffers for data isolation instead of a register. The common enable line of the tri-state buffers is connected to the output of the address decoder's AND gate. The input of these buffers connects to the input device (like switches S15...S0), and the output connects to the FALCON-A's data bus.
π Example #1: Design a 16-bit parallel input port mapped on address 7Eh of the FALCON-A I/O space.
- Address decoder has A7 and A0 inverted.
- IOR# is used.
- Sixteen tri-state buffers with common enable are used.
π Example #2: Write a program for a FALCON-A with a 16-bit input port at 7Eh and a 16-bit output port at DEh that blinks LEDs corresponding to switches set to logic 1.
- The program reads the input port, sends the value to the output port, waits, turns off all LEDs, waits again, and repeats indefinitely. This continuously monitors the switches and blinks the corresponding LEDs.
- The flowchart and assembly code (filename: Example_2) illustrate this process step-by-step.
π Definition β Single Address I/O Port: It is possible to use a single address for both input and output by using an address decoder that differentiates between the register (for output) and the tri-state buffer (for input) using the IOW# and IOR# control bus signals. A diagram shows a 16-bit parallel input/output port at address 2Ch using this technique.
Memory mapped I/O ports
Memory-mapped I/O maps I/O ports onto the CPU's memory space instead of a separate I/O space. For the FALCON-A, this requires: replacing IOW# with MEMW#, using the entire CPU address bus in the address decoder (e.g., addresses 00DEh and 00DFh for the previous example), and using store and load instructions instead of out and in instructions.
π Example: Rewriting the program from Example #2 for memory-mapped I/O.
- The advantage is that more than 256 ports are available (up to the full memory space).
- The disadvantage is that the address decoder becomes more complex, increasing hardware costs.
Partial decoding and the βwrap aroundβ effect
Partial decoding is a technique where some of the CPU's address lines are ignored in the address decoder, reducing complexity and cost. For example, ignoring address lines A8...A15 from the FALCON-A saves eight inverters and two AND gates. However, it has a trade-off known as the "wrap around" effect.
π Definition β Wrap Around Effect: When address lines are unused (don't cares), the single intended address is accessed by multiple addresses. For example, if upper eight address lines are unused, address 00DEh is also accessed at 01DEh, 02DEh, ..., FFDEh. The 64 Kbyte address space "wraps around" itself 256 times, effectively reducing it to 256 bytes. π‘ Why this matters: Partial decoding saves hardware but can cause aliasing, where multiple addresses map to the same port. This is acceptable in small systems with lots of unused memory space.
Data bus multiplexing
Data bus multiplexing connects one part of the CPU's data bus to the peripheral at one time and another part at a different time, ensuring only one 8-bit portion is connected at any time. This is used to attach 8-bit peripherals to a 16-bit (or larger) CPU data bus that has a byte-wide address space.
π Definition β Data Bus Multiplexing: A technique using tri-state buffers to connect different halves of a CPU's data bus to an 8-bit peripheral at different times, controlled by address bit A0.
- For an even address (A0=0), the upper group of tri-state buffers is enabled, connecting D<15..8> to the peripheral.
- For an odd address (A0=1), the lower group is enabled, connecting D<7..0> to the peripheral.
- An 8-bit parallel output port using addresses DCh and DDh is shown as an example.
- The instruction
out r1H,220accesses the peripheral using D<15..8>, whileout r1L,221uses D<7..0>. π Example: The instructionout r1,220sends r1H to the peripheral, but the contents of r1L are lost. This is because for address 220 (even), only D<15..8> are connected; D<7..0> (r1L) are not connected. - Advantage: All addresses are utilized, none wasted.
- Disadvantage: Increased complexity and cost of the interface.
A generic I/O interface
Most parallel I/O ports are mapped onto a range of contiguous addresses. A block diagram shows an interface using eight consecutive addresses (56 to 63) for a typical parallel device. Registers within the interface have predefined functions, like a "data out" register at addresses 56 and 57 for sending data, and a "control" register at addresses 60 and 61 for sending control bits. An address decoder at the bottom receives address/control information and generates enable signals for these registers.
The Centronics Parallel Printer Interface
The Centronics Parallel Printer Interface is an industry-standard set of signal specifications used by most printers. It provides a uni-directional, byte-wide parallel interface. The interface uses a 25-pin connector on the CPU side and a 36-pin connector on the printer side.
Key Signals:
- STROBE#: A control signal (active low) from the CPU to the printer indicating data is ready.
- BUSY: A status signal from the printer indicating it cannot accept more data.
- ACKNLG#: A status signal from the printer indicating data has been received and it is ready for new data.
- D<7..0>: The 8-bit data bus.
- PE#: Paper End status signal.
- SLCT: Select (online) status signal.
- ERROR#: Error status signal.
- INIT#: Control signal to reset the printer.
- AUTO FEED XT#: Control signal for auto line feed.
- SLCT IN#: Control signal to enable data entry.
Data Transfer Handshake:
- CPU places 8-bit data on the printer's data bus.
- CPU applies a negative pulse (β₯0.5ΞΌs) to the STROBE# pin.
- Printer activates BUSY (high) to indicate it cannot accept more data.
- Printer receives the byte, then activates ACKNLG# (low) to signal completion.
- Printer deactivates BUSY (low) to indicate readiness for new data.
- BUSY is suitable for level-triggered systems; ACKNLG# is better for edge-triggered systems.
- The interface typically uses two 8-bit output ports (data and control) and one 8-bit input port (status).
π Example #3: Design a Centronics parallel printer interface for the FALCON-A CPU starting at address 38h.
- Since the FALCON-A has a 16-bit data bus, three contiguous even addresses (38h, 3Ah, 3Ch) are used to simplify the design.
- Data bus lines D7...D0 are connected to the printer's 8-bit data bus; D15...D8 are left unconnected. (The FALCON-A uses big-endian format, so the low byte of CPU registers is transferred to the printer.)
- The address decoder logic diagram is provided in the lecture.
Centronics Bit Assignment for I/O Ports (Table 2):
- Address 0 (DATA): 8-bit output port for data byte (D7...D0).
- Address 1 (STATUS): 8-bit input port for status: BUSY (bit 7), ACKNLG# (bit 6), PE# (bit 5), SLCT (bit 4), ERROR# (bit 3), unused (bits 2-0).
- Address 2 (CONTROL): 8-bit output port for control: unused (bits 7-6), DIR (bit 5, enables bidirectional mode), IRQEN (bit 4), SLCT IN# (bit 3), INIT# (bit 2), Auto Feed XT# (bit 1), STROBE# (bit 0).
β Key Takeaways
The most critical concepts for the exam are the distinction between input and output port design (tri-state buffers vs. registers, IOR# vs. IOW#), the difference between isolated and memory-mapped I/O, and the trade-offs of partial decoding (lower cost vs. wrap-around effect). Data bus multiplexing is essential for connecting 8-bit peripherals to a 16-bit bus, enabling byte-wide transfers. Finally, the Centronics printer interface is a practical example of parallel communication, requiring careful consideration of handshaking signals (STROBE#, BUSY, ACKNLG#) and bit assignments for data, status, and control registers.
π§ Quick Revision Questions
- What are the three key differences between designing a parallel input port and a parallel output port for the FALCON-A?
- Explain the "wrap around" effect caused by partial decoding. Why might an engineer still choose to use partial decoding?
- In data bus multiplexing, how does the CPU's A0 line determine which half of the data bus is connected to an 8-bit peripheral?
- List the three handshaking signals used in the Centronics parallel printer interface and describe their function during a data transfer.
- For the FALCON-A Centronics interface example, why are addresses 39h, 3Bh, and 3Dh considered valid for accessing the interface even though the designed addresses are 38h, 3Ah, and 3Ch?
π Lecture 26 β Programmed I/O
π Overview: This lecture continues the discussion of the Centronics Parallel Printer Interface and introduces Programmed I/O, the first of three main I/O techniques. It provides detailed examples of programmed I/O implementation for both the FALCON-A and SRC processors, including timing analysis, and compares the two approaches. The lecture highlights the inefficiency of polling and sets the stage for interrupt-driven I/O.
ποΈ Topics Covered
This lecture covers the continuation of the Centronics Parallel Printer Interface specification, a detailed example of programming the interface on the FALCON-A processor to print an 80-character line, the concept and definition of Programmed I/O, a timing analysis of the FALCON-A example program, an improved approach using a printer buffer, programmed I/O examples for the SRC processor, and a comparison of the FALCON-A and SRC examples.
π Lecture Summary
The Centronic Parallel Printer Interface (Cont.)
The Centronics interface uses multiple control and status signals. The STROBE# signal (active low) tells the printer to read in the data byte on the data lines. The ACKNLG# signal goes low to indicate that the transfer of a character is complete. The BUSY signal is high when the printer cannot accept data (e.g., during data entry, printing, offline state, or error). The BUSY signal is more suitable for level-triggered systems, while the ACKNLG# signal is better for edge-triggered systems. The interface typically uses two 8-bit parallel output ports (for DATA and CONTROL) and one 8-bit input port (for STATUS). Table 2 shows the bit assignments for these I/O ports, where logical addresses 0, 1, and 2 correspond to the DATA, STATUS, and CONTROL registers, respectively.
Example # 1
The problem is to write an assembly language program for the FALCON-A processor to send an 80-character line to a Centronics printer, with the character data starting at memory address 1024. The solution involves initializing the printer by resetting the INIT# control bit (bit 2) to 0 and then back to 1, and setting the STROBE# signal high. The program then enters a polling loop to check the BUSY flag (bit 7 of the status register). When the printer is ready (BUSY=0), the program loads the next character from memory, outputs it to the data port, generates the necessary STROBE# pulse, advances the buffer pointer, decrements the loop counter, and repeats.
Programmed Input/Output
Programmed I/O refers to a technique where all I/O operations are performed under the direct control of a program running on the CPU. The program, often a "tight loop," handles all I/O activity, including device status sensing, issuing read/write commands, and transferring data. The I/O device has no direct access to memory or the CPU, and data transfer uses CPU registers. A subsequent I/O operation cannot begin until the current one is complete, causing the CPU to wait and making the scheme extremely inefficient. The examples from lectures 24, 25, and 26 are all examples of Programmed I/O.
π Definition β Programmed I/O: All I/O operations are performed directly by a program running on the CPU, which controls all aspects of the I/O process, including status checking, command issuing, and data transfer.
Timing analysis of the program in Example # 1(lec26)
The main loop of the FALCON-A example executes 80 times. The STROBE# signal generation takes 5 clock periods to go low and 5 clock periods to go high. For a 10MHz FALCON-A CPU, this corresponds to 0.5Β΅sec each, satisfying the printer's timing requirements. The polling loop (in r1, statusp; and r1, r1, r3; jnz r1, [again]) takes 10 clock periods (1Β΅sec). One pass of the main loop takes 38 clock periods (3.8Β΅sec). For a 1000 character-per-second (cps) printer, the printer takes 1msec per character. After sending a character in 3.8Β΅sec, the CPU waits ~996Β΅sec, executing the polling loop about 996 times per character. This demonstrates the extreme inefficiency of Programmed I/O.
π‘ Why this matters: The timing analysis shows that a 10MHz CPU spends over 99% of its time just waiting for the printer, highlighting why programmed I/O is unsuitable for slow devices.
An improved approach uses a buffer memory within the printer. A modified program eliminates the STROBE# pulse generation instructions, but the polling loop remains to check if the buffer is full (BUSY=1). The main loop now takes 28 clock periods (2.8Β΅sec). While the first 64 characters can be sent quickly (filling the buffer), the remaining 16 characters still face the same polling overhead. Increasing buffer size only delays the problem, not solves it. This issue led to the invention of interrupt-driven I/O.
Programmed I/O in SRC
For the SRC processor, which uses memory-mapped I/O, a program to output a character uses a 2-instruction polling loop to test the ready signal (checked by its sign bit). The program waits for the ready signal to become logic 1, then writes the character to the device data register. A 10 MIPS SRC would execute 10,000 instructions waiting for a 1,000 character/sec printer. A program to print an 80-character line has an inner loop to wait for ready and an outer loop to output a character, advance the pointer, decrement the counter, and repeat, followed by instructions to issue the print command.
Comparisons of the SRC and FALCON-A Examples
The FALCON-A and SRC examples are similar but differ in the control signal checked: the SRC checks the ready signal (active high), while the FALCON-A checks the BUSY signal (active low). Other differences include the instruction set, address width, and number of address lines. Despite different techniques, overhead due to polling cannot be completely eliminated in Programmed I/O.
β Key Takeaways
The key concept of this lecture is Programmed I/O, where the CPU is entirely responsible for all I/O operations, including continuous status checking (polling). The detailed timing analysis of the FALCON-A printer example clearly demonstrates the severe inefficiency of this technique, as the CPU wastes most of its time in a polling loop while waiting for a slow device. While introducing a printer buffer can slightly improve efficiency by allowing burst transfers, it does not eliminate the polling overhead and is only a partial solution. The examples for both the FALCON-A and SRC processors illustrate the universal structure of programmed I/Oβa polling loop followed by a data transferβhighlighting the need for more efficient methods like interrupt-driven I/O.
π§ Quick Revision Questions
- What is the fundamental characteristic of Programmed I/O that makes it inefficient for slow peripherals?
- In the FALCON-A example, how many clock periods does one pass of the polling loop take, and what does this imply for a 1000 cps printer?
- What is the purpose of the STROBE# signal in the Centronics interface, and how is it generated in the FALCON-A program?
- How does the SRC program determine if the printer is ready to accept a new character?
- Why does increasing the size of the printer's buffer not completely solve the inefficiency problem of Programmed I/O?