49. Parity-Protected Stored Word

Task Description

Complete the parity storage, generation, and checking logic in the supplied 4-bit stored-word circuit. The completed circuit must store even parity with the data and detect the provided bit-0 read error.

Constraints

  1. Inputs: Data_In3, Data_In2, Data_In1, Data_In0, Write_Enable, Inject_Error, Clock, nReset.
  2. Outputs: Data_Out[3], Data_Out[2], Data_Out[1], Data_Out[0], Error.
  3. Write_Enable = 1 stores data and parity together on the rising Clock edge; Write_Enable = 0 holds them.
  4. nReset = 0 asynchronously clears all five stored bits and has priority over Write_Enable.
  5. Read operation is combinational.
  6. Use even parity and keep the supplied data-storage and INJ_XOR read path unchanged.
  7. The checker must use the read-side Data_Out[0]; do not connect Inject_Error directly to Error.

Behavioral Reference

ConditionBehavior
nReset = 0Clear stored data and parity.
Write_Enable = 1Store Data_In3..0 and even parity on the rising clock edge.
Write_Enable = 0Hold the stored value.
Inject_Error = 1Invert only Data_Out[0].
Parity errorError = 1
Parity_In = Data_In3 XOR Data_In2 XOR Data_In1 XOR Data_In0

Error = Data_Out[3] XOR Data_Out[2] XOR
        Data_Out[1] XOR Data_Out[0] XOR Stored_Parity

Data_Out[3:0] and Error are combinational read outputs, so they update after input/read-path changes without a clock edge.

Need Help? Refer to the Quick Guide below

Memory Organization and Access

Memory Organization

A memory is described as:

Depth Γ— Word Width

  • Depth β€” number of addressable locations
  • Word Width β€” bits stored at each location

Capacity = Depth Γ— Word Width

For a memory with D locations:

Address bits = ceil(log2(D))

Example: 256 Γ— 8 β†’ 2048 bits capacity and 8 address bits.

Memory Interface

                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Address ───────►│                   β”‚
Data_In ───────►│      Memory       │──────► Data_Out
CS / EN ───────►│                   β”‚
WE ────────────►│                   β”‚
OE / RE ───────►│                   β”‚
Clock* ────────►│                   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CS/EN selects the memory, WE controls writing, and OE/RE controls reading/output.

When the memory is not enabled, no access occurs; the exact control polarity depends on the specified memory interface.

*Clock is used for synchronous memory operations.

Writes are rising-edge synchronous unless stated otherwise. Unwritten locations are undefined unless initialized.

Read Behavior

CaseBehavior
Asynchronous ReadData_Out follows the selected address after access delay.
Synchronous ReadData becomes valid according to a defined clock-cycle latency.
Read-First during R/WSame-address read/write returns old data.
Write-First during R/WSame-address read/write returns new data.
No-Change during R/WSame-address read/write keeps the previous output.

Access time is expressed in time, while read latency is expressed in clock cycles.

Memory Expansion

Smaller memories can be combined to increase word width or depth.

Width Expansion: Two 4 Γ— 4 memories β†’ 4 Γ— 8

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Address ────────►│   4 Γ— 4   │────► Data[3:0]
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β–²
                      β”‚ Same Address
                      β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Address ────────►│   4 Γ— 4   │────► Data[7:4]
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Depth Expansion: Two 4 Γ— 4 memories β†’ 8 Γ— 4

                       A2
                        β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Memory Selectβ”‚
                 β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚                 β”‚
          CS0 = A2'          CS1 = A2
               β”‚                 β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
A1:A0 ─►│    4 Γ— 4    β”‚   β”‚    4 Γ— 4    │◄─ A1:A0
        β”‚  Memory 0   β”‚   β”‚  Memory 1   β”‚
        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
               β”‚                 β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β–Ό
               Selected Data[3:0]

For depth expansion, higher address bits select the memory or bank, while lower bits select the local address.

Address Decoding

Address decoding generates the required CS or bank-select signals so only the intended memory responds.

Incomplete decoding can cause address aliasing, where multiple system addresses access the same physical location.

SRAM, ROM, DRAM and Flash

SRAM

Static RAM (SRAM) is fast, volatile memory that retains stored data while power is present and does not require periodic refresh.

SRAM is commonly used where low access latency is more important than storage density.

ROM and Non-Volatile Memory

ROM stores fixed or preinitialized data and retains its contents without power.

TypeUpdate Behavior
Mask ROMProgrammed during manufacture; normally not changed afterward
EEPROMElectrically erasable and reprogrammable
FlashNon-volatile memory programmed and erased electrically, typically in larger regions

ROM-type storage is useful for fixed tables, constants, configuration data, and firmware-like contents.

DRAM Organization and Access

Dynamic RAM (DRAM) provides dense volatile storage and requires periodic refresh.

DRAM is organized conceptually into:

DRAM
 └─ Banks
     └─ Rows
         └─ Columns

A row must be opened before data in that row can be accessed.

CommandPurpose
ACTIVATEOpens the required row
READ / WRITEAccesses data in the open row
PRECHARGECloses the currently open row
REFRESHRestores stored information periodically

DRAM Row Access Cases

The required command sequence depends on the current open-row state.

Closed Row   β†’ ACTIVATE β†’ READ / WRITE
Row Hit      β†’ READ / WRITE
Row Conflict β†’ PRECHARGE β†’ ACTIVATE β†’ READ / WRITE

A row hit avoids reopening the row, while a row conflict requires the existing row to be closed before another row can be activated.

DRAM Refresh

Refresh periodically restores DRAM information and may temporarily delay normal memory accesses.

At the architectural level, refresh is treated as a controller-scheduled memory operation rather than as a device-physics process.

Flash Program and Erase

Flash memory is non-volatile.

Program: 1 β†’ 0

Erase: restores the erase region to 1

Programming and erasing therefore have different behavior; an already-programmed 0 is not simply changed back to 1 by another program operation.

Memory-Type Comparison

MemoryVolatile?Relative CharacteristicUpdate BehaviorTypical Use
SRAMYesFast access, lower densityDirect read/writeSmall fast storage
ROMNoFixed/preinitialized storageNormally fixedConstants and lookup tables
DRAMYesHigh densityRead/write + refreshLarge working memory
EEPROMNoReprogrammable NVMElectrical erase/writeConfiguration storage
FlashNoDense NVMProgram + erase regionsBulk non-volatile storage

Memory selection depends on required volatility, access latency, density, update behavior, and application role.

Register Files and Multi-Port Memory

Register File

A register file is a small structured memory optimized for fast access near datapaths.

A typical 2-read / 1-write register file provides:

  • two independent read addresses and outputs;
  • one write address and input;
  • one write enable.
                    Write_Data
                        β”‚
Write_Addr ──► Write Decoder
                        β”‚
                   Write Select
                        β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Register    β”‚
                 β”‚    Bank     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
                   β”‚         β”‚
Read_Addr_A ───► Read MUX A  β”‚
                   β”‚         β”‚
                   β–Ό         β”‚
              Read_Data_A    β”‚
                             β”‚
Read_Addr_B ─────────► Read MUX B
                             β”‚
                             β–Ό
                        Read_Data_B

Internally, the write decoder selects the destination entry, while independent read MUX paths select the two read outputs.

2-Read / 1-Write Behavior

  • Reads are combinational.
  • Writes occur on the rising clock edge.
  • Both read ports operate independently.
  • One entry is updated when Write_Enable = 1.

For same-address read/write access, there is no bypass unless explicitly stated.

Before write edge β†’ Read shows old data
After write edge  β†’ Read shows newly stored data

Single-Port and Dual-Port Memory

ArchitectureAccess Capability
Single-PortOne shared access port
Simple Dual-PortSeparate read and write ports
True Dual-PortTwo independently controlled read/write ports

Multi-port memories improve concurrency because more than one access can occur in the same cycle.

Different-address operations may proceed concurrently when the architecture supports them.

Dual-Port Collisions

When two ports access the same address, the required behavior must be defined.

For the dual-port behavior defined here:

CollisionBehavior
Read / Write, same addressRead-first: the read observes old data on the write edge
Write / Write, same addressCollision = 1; Port A wins and Port B write is blocked

Same-address behavior should never be assumed from the term dual-port alone.

Register File vs RAM

PropertyRegister FileRAM
Typical SizeSmallSmall to very large
Main RoleFast operand/state access near datapathsGeneral data storage
PortsOften multiple dedicated read/write portsDepends on memory architecture
Hardware CostIncreases quickly with more portsUsually more area-efficient for larger storage

More ports improve concurrent access, but increase hardware and routing cost.

FIFO Storage Architecture

FIFO Principle

A First-In, First-Out (FIFO) stores data in the same order in which it is written.

Write_Data ──► [ FIFO Storage ] ──► Data_Out
                  β–²       β–²
                  β”‚       β”‚
             Write Ptr  Read Ptr
                  β”‚       β”‚
               Status / Control

A FIFO typically contains:

  • a storage array;
  • a write pointer;
  • a read pointer;
  • occupancy/status logic.

Circular Buffer and Pointers

The write pointer selects the next location to receive data, while the read pointer selects the oldest valid entry.

0 β†’ 1 β†’ 2 β†’ 3
↑           ↓
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

After the final location, the pointer wraps around to the first location.

Empty, Full and Occupancy

StatusMeaning
EmptyNo valid entries are available to read
FullNo free entries are available to write
OccupancyNumber of valid entries currently stored

Access is accepted only when valid:

Write accepted when Full = 0

Read accepted when Empty = 0

Blocked accesses must not change the FIFO state.

Read and Write Behavior

OperationEffect
Write onlyStore data, advance the write pointer, occupancy +1
Read onlyOutput data, advance the read pointer, occupancy -1
Valid Read + WriteBoth operations occur; occupancy is unchanged
Blocked WriteNo state change when Full = 1
Blocked ReadNo state change when Empty = 1

Data_Out updates only on an accepted read and otherwise retains its previous value.

FIFO Reset

Reset clears the FIFO's logical state:

  • read pointer;
  • write pointer;
  • occupancy/status.

Data_Out may be reset to a defined value, but the payload storage itself does not need to be erased because Empty indicates that no stored entry is currently valid.

Register-Based vs RAM-Based FIFO

ImplementationTypical Characteristic
Register-Based FIFOSimple and suitable for small FIFOs
RAM-Based FIFOMore storage-efficient for larger FIFOs

An asynchronous FIFO allows read and write operations in different clock domains, but its CDC implementation is outside this topic.

Memory Banking and Arbitration

Memory Banking

Memory banking divides storage into independently accessible banks.

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Address ────────►│ Bank     β”‚
                 β”‚ Select   β”‚
                 β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                      β”‚
               β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
               β”‚             β”‚
          β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
          β”‚ Bank 0  β”‚   β”‚ Bank 1  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The address is divided into:

Bank-select bits β†’ Target bank

Local-address bits β†’ Location inside that bank

Interleaving

Interleaving distributes sequential addresses across different banks.

Example: two-bank interleaving

Address 0 β†’ Bank 0
Address 1 β†’ Bank 1
Address 2 β†’ Bank 0
Address 3 β†’ Bank 1

Here, one address bit selects the bank while the remaining bits form the local address.

Parallel Access, Conflicts and Arbitration

Requests to different banks may proceed concurrently. Requests targeting the same bank create a bank conflict and require arbitration.

Example fixed-priority policy:

Requester 0 > Requester 1

RequestsResult
Different banksBoth requests may proceed
Same bankBank conflict occurs
Same bank with fixed priorityRequester 0 is granted; Requester 1 waits

An arbiter applies the defined priority rule so competing requests are resolved deterministically.

Throughput and Latency

Banking primarily improves throughput by allowing accesses to different banks in parallel.

It does not inherently reduce the intrinsic latency of a single memory access.

Content-Addressable Memory

RAM vs CAM

A Content-Addressable Memory (CAM) searches stored entries by content rather than by address.

MemoryAccess Method
RAMProvide an address to read or write a location
CAMProvide a search key and find matching stored entries

CAM Entry and Search

Each CAM entry contains:

Valid + Key

Only entries with Valid = 1 participate in a search.

Search_Key
    β”‚
    β”œβ”€β”€β”€β”€β–Ί Entry 0: Valid + Key ─► Compare
    β”œβ”€β”€β”€β”€β–Ί Entry 1: Valid + Key ─► Compare
    β”œβ”€β”€β”€β”€β–Ί Entry 2: Valid + Key ─► Compare
    └────► Entry 3: Valid + Key ─► Compare
                            β”‚
                            β–Ό
                     Priority Select
                            β”‚
                    Match / Match_Index

CAM search is combinational: all valid entries are compared with Search_Key in parallel.

Match Outputs

OutputMeaning
MatchIndicates that at least one valid entry matches
Match_IndexIdentifies the selected matching entry

If no valid entry matches:

Match = 0

When multiple valid entries match, the lowest matching index wins.

Matching entries: 1 and 3
Selected Match_Index: 1

Write and Update

A CAM entry can be added or replaced by selecting an entry and updating its stored Key and Valid state.

Write_Index + Key_In + Valid_In
              β”‚
              β–Ό
        Selected CAM Entry

The selected entry is updated on the rising clock edge when writing is enabled.

TCAM Awareness

A Ternary CAM (TCAM) extends CAM matching by allowing masked or don't-care bits in stored entries.

This enables a stored entry to match more than one exact binary key.

Memory Reliability and Control

Parity Protection

Stored or transferred data may become corrupted. Parity provides a simple way to detect selected error patterns.

With even parity, the total number of 1 bits in the protected word, including the parity bit, is even.

Write: Data ──► Generate Parity ──► Store Data + Parity

Read:  Data + Parity ──► Recompute / Check ──► Error

Parity can detect errors, but it does not identify or correct the corrupted bit.

ECC and SECDED

Error-Correcting Codes (ECC) use additional check bits to provide stronger protection than parity.

A syndrome represents the result of the ECC check and can indicate error status or location.

SECDED provides:

  • Single-Error Correction β€” correct one corrupted bit;
  • Double-Error Detection β€” detect two corrupted bits.

Detailed Hamming-code derivation is outside this topic.

Memory Controller and Transactions

A memory controller sequences transactions and coordinates memory availability.

Request
   β”‚
   β–Ό
Accept ──► Access / Wait ──► Complete
              β”‚
           Busy / Wait

A request is accepted only when the controller is ready. Required request fields are captured at acceptance and held while the transaction is active.

Later changes on external request inputs do not alter the active transaction.

Ready or Done indicates completion. When Done is used, it is a one-clock pulse unless otherwise specified.

A new request may be accepted when the controller returns to its ready/idle state.

Multiple requesters may require arbitration before a transaction begins.

DRAM Command Sequencing

A DRAM controller converts memory requests into command sequences based on the currently open row.

Closed Row   β†’ ACTIVATE β†’ READ / WRITE
Row Hit      β†’ READ / WRITE
Row Conflict β†’ PRECHARGE β†’ ACTIVATE β†’ READ / WRITE

Each DRAM command in this simplified controller sequence occupies one controller cycle.

Refresh and Open-Row Tracking

The controller tracks the currently open row and schedules refresh when required.

No row open β†’ REFRESH
Row open    β†’ PRECHARGE β†’ REFRESH

Refresh has priority when the controller becomes idle and leaves the row state closed.

Architecture Selection

Different storage architectures solve different design problems.

ArchitectureTypical Selection Reason
SRAMLow access latency
DRAMHigh storage density
FlashNon-volatile storage
Register FileFast multi-port operand access
FIFOOrdered buffering
CAMSearch by content
Banked MemoryHigher concurrent throughput
Multi-Port MemoryMultiple simultaneous accesses

Architecture selection depends on capacity, latency, throughput, volatility, and access requirements.