§ 5.3. Memory Subsystem¶
Main memory, as the bus sees it: one memory with two ports, I_ for
instruction fetch and D_ for data. Inside, an optional small cache sits on
each port, the two-port arbiter
takes turns, an optional shared cache sits below it, then one memory
endpoint. The shared-memory arrangements of
§ 4.7 and the memory-system experiments of
§ 4.8 are built from this part.
| Component | Description | Structural | Behavioral |
|---|---|---|---|
MemorySubsystem |
Two ports, optional caches, an arbiter and one memory | Yes | No (its endpoint, caches and arbiter have compact forms) |
Catalog: memory.subsystem.32.
| Parameter | Values | Default |
|---|---|---|
technology |
ff, sram, dram |
ff |
words |
A power of two in 16–2^28 (an accepted construction parameter, not a tested capacity range) | 65536 (256 KiB) |
caches |
none, or default: a read-only instruction cache and a write-through data cache, each four sets of 16-byte lines |
none |
clock_period |
The clock the memory is set up for, in ticks; 0 for none |
0 |
pipelined |
1: the pipelined arbiter of § 6.3.2 |
0 |
retention_ticks |
dram only: how long a closed row keeps its data, 1,024–10¹² ticks |
The profile's: 64 ms (64 × 10⁹ ticks) in every profile, a real DRAM's refresh period |
sram is the clocked on-chip SRAM macro, with as many wait states as its
proven access time needs at clock_period (the endpoint's default of 2
without one). dram uses the timing profile's DRAM row size (capped at
words) and, given clock_period, one refresh per the profile's refresh
interval (7.8125 µs in embedded), as the memory-system experiments of
§ 4.8 do. ff ignores the clock.
These are the catalog parameters a system description uses. Built from C++
(MemorySubsystemConfig), the part takes the full form: any memory
endpoint configuration, any cache configuration per port and for the shared
cache, the arbiter's burst length, and optional invalidation inputs
INV_L1 (both port caches) and INV_L2 (the shared cache). § 4.7 and § 4.8
use that form.
IO pins¶
| Pin | Direction | Width | Meaning |
|---|---|---|---|
CLK, RST |
Input | 1 each | Clock; reset of the ports, caches and arbiter (not of the stored data) |
<P>REQ_VALID, <P>REQ_OP, <P>REQ_ADDR, <P>REQ_WRITE_DATA, <P>REQ_WRITE_MASK, <P>RSP_READY |
Input | 1, 3, 32, 32, 4, 1 | Requests, for P = I_, D_ |
<P>REQ_READY, <P>RSP_VALID, <P>RSP_READ_DATA, <P>RSP_STATUS |
Output | 1, 1, 32, 3 | Answers on the corresponding port |
I_CLK, I_RST, D_CLK, D_RST |
Input | 1 each | Port clocks, unused (everything runs on CLK) |
INV_L1, INV_L2 |
Input | 1 each | Only with invalidation inputs: invalidate the port caches / the shared cache |
Behavior¶
Both ports see the same memory: a word written through D_ is fetched
through I_ (once any cached copy is replaced). Each port answers with the
memory's statuses: Range past the last word, Alignment for a misaligned
word. Reset clears the ports and caches but keeps the memory image, so a
loaded program survives it.
The two ports contend at the arbiter after any cache lookup. A request or
response waits through the same valid/ready rules as the other memory
components. When both ask in the same cycle, the fetch port wins after
reset and the arbiter then alternates (round robin); the losing port must
keep its request up until its REQ_READY rises. Without caches, D_REQ_READY rises only
while the data port is asking, so an idle data port reads not-ready, which
the valid/ready handshake allows. The endpoint's technology determines alignment, masks, range
errors and physical access/refresh waits; these are not replaced with a
fixed subsystem latency.
With caches, there is no instruction/data coherence mechanism: invalidation is tied off. A data write does not invalidate an instruction-cache copy, so self-modifying code must not assume a subsequent fetch sees the new word. Program loading takes place before reset and execution. Devices stay on separate bus targets and never pass through these caches.
caches |
A fetch hit | A fetch miss | A store |
|---|---|---|---|
none |
— | waits for the arbiter and the memory | waits for the arbiter and the memory |
default |
answered in the lookup cycle | fills a 16-byte line | written through to memory |
Implementation¶
| Part | Contents |
|---|---|
INSTRUCTION_CACHE, DATA_CACHE |
Cache<32> on each configured port (with caches = default, scalable storage); invalidation tied off unless the invalidation inputs exist |
ARBITER |
TwoPortMemoryArbiter<32>: I_ side from the fetch path, D_ side from the data path |
SHARED_CACHE |
An optional read-write Cache<32> between the arbiter and the memory (C++ form only) |
RAM |
The memory endpoint of the chosen technology (§ 3.5); a large memory selects the native device's scalable form |
The program loader writes straight into RAM's storage before the run.
There is no whole-subsystem compact leaf. Its endpoint, arbiter and caches retain their own structural or compact implementations. The current recipe instantiates the caches and the arbiter by class; these are not cache families selected from the system description, and a description can only choose no caches or the default pair. Separate instruction and data memories (§ 4.7's arrangement A) are not this part: they are two endpoints.
Timing. Propagation and access timing come from the chosen child parts, and the whole connected machine needs its own clock certificate. There is no stored subsystem delay table or single-cycle promise for a cache miss. The published machine certificates cover the listed configurations (the games machines with SRAM set up for 4.5 ns, and FF and DRAM for comparison); they are not a sweep over every accepted depth, technology and cache option. Structural unknown fields follow the endpoint and arbiter rules; numerical program checks use known binary traffic after reset.
Examples¶
A 4 KiB flip-flop memory: a store through D_, a load of the same word,
a fetch of it through I_, and an address past the end.
All 13 recorded rows of MemorySubsystemScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.
Default scenario profile: fidelity-compact-v1 / structural (763e0b8bac717d60). Changing fidelity or the circuit can change these times.
| Checkpointzero-based number · timeline label | Timesimulator units | CLKInput · 1 bit |
D_CLKInput · 1 bit |
D_REQ_ADDRInput · 32 bit |
D_REQ_OPInput · 3 bit |
D_REQ_VALIDInput · 1 bit |
D_REQ_WRITE_DATAInput · 32 bit |
D_REQ_WRITE_MASKInput · 4 bit |
D_RSP_READYInput · 1 bit |
D_RSTInput · 1 bit |
I_CLKInput · 1 bit |
I_REQ_ADDRInput · 32 bit |
I_REQ_OPInput · 3 bit |
I_REQ_VALIDInput · 1 bit |
I_REQ_WRITE_DATAInput · 32 bit |
I_REQ_WRITE_MASKInput · 4 bit |
I_RSP_READYInput · 1 bit |
I_RSTInput · 1 bit |
RSTInput · 1 bit |
D_REQ_READYExpected output · 1 bit |
D_RSP_READ_DATAExpected output · 32 bit |
D_RSP_STATUSExpected output · 3 bit |
D_RSP_VALIDExpected output · 1 bit |
I_REQ_READYExpected output · 1 bit |
I_RSP_READ_DATAExpected output · 32 bit |
I_RSP_STATUSExpected output · 3 bit |
I_RSP_VALIDExpected output · 1 bit |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#0reset | 31 | 0 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
1 |
0 |
not checked | not checked | 0 |
0 |
not checked | not checked | 0 |
#1ready | 46 | 0 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
not checked | not checked | not checked | 0 |
not checked | not checked | not checked | 0 |
#2data-write | 143 | 0 |
0 |
0x00000040 |
0x1 |
0 |
0x12345678 |
0xF |
0 |
0 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
not checked | not checked | 0x0 |
1 |
not checked | not checked | not checked | not checked |
#3data-read | 326 | 0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0 |
not checked | 0x12345678 |
0x0 |
1 |
not checked | not checked | not checked | not checked |
#4fetch-same-word | 510 | 0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
not checked | not checked | not checked | not checked | not checked | 0x12345678 |
0x0 |
1 |
#5second-word | 675 | 0 |
0 |
0x00000044 |
0x1 |
0 |
0x9ABCDEF0 |
0xF |
0 |
0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
not checked | not checked | 0x0 |
1 |
not checked | not checked | not checked | not checked |
#6both-ports-ask | 734 | 0 |
0 |
0x00000044 |
0x0 |
1 |
0x9ABCDEF0 |
0xF |
0 |
0 |
0 |
0x00000040 |
0x0 |
1 |
0x00000000 |
0xF |
0 |
0 |
0 |
0 |
not checked | not checked | not checked | 1 |
not checked | not checked | not checked |
#7fetch-granted | 749 | 1 |
1 |
0x00000044 |
0x0 |
1 |
0x9ABCDEF0 |
0xF |
0 |
0 |
1 |
0x00000040 |
0x0 |
1 |
0x00000000 |
0xF |
0 |
0 |
0 |
0 |
not checked | not checked | not checked | 0 |
not checked | not checked | not checked |
#8data-granted | 785 | 1 |
1 |
0x00000044 |
0x0 |
1 |
0x9ABCDEF0 |
0xF |
0 |
0 |
1 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
1 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked |
#9data-accepted | 800 | 1 |
1 |
0x00000044 |
0x0 |
1 |
0x9ABCDEF0 |
0xF |
0 |
0 |
1 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
0 |
not checked | not checked | not checked | not checked | not checked | not checked | not checked |
#10both-answered | 943 | 0 |
0 |
0x00000044 |
0x0 |
0 |
0x9ABCDEF0 |
0xF |
0 |
0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
not checked | 0x9ABCDEF0 |
0x0 |
1 |
not checked | 0x12345678 |
0x0 |
1 |
#11both-taken | 956 | 1 |
1 |
0x00000044 |
0x0 |
0 |
0x9ABCDEF0 |
0xF |
1 |
0 |
1 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
1 |
0 |
0 |
not checked | not checked | not checked | 0 |
not checked | not checked | not checked | 0 |
#12outside-memory | 1111 | 0 |
0 |
0x00001000 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
0x00000040 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0 |
not checked | not checked | 0x2 |
1 |
not checked | not checked | not checked | not checked |
Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.
Source and tests¶
Configuration and ports, cache/arbiter/endpoint wiring, system clock checks.
| Test | Coverage |
|---|---|
MemorySubsystemScenarioTest |
The recorded example |
ComputerSystemCachedFFTest, ComputerSystemCachedDRAMTest |
The bring-up program with caches over flip-flop and DRAM memory |
| Games | Every load and store checked against an independent memory model |