Memory Hierarchy & I/O/Memory Interfacing with 8085
Open in the Padhaiko app4.1 Memory classifications and hierarchy
Memory is the storage component of a microprocessor system that holds executable program instructions and operational data. In microprocessor system design, memory devices are organized systematically based on physical storage mechanisms, read-write capabilities, volatility, and access speeds.
Primary vs Secondary Memory
Computer memory is broadly divided into two main categories:
- Primary Memory (Main Memory): Directly accessible by the microprocessor via system address and data buses. Primary memory stores active instructions and operating data during program execution. It offers high speed and random access capability, but has lower storage density and higher cost per bit compared to secondary storage. Primary memory consists of Semiconductor Random Access Memory (RAM) and Read-Only Memory (ROM).
- Secondary Memory (Auxiliary / Mass Storage): Not directly addressable by the CPU. Program instructions and bulk data files stored in secondary memory must first be loaded into primary memory before execution. Examples include Solid-State Drives (SSDs), Hard Disk Drives (HDDs), optical discs (CD/DVD), and flash drives.
Classification of Semiconductor Primary Memory
| Memory Category | Sub-type | Storage Element | Volatility | Read/Write Capability | Primary Application |
|---|---|---|---|---|---|
| RAM | SRAM (Static RAM) | 6-transistor cross-coupled flip-flop | Volatile | Read and write at equal high speed | CPU registers, L1/L2/L3 cache |
| RAM | DRAM (Dynamic RAM) | 1 transistor + 1 MOS capacitor | Volatile | Slower than SRAM; requires periodic refresh | Main system memory (DDR4, DDR5) |
| ROM | Mask ROM | Hardwired diode/transistor matrix | Non-volatile | Read-only; factory programmed | Mass production fixed firmware |
| ROM | PROM | Fusible Nichrome or polysilicon links | Non-volatile | One-time programmable by user | Field programmable bootstrap loaders |
| ROM | EPROM | Floating gate MOS (trapped charge) | Non-volatile | Ultraviolet light erasable; reprogrammable | Prototyping firmware (e.g., Intel 2764) |
| ROM | EEPROM | Floating gate tunnel oxide MOS | Non-volatile | Electrically byte-erasable in circuit | Calibration tables, configuration storage |
| Flash Memory | NAND / NOR Flash | Floating gate / charge trap transistors | Non-volatile | Electrically block-erasable; high density | USB drives, SSDs, modern motherboard BIOS |
| Aspect | Static RAM (SRAM) | Dynamic RAM (DRAM) |
|---|---|---|
| Basic Memory Cell | 4 to 6 transistors forming a bistable multivibrator (flip-flop) | Single MOS transistor and a storage capacitor |
| Data Retention | Retains stored data indefinitely as long as DC power is supplied | Data leaks away across capacitor; requires refresh cycle every 2 ms to 4 ms |
| Refresh Circuitry | Not required | Dedicated refresh controller and arbiter circuitry required |
| Access Time | Fast: typically 1 ns to 10 ns | Slower: typically 30 ns to 70 ns |
| Packaging Density & Cost | Lower density (larger silicon area per bit), significantly higher cost | High packing density, low cost per bit |
| Power Consumption | Higher active power; virtually zero standby current | Lower active power per bit, but continuous power needed for refresh |
| Typical Usage | Microprocessor cache memories (L1, L2, L3) and high-speed scratchpads | Main system memory in microcomputers and embedded systems |
Memory Hierarchy
The memory hierarchy organizes memory subsystems in a pyramid configuration. The objective is to achieve the highest possible access speed while keeping total system cost reasonable and providing adequate storage capacity.
+-----------------------+
/ Registers \ Fastest, lowest capacity,
/ (Within CPU) \ highest cost per bit
+-----------------------------+
/ L1 Cache \
+---------------------------------+
/ L2 Cache \
+-------------------------------------+
/ L3 Cache \
+-----------------------------------------+
/ Main Memory \
/ (DRAM / SRAM) \
+-----------------------------------------------+
/ Secondary Storage \
/ (NVMe SSD / SATA HDD) \
+-----------------------------------------------------+
/ Tertiary Storage \ Slowest, highest capacity,
/ (Optical Media, Magnetic Tape) \ lowest cost per bit
+-----------------------------------------------------------+| Hierarchy Level | Typical Capacity | Access Time | Managed By | Technology |
|---|---|---|---|---|
| CPU Registers | 64 to 2048 bytes | 0.2 ns to 0.5 ns | Compiler / Programmer | Internal CPU flip-flops |
| Level 1 Cache | 32 KB to 128 KB | 0.8 ns to 1.5 ns | Hardware (Cache Controller) | On-die SRAM |
| Level 2 Cache | 256 KB to 2 MB | 3 ns to 5 ns | Hardware | On-die SRAM |
| Level 3 Cache | 8 MB to 64 MB | 10 ns to 20 ns | Hardware | Shared on-die SRAM |
| Main Memory | 4 GB to 128 GB | 50 ns to 100 ns | Operating System / Hardware | Synchronous DRAM (DDR4/DDR5) |
| Secondary Storage | 256 GB to 8 TB | 10 us (SSD) to 10 ms (HDD) | Operating System (File System) | NAND Flash / Magnetic Disks |
| Off-line / Archive | 1 TB to 100+ TB | Seconds to minutes | System Administrator / Tape robot | Magnetic Tape, Optical jukebox |
4.2 Interfacing I/O devices and memory with 8085
Interfacing is the method of connecting peripheral input/output devices and memory chips to the microprocessor buses so that data transfer can take place reliably.
8085 Bus Organization and Demultiplexing
The Intel 8085 microprocessor has:
- 16 Address Lines (A15 to A0): Capable of addressing 2^16 = 65,536 memory locations (64 KB). The upper 8 address lines (A15 to A8) are unidirectional and dedicated.
- Multiplexed Address/Data Lines (AD7 to AD0): To minimize IC pin count to 40 pins, the lower 8 address lines (A7 to A0) and the 8 bidirectional data lines (D7 to D0) are time-multiplexed onto the same 8 physical pins (pins 12 to 19).
- Address Latch Enable (ALE): Pin 30 provides a positive-going pulse during the T1 state of every machine cycle. ALE indicates that the bits on AD7 to AD0 represent address lines A7 to A0.
Bus Demultiplexing with 74LS373
To interface memory or I/O devices, the multiplexed bus AD7 to AD0 must be separated into a distinct 8-bit low-order address bus (A7 to A0) and an 8-bit data bus (D7 to D0).
Demultiplexing is performed using an external 8-bit transparent D-latch, such as the 74LS373:
- The inputs (1D to 8D) of the 74LS373 are tied directly to AD7 to AD0 of the 8085.
- The latch enable input (LE / G, pin 11) is connected to the 8085 ALE output.
- The output enable pin (OE_bar, pin 1) is tied to ground (0V) to keep outputs permanently enabled.
During the T1 state of each machine cycle:
- The 8085 places the low-order address on AD7 to AD0 and asserts ALE HIGH.
- The 74LS373 latch becomes transparent; the address appears at its outputs (1Q to 8Q).
- When ALE transitions from HIGH to LOW at the end of T1, the 74LS373 latches and holds address lines A7 to A0 stable for the rest of the machine cycle (T2, T3, T4).
- During T2, T3, and T4, the 8085 floats the address on AD7 to AD0 and uses these pins exclusively for bidirectional data transfer (D7 to D0).
Generation of Control Signals
The 8085 provides three primary status and control lines: IO/M_bar (pin 34), RD_bar (pin 32, active LOW), and WR_bar (pin 31, active LOW). Memory and peripheral devices require distinct, mutually exclusive read and write strobes:
- MEMR_bar (Memory Read): Active LOW when
IO/M_bar = 0andRD_bar = 0. - MEMW_bar (Memory Write): Active LOW when
IO/M_bar = 0andWR_bar = 0. - IOR_bar (I/O Read): Active LOW when
IO/M_bar = 1andRD_bar = 0. - IOW_bar (I/O Write): Active LOW when
IO/M_bar = 1andWR_bar = 0.
These four control strobes can be synthesized using basic OR gates:
MEMR_bar = IO/M_bar OR RD_barMEMW_bar = IO/M_bar OR WR_barIOR_bar = (NOT IO/M_bar) OR RD_barIOW_bar = (NOT IO/M_bar) OR WR_bar
Alternatively, an active-low 3-to-8 line decoder (such as the 74LS138) can generate all four strobes cleanly with minimal component count.
4.2.1 Address decoding
Address decoding is the electrical logic that inspects the microprocessor address bus lines and generates an active-low Chip Select (CS_bar or CE_bar) signal for a specific memory chip or I/O device.
Because all memory chips and I/O ports share the same data bus, no two devices may place data onto the bus at the same time. The address decoder guarantees that only the single device whose address matches the CPU output is activated.
There are three primary address decoding schemes in microprocessor systems:
- Absolute (Full) Address Decoding: Every address line available in the addressing mode is decoded.
- Partial (Non-unique) Address Decoding: Only a subset of higher address lines is decoded, leaving some address lines unmonitored.
- Linear Select Decoding: Each device is selected by connecting its
CS_barpin directly to an individual higher-order address line (e.g., A15 selects chip 1, A14 selects chip 2). While it requires zero decoder ICs, it severely fragments the address space and permits addressing only as many devices as there are spare address lines.
4.2.2 Unique and non-unique address decoding
Unique vs Non-Unique Address Decoding
Unique (Absolute) Address Decoding: In unique address decoding, all address lines of the processor are connected to the decoding circuitry. As a consequence, each physical memory register or peripheral port responds to exactly one address in the system memory or I/O map. There are no redundant or ghost addresses. Full decoding is essential in modular systems where memory may be expanded later, as it prevents bus contention.
Non-Unique (Partial / Fold-back) Address Decoding: In non-unique address decoding, only the minimum number of address lines necessary to determine device size is decoded; the remaining address lines are treated as "don't cares" (denoted as X). Because the decoder does not inspect these don't-care lines, the physical device responds identically whether those lines are 0 or 1.
If n address lines are left unconnected, the device appears at 2^n distinct addresses across the address space. These duplicate addresses are called alias addresses, shadow addresses, or fold-back addresses.
| Feature | Unique (Full) Address Decoding | Non-Unique (Partial) Address Decoding |
|---|---|---|
| Address Line Usage | All address lines are decoded | Some higher-order address lines are left unconnected (don't care) |
| Hardware Complexity | Higher; requires multi-input NAND gates or decoder ICs | Lower; requires minimal logic gates |
| Implementation Cost | Higher component cost and board layout complexity | Low component cost; simple design |
| Number of Addresses per Device | Exactly 1 unique address | 2^n alias addresses (where n is number of don't care lines) |
| Address Space Utilization | 100% efficient; no address waste | Highly wasteful; entire blocks are blocked by shadow addresses |
| System Expandability | Easy to add memory/peripherals without bus collision | Expansion risks bus contention if a new chip overlaps shadow addresses |
4.2.3 I/O mapped I/O and memory mapped I/O
The 8085 microprocessor supports two distinct architectures for communicating with peripheral devices:
- I/O Mapped I/O (Isolated I/O / Peripheral-Mapped I/O)
- Memory Mapped I/O
| Aspect | I/O Mapped I/O | Memory Mapped I/O |
|---|---|---|
| Address Bus Width | 8-bit port address (A7 to A0, duplicated on A15 to A8) | 16-bit address (A15 to A0) |
| Total Addressable Ports | 2^8 = 256 input ports and 256 output ports | Shared 64 KB space (any portion allocated to I/O reduces memory) |
| Control Signals | Dedicated IOR_bar and IOW_bar (with IO/M_bar = 1) | Standard MEMR_bar and MEMW_bar (with IO/M_bar = 0) |
| Dedicated Instructions | Only two instructions: IN port_addr and OUT port_addr | All memory instructions: MOV r,M, MOV M,r, LDA, STA, LHLD, SHLD, ADD M |
| Data Register Restriction | Data transfers must pass strictly through the Accumulator (A) | Data can be moved to or from any CPU general-purpose register (A, B, C, D, E, H, L) |
| Direct Arithmetic/Logic | Not possible; port data must first be loaded into accumulator | Arithmetic and logic can be executed directly on port data (e.g., CMP M, ANA M) |
| Execution Speed | IN and OUT take 10 T-states (3 machine cycles: OF, MR, IOR/IOW) | Faster single-byte transfer: MOV r,M takes 7 T-states (OF, MR); STA takes 13 T-states |
| Hardware Decoder Complexity | Simpler decoder (decodes only 8 address lines A7 to A0) | More complex decoder (must decode 16 address lines A15 to A0) |
| Impact on System RAM | Zero impact; entire 64 KB memory space remains available | Consumes address space that could otherwise hold RAM or ROM |
4.2.4 I/O address decoding with NAND and block decoders
Address Decoding with NAND Gates
In I/O mapped I/O, the port address is an 8-bit number placed on address lines A7 to A0. An 8-input NAND gate (such as the 74LS30) can be configured to produce an active-low device select signal.
For example, to decode an input port at address 80H (1000 0000B):
- Line A7 is a logic 1 and connects directly to an input of the 74LS30.
- Lines A6, A5, A4, A3, A2, A1, and A0 are logic 0; each is passed through an inverter (74LS04) before connecting to the 74LS30 inputs.
- The output of the 74LS30 goes LOW if and only if
A7-A0 = 80H. - To generate the active-low device enable for an input port buffer (74LS244), the 74LS30 output and the system
IOR_barline are combined through a 2-input OR gate (or negative-input AND). When both are LOW, the output of the OR gate goes LOW, enabling the buffer onto data lines D7 to D0.
Address Decoding with 74LS138 (3-to-8 Line Decoder)
The 74LS138 is an industry-standard 3-to-8 line decoder with three binary select inputs (A, B, C) and eight active-low outputs (Y0_bar to Y7_bar). It includes three enable pins:
G1: Active HIGH enable (pin 6).G2A_bar: Active LOW enable (pin 4).G2B_bar: Active LOW enable (pin 5).
The decoder is active only when G1 = 1, G2A_bar = 0, and G2B_bar = 0. When active, exactly one of the eight outputs goes LOW according to the binary code on inputs C (MSB), B, and A (LSB).
+-------------------+
A0 ----->| A (Pin 1) Y0_bar |---> Selects Port 0 (e.g., F8H)
A1 ----->| B (Pin 2) Y1_bar |---> Selects Port 1 (e.g., F9H)
A2 ----->| C (Pin 3) Y2_bar |---> Selects Port 2 (e.g., FAH)
| Y3_bar |---> Selects Port 3 (e.g., FBH)
IO/M_bar ----->| G1 (Pin 6) Y4_bar |---> Selects Port 4 (e.g., FCH)
A7 to A3 ====>| G2A_bar Y5_bar |---> Selects Port 5 (e.g., FDH)
| G2B_bar Y6_bar |---> Selects Port 6 (e.g., FEH)
| Y7_bar |---> Selects Port 7 (e.g., FFH)
+-------------------+
74LS1384.2.5 Memory address decoding
Memory chips require address decoding to interface with the 8085 16-bit address bus:
- Determining Address Lines for Memory Chip: A memory chip with capacity C bytes requires k address lines such that 2^k = C.
- For an 8 KB memory IC (8192 bytes): 2^13 = 8192, so 13 address lines (A12 to A0) connect directly to the memory chip address pins.
- For a 4 KB memory IC (4096 bytes): 2^12 = 4096, so 12 address lines (A11 to A0) connect to the chip.
- For a 2 KB memory IC (2048 bytes): 2^11 = 2048, so 11 address lines (A10 to A0) connect to the chip.
- Connecting Higher-Order Address Lines to Decoder: The remaining higher-order address lines (e.g., A15, A14, A13 for an 8 KB chip) are routed to a decoder like the 74LS138 to generate individual chip enable (
CE_barorCS_bar) signals. - Control Line Connection:
- For EPROM (e.g., 2764): Connect
MEMR_barto theOE_bar(Output Enable) pin. - For SRAM (e.g., 6264): Connect
MEMR_bartoOE_bar, andMEMW_bartoWE_bar(Write Enable). - Connect the decoded chip select output from the 74LS138 to
CE_bar(orCS_bar).
- For EPROM (e.g., 2764): Connect
Worked Examples
Full Memory Interface Design (8 KB EPROM and 8 KB SRAM)
Design an absolute address decoding interface for an 8085 microprocessor system with:
- One 8 KB EPROM (2764) starting at address 0000H.
- One 8 KB Static RAM (6264) starting at address 8000H.
Use a 74LS138 (3-to-8 line decoder) and minimal additional logic gates. Determine the address range for each chip, construct the address decoding map table, and show decoder input/enable connections.
Determine Required Address Lines for Memory Chips:
- Total capacity of EPROM = 8 KB = 8 x 1024 bytes = 8192 bytes. Since 2^13 = 8192, exactly 13 address lines (A12 through A0) must be wired directly to the address pins of the 2764 EPROM.
- Total capacity of SRAM = 8 KB = 8 x 1024 bytes = 8192 bytes. Similarly, address lines A12 through A0 are wired directly to the address pins of the 6264 SRAM.
- The remaining 3 upper address lines of the 8085 (A15, A14, A13) are available for chip selection via the 74LS138 decoder.
Construct the Address Map:
- EPROM (2764): Starts at 0000H. A15 = 0, A14 = 0, A13 = 0. Internal address lines A12 to A0 vary from all 0s to all 1s:
- Minimum address: 000 0 0000 0000 0000B = 0000H
- Maximum address: 000 1 1111 1111 1111B = 1FFFH
- SRAM (6264): Starts at 8000H. A15 = 1, A14 = 0, A13 = 0. Internal address lines A12 to A0 vary from all 0s to all 1s:
- Minimum address: 100 0 0000 0000 0000B = 8000H
- Maximum address: 100 1 1111 1111 1111B = 9FFFH
Address Decoding Table:
| Memory Device | A15 | A14 | A13 | A12–A0 | Hex Range | Decoder Output |
|---|---|---|---|---|---|---|
| 8 KB EPROM (2764) | 0 | 0 | 0 | 0000H to 1FFFH | 0000H – 1FFFH | Y0_bar |
| Unassigned | 0 | 0 | 1 | 0000H to 1FFFH | 2000H – 3FFFH | Y1_bar |
| Unassigned | 0 | 1 | 0 | 0000H to 1FFFH | 4000H – 5FFFH | Y2_bar |
| Unassigned | 0 | 1 | 1 | 0000H to 1FFFH | 6000H – 7FFFH | Y3_bar |
| 8 KB SRAM (6264) | 1 | 0 | 0 | 0000H to 1FFFH | 8000H – 9FFFH | Y4_bar |
Hardware Interconnection Details:
- 74LS138 Decoder Connections:
- Address select inputs: Connect A13 to A (pin 1), A14 to B (pin 2), and A15 to C (pin 3).
- Enable inputs:
- Connect 8085
IO/M_barto active-low enableG2A_bar(pin 4). This ensures the decoder operates only during memory cycles (IO/M_bar = 0). - Ground
G2B_bar(pin 5) to 0V. - Connect active-high enable
G1(pin 6) to +5V (Vcc).
- Connect 8085
- Chip Select Connections:
- Connect output
Y0_bar(pin 15) toCE_barof the 2764 EPROM. - Connect output
Y4_bar(pin 11) toCE_barof the 6264 SRAM.
- Connect output
- Control Signals:
- Connect
MEMR_bartoOE_barof the 2764 EPROM. - Connect
MEMR_bartoOE_barandMEMW_bartoWE_barof the 6264 SRAM.
- Connect
The 8 KB EPROM spans 0000H to 1FFFH (selected by Y0_bar), and the 8 KB SRAM spans 8000H to 9FFFH (selected by Y4_bar). Address lines A12 to A0 connect directly to memory chips, while A15 to A13 drive 74LS138 inputs C, B, A with G2A_bar driven by IO/M_bar.
I/O Mapped I/O Interface and Assembly Routine
An 8085 microprocessor is interfaced to an 8-bit input port (DIP switches) at I/O address 80H and an 8-bit output port (LED display) at I/O address 81H.
Write an assembly language program to read the 8-bit switch pattern from Port 80H, invert all bits, and output the result to Port 81H. Show register status, machine cycles, and timing specifications.
Assembly Language Program:
ORG 2000H
IN 80H
CMA
OUT 81H
HLTLine-by-Line Execution and Register Trace: Assume initially that the DIP switches set Port 80H data to 55H (0101 0101B).
IN 80H: Reads the byte 55H from input port 80H into the Accumulator. Machine cycles: Opcode Fetch (4T), Memory Read (3T), I/O Read (3T) = 10 T-states total.
CMA: Complements each bit of the Accumulator: NOT(55H) = AAH (1010 1010B). Machine cycles: Opcode Fetch (4T) = 4 T-states. Flags are unaffected by CMA.
OUT 81H: Sends the inverted byte (AAH) from the Accumulator to output port 81H. Machine cycles: Opcode Fetch (4T), Memory Read (3T), I/O Write (3T) = 10 T-states total.
The program reads 55H from Port 80H via IN 80H (10 T-states), inverts it to AAH via CMA (4 T-states), and sends AAH to Port 81H via OUT 81H (10 T-states). Total execution time is 24 T-states.
Non-Unique (Partial) Address Decoding Analysis
In an 8085-based industrial controller, an 8-bit output port is interfaced using partial address decoding in I/O-mapped mode. The decoder decodes only address lines A7 and A6 such that A7 = 1 and A6 = 0 generates the active-low device select signal. Address lines A5 through A0 are left unconnected (don't care bits).
- Determine the base (minimum) address of the port.
- Determine the maximum address of the port.
- Calculate the total number of alias (shadow) addresses generated.
Identify Decoded and Don't Care Address Bits: In I/O mapped I/O, the port address has 8 bits: A7 through A0. The decoding conditions specify:
- A7 = 1 (fixed)
- A6 = 0 (fixed)
- A5 through A0 = X (6 don't care bits)
Determine Minimum and Maximum Addresses:
- Minimum (Base) Address: Set all don't care bits (A5 to A0) to logic 0: Address = 1000 0000B = 80H
- Maximum Address: Set all don't care bits (A5 to A0) to logic 1: Address = 1011 1111B = BFH
Calculate Number of Shadow Addresses: Since there are 6 unmonitored address lines (A5, A4, A3, A2, A1, A0), each unmonitored line can independently assume 2 states (0 or 1). Total number of alias addresses = 2^6 = 64.
Any IN or OUT instruction targeting any address from 80H through BFH will activate this same physical output port.
Base address = 80H, maximum address = BFH, and total alias addresses = 64 (spanning 80H to BFH).
Exercises
Exercises
Design an absolute address decoding scheme for an 8085 system requiring 16 KB of EPROM (implemented using two 8 KB 2764 chips) mapped to 0000H–3FFFH and 8 KB of SRAM (using one 8 KB 6264 chip) mapped to A000H–BFFFH. Show decoder select lines, address ranges, and control line connections using a 74LS138.
Calculate Memory Capacities and Address Line Allocation:
- Each 8 KB memory chip requires 13 address lines (2^13 = 8192 bytes), so address lines A12 to A0 are wired directly to the address pins of all three memory chips.
- Total EPROM capacity = 16 KB = 2 chips x 8 KB = 16,384 bytes, mapped contiguously from 0000H to 3FFFH.
- EPROM 1: 0000H to 1FFFH (8 KB)
- EPROM 2: 2000H to 3FFFH (8 KB)
- Total SRAM capacity = 8 KB = 8192 bytes, mapped from A000H to BFFFH.
- Remaining upper address lines (A15, A14, A13) are decoded using a 74LS138 decoder.
Address Range Decoding Table:
| Memory Chip | A15 | A14 | A13 | Address Span | 74LS138 Output |
|---|---|---|---|---|---|
| EPROM 1 (2764) | 0 | 0 | 0 | 0000H – 1FFFH | Y0_bar |
| EPROM 2 (2764) | 0 | 0 | 1 | 2000H – 3FFFH | Y1_bar |
| Unused | 0 | 1 | 0 | 4000H – 5FFFH | Y2_bar |
| Unused | 0 | 1 | 1 | 6000H – 7FFFH | Y3_bar |
| Unused | 1 | 0 | 0 | 8000H – 9FFFH | Y4_bar |
| SRAM (6264) | 1 | 0 | 1 | A000H – BFFFH | Y5_bar |
| Unused | 1 | 1 | 0 | C000H – DFFFH | Y6_bar |
| Unused | 1 | 1 | 1 | E000H – FFFFH | Y7_bar |
Hardware Connections:
- Connect 8085 address lines A13, A14, A15 to 74LS138 inputs A (pin 1), B (pin 2), and C (pin 3) respectively.
- Connect
IO/M_bartoG2A_bar(pin 4), groundG2B_bar(pin 5), and connectG1(pin 6) to +5V. - Wire decoder output
Y0_bartoCE_barof EPROM 1,Y1_bartoCE_barof EPROM 2, andY5_bartoCE_barof SRAM. - Connect
MEMR_bartoOE_barof EPROM 1, EPROM 2, and SRAM. ConnectMEMW_bartoWE_barof SRAM.
EPROM 1 occupies 0000H–1FFFH (Y0_bar), EPROM 2 occupies 2000H–3FFFH (Y1_bar), and SRAM occupies A000H–BFFFH (Y5_bar). Inputs A, B, C are fed by A13, A14, A15, and G2A_bar is enabled by IO/M_bar = 0.
Compare Memory Mapped I/O and Peripheral (I/O) Mapped I/O across five key architectural criteria. Then design an absolute address decoding circuit using NAND gates and inverters to generate an active-low device select signal for a memory-mapped output port at address C000H.
Comparison Across Architectural Criteria:
- Address Space: Peripheral-mapped I/O provides a dedicated 8-bit address space (256 ports), while Memory-mapped I/O uses 16-bit addresses and shares the 64 KB memory space.
- Control Signals: Peripheral-mapped I/O uses
IOR_barandIOW_bar(IO/M_bar = 1), whereas Memory-mapped I/O usesMEMR_barandMEMW_bar(IO/M_bar = 0). - Instruction Set: Peripheral-mapped I/O is restricted to
INandOUTinstructions, while Memory-mapped I/O supports all memory reference instructions (MOV,LDA,STA,ADD M, etc.). - Data Registers: Peripheral-mapped I/O transfers data solely through the Accumulator, whereas Memory-mapped I/O can transfer data to/from any internal register (A, B, C, D, E, H, L).
- Decoder Hardware: Peripheral-mapped I/O requires decoding only 8 address lines (A7–A0), whereas Memory-mapped I/O requires decoding all 16 address lines (A15–A0).
Address Decoding Circuit Design for Port at C000H: The memory address is C000H = 1100 0000 0000 0000B:
- A15 = 1, A14 = 1.
- A13 through A0 = 0 (14 lines at logic 0).
- Operation requires
IO/M_bar = 0andWR_bar = 0(orMEMW_bar = 0).
Design implementation:
- Pass address lines A13 through A0 through inverters to make them logic 1.
- Route A15, A14, and inverted A13–A0 into a tree of NAND/AND gates (or two cascaded 8-input NAND gates) to produce a single active-HIGH match signal when
Address = C000H. - Invert
IO/M_barand combine with the address match signal andWR_barvia a NOR gate (or active-low enable logic) to assert the clock/enable pin of an octal latch (74LS374).
Memory Mapped I/O uses 16-bit addresses, shares the 64 KB address space, uses MEMR_bar/MEMW_bar, and supports any register and memory instruction. The decoder for address C000H decodes A15=1, A14=1, A13–A0=0, and asserts when MEMW_bar is active.
In an 8085 microprocessor system, an input port is interfaced using partial decoding. Address lines A7, A6, and A5 are decoded such that A7 = 0, A6 = 1, and A5 = 1 activates the port. Address lines A4 through A0 are left unconnected.
Determine:
- The base (minimum) hex address of the port.
- The maximum hex address of the port.
- The total number of alias (shadow) addresses.
Analyze Address Bits: The port is interfaced in I/O mapped mode with an 8-bit port address (A7 to A0):
- Decoded bits: A7 = 0, A6 = 1, A5 = 1 (fixed binary prefix: 011B)
- Unconnected bits: A4, A3, A2, A1, A0 (5 don't care bits, X)
Determine Minimum and Maximum Hex Addresses:
- Minimum address (all don't care bits = 0): 011 00000B = 60H
- Maximum address (all don't care bits = 1): 011 11111B = 7FH
Calculate Number of Shadow Addresses: With 5 don't care bits, the number of distinct combinations is: Total alias addresses = 2^5 = 32.
The port responds to any address in the inclusive range 60H to 7FH.
Base address = 60H, maximum address = 7FH, and total alias addresses = 32.
Explain why demultiplexing of the address/data bus (AD7–AD0) is mandatory in an 8085 microprocessor system. Describe the circuit operation using a 74LS373 octal latch and the ALE signal.
Why Demultiplexing is Mandatory: The 8085 microprocessor uses multiplexed pins AD7–AD0 to reduce physical pin count to 40 pins. During the first clock period (T1) of every machine cycle, these pins carry the low-order address bits (A7–A0). During subsequent clock periods (T2, T3, T4), the same pins carry bidirectional 8-bit data (D7–D0).
Memory chips and peripheral devices require address lines to remain completely stable throughout the entire read or write cycle. If AD7–AD0 were connected directly to memory address pins, the memory would see address bits during T1, but as soon as the bus switched to data during T2/T3, the memory would read its own data as a changing address, causing corrupted bus operations. Therefore, the address must be latched externally during T1 and held stable for the remainder of the cycle.
Circuit Operation with 74LS373 Octal Latch:
- Connections: Lines AD7–AD0 from the 8085 connect to data inputs 1D–8D of the 74LS373. The 8085 ALE pin connects to the Latch Enable (LE / G) pin 11. Output Enable (
OE_bar, pin 1) is tied to ground (0V). Latch outputs 1Q–8Q become the dedicated address bus A7–A0. - Operation during T1 State: The 8085 places A7–A0 on AD7–AD0 and asserts ALE HIGH. While ALE is HIGH, the 74LS373 latch is transparent: outputs 1Q–8Q follow inputs 1D–8D.
- Latching at Falling Edge of ALE: Near the end of T1, ALE drops from HIGH to LOW. This falling edge latches the current states of AD7–AD0 into the internal flip-flops of the 74LS373.
- Operation during T2, T3, T4: Throughout T2, T3, and T4, ALE remains LOW, locking the latched address on outputs A7–A0. Meanwhile, the 8085 floats AD7–AD0 and uses them for reading or writing data bytes D7–D0 without disturbing the latched address lines.
Demultiplexing is required because memory needs stable address lines throughout T1–T3, while AD7–AD0 switches from address to data after T1. The 74LS373 uses the falling edge of ALE to capture and hold A7–A0 stable while AD7–AD0 transmits data D7–D0.
Design an interface for an 8-bit input port at I/O address 20H (using a 74LS244 octal buffer) and an 8-bit output port at I/O address 30H (using a 74LS374 octal latch) with an 8085 microprocessor using a 74LS138 decoder.
Write an 8085 assembly language subroutine to read the byte from Port 20H, mask off the lower 4 bits, shift the upper nibble into the lower 4 bit positions, and display the result at Port 30H. Include register states.
Hardware Interfacing Design:
- Address lines A7, A6, A5, A4 are decoded:
- Port 20H = 0010 0000B (A7=0, A6=0, A5=1, A4=0)
- Port 30H = 0011 0000B (A7=0, A6=0, A5=1, A4=1)
- Use 74LS138: Connect A4 to input A, A5 to input B, A6 to input C.
- Connect A7 to
G2A_bar(must be 0),IO/M_barinverted toG1(must be 1 for I/O), and groundG2B_bar. - When address is 20H, CBA = 010B (Y2_bar goes LOW). Combine Y2_bar with
IOR_barusing an OR gate to driveOE_barof the 74LS244 buffer. - When address is 30H, CBA = 011B (Y3_bar goes LOW). Combine Y3_bar with
IOW_barusing an OR gate to clock the 74LS374 latch.
- Connect A7 to
Assembly Subroutine:
ORG 2050H
IN 20H
ANI F0H
RRC
RRC
RRC
RRC
OUT 30H
RETTrace with Sample Data: Assume input at Port 20H is B4H (1011 0100B).
IN 20H: Accumulator = B4H.ANI F0H: Accumulator = B0H (masks lower nibble).- Four
RRCinstructions rotate B0H right four times:- 1st RRC: 0101 1000B = 58H
- 2nd RRC: 0010 1100B = 2CH
- 3rd RRC: 0001 0110B = 16H
- 4th RRC: 0000 1011B = 0BH
Flags: ANI F0H sets S = 1 (result B0H), Z = 0, AC = 1 (the 8085 always sets AC on ANA/ANI), P = 0 (three 1s in B0H) and CY = 0. RRC changes only CY, and each rotated-out bit is 0, so the flags stay S=1, Z=0, AC=1, P=0, CY=0.
OUT 30H: Sends 0BH to Port 30H.
The circuit decodes Port 20H (74LS244 buffer enabled by Y2_bar OR IOR_bar) and Port 30H (74LS374 latch clocked by Y3_bar OR IOW_bar). The assembly routine reads Port 20H, masks with F0H, rotates right 4 times to move the upper nibble into the lower nibble (e.g. B4H becomes 0BH), and writes to Port 30H.