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
Data_In3, Data_In2, Data_In1, Data_In0, Write_Enable, Inject_Error, Clock, nReset.Data_Out[3], Data_Out[2], Data_Out[1], Data_Out[0], Error.Write_Enable = 1 stores data and parity together on the rising Clock edge; Write_Enable = 0 holds them.nReset = 0 asynchronously clears all five stored bits and has priority over Write_Enable.INJ_XOR read path unchanged.Data_Out[0]; do not connect Inject_Error directly to Error.| Condition | Behavior |
|---|---|
nReset = 0 | Clear stored data and parity. |
Write_Enable = 1 | Store Data_In3..0 and even parity on the rising clock edge. |
Write_Enable = 0 | Hold the stored value. |
Inject_Error = 1 | Invert only Data_Out[0]. |
| Parity error | Error = 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.
A memory is described as:
Depth Γ Word Width
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.
βββββββββββββββββββββ
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.
| Case | Behavior |
|---|---|
| Asynchronous Read | Data_Out follows the selected address after access delay. |
| Synchronous Read | Data becomes valid according to a defined clock-cycle latency. |
| Read-First during R/W | Same-address read/write returns old data. |
| Write-First during R/W | Same-address read/write returns new data. |
| No-Change during R/W | Same-address read/write keeps the previous output. |
Access time is expressed in time, while read latency is expressed in clock cycles.
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 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.
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 stores fixed or preinitialized data and retains its contents without power.
| Type | Update Behavior |
|---|---|
| Mask ROM | Programmed during manufacture; normally not changed afterward |
| EEPROM | Electrically erasable and reprogrammable |
| Flash | Non-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.
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.
| Command | Purpose |
|---|---|
ACTIVATE | Opens the required row |
READ / WRITE | Accesses data in the open row |
PRECHARGE | Closes the currently open row |
REFRESH | Restores stored information periodically |
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.
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 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 | Volatile? | Relative Characteristic | Update Behavior | Typical Use |
|---|---|---|---|---|
| SRAM | Yes | Fast access, lower density | Direct read/write | Small fast storage |
| ROM | No | Fixed/preinitialized storage | Normally fixed | Constants and lookup tables |
| DRAM | Yes | High density | Read/write + refresh | Large working memory |
| EEPROM | No | Reprogrammable NVM | Electrical erase/write | Configuration storage |
| Flash | No | Dense NVM | Program + erase regions | Bulk non-volatile storage |
Memory selection depends on required volatility, access latency, density, update behavior, and application role.
A register file is a small structured memory optimized for fast access near datapaths.
A typical 2-read / 1-write register file provides:
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.
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
| Architecture | Access Capability |
|---|---|
| Single-Port | One shared access port |
| Simple Dual-Port | Separate read and write ports |
| True Dual-Port | Two 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.
When two ports access the same address, the required behavior must be defined.
For the dual-port behavior defined here:
| Collision | Behavior |
|---|---|
| Read / Write, same address | Read-first: the read observes old data on the write edge |
| Write / Write, same address | Collision = 1; Port A wins and Port B write is blocked |
Same-address behavior should never be assumed from the term dual-port alone.
| Property | Register File | RAM |
|---|---|---|
| Typical Size | Small | Small to very large |
| Main Role | Fast operand/state access near datapaths | General data storage |
| Ports | Often multiple dedicated read/write ports | Depends on memory architecture |
| Hardware Cost | Increases quickly with more ports | Usually more area-efficient for larger storage |
More ports improve concurrent access, but increase hardware and routing cost.
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:
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.
| Status | Meaning |
|---|---|
| Empty | No valid entries are available to read |
| Full | No free entries are available to write |
| Occupancy | Number 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.
| Operation | Effect |
|---|---|
| Write only | Store data, advance the write pointer, occupancy +1 |
| Read only | Output data, advance the read pointer, occupancy -1 |
| Valid Read + Write | Both operations occur; occupancy is unchanged |
| Blocked Write | No state change when Full = 1 |
| Blocked Read | No state change when Empty = 1 |
Data_Out updates only on an accepted read and otherwise retains its previous value.
Reset clears the FIFO's logical state:
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.
| Implementation | Typical Characteristic |
|---|---|
| Register-Based FIFO | Simple and suitable for small FIFOs |
| RAM-Based FIFO | More 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 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 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.
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
| Requests | Result |
|---|---|
| Different banks | Both requests may proceed |
| Same bank | Bank conflict occurs |
| Same bank with fixed priority | Requester 0 is granted; Requester 1 waits |
An arbiter applies the defined priority rule so competing requests are resolved deterministically.
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.
A Content-Addressable Memory (CAM) searches stored entries by content rather than by address.
| Memory | Access Method |
|---|---|
| RAM | Provide an address to read or write a location |
| CAM | Provide a search key and find matching stored entries |
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.
| Output | Meaning |
|---|---|
Match | Indicates that at least one valid entry matches |
Match_Index | Identifies 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
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.
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.
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.
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:
Detailed Hamming-code derivation is outside this topic.
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.
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.
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.
Different storage architectures solve different design problems.
| Architecture | Typical Selection Reason |
|---|---|
| SRAM | Low access latency |
| DRAM | High storage density |
| Flash | Non-volatile storage |
| Register File | Fast multi-port operand access |
| FIFO | Ordered buffering |
| CAM | Search by content |
| Banked Memory | Higher concurrent throughput |
| Multi-Port Memory | Multiple simultaneous accesses |
Architecture selection depends on capacity, latency, throughput, volatility, and access requirements.