Skip to content

ยง 4.3.5. Memory Access

These are CPU-side components. The lane/alignment logic is shared by both cores. The pipeline additionally uses a requester to hold one universal memory transaction until completion; the strict single-cycle and baseline cores use zero-wait endpoint pins with combinational port formatting, not a stateful requester. These components do not contain storage or replace a technology-specific controller.

Component Description Structural Behavioral
RV32IMemoryLanes Little-endian subword extraction, store placement, masks, and endpoint address Yes Yes
RV32IMemoryAlignmentUnit Address alignment predicate Yes Yes
RV32IMemoryRequest CPU-owned, one-outstanding transaction requester Yes Yes

Columns count registered implementations. Behavioral pipeline cores contain equivalent requester bookkeeping; the single-cycle Memory stage contains only equivalent formatting logic. Those helpers are not separately selectable implementations of these building blocks. C++ examples below specify binary behavior without propagation delays.

Memory requests out, load values back A request travels from the CPU through lane formatting and request tracking to an endpoint; returning load data is tracked, extracted, and extended before reaching the CPU. OUTGOING REQUEST RETURNING LOAD DATA CPU CPU address + data load value Lanes Lanes place / mask extract / extend Request Request hold until done response word Endpoint Endpoint access storage return word
Pipeline transaction path. Lanes = RV32IMemoryLanes; Request = RV32IMemoryRequest. Endpoint = controller plus native storage, or its fused MemoryEndpoint. The single-cycle and baseline cores re-use Lanes with combinational formatting to zero-wait endpoints. Arrows show payload flow, not clock cycles or the complete handshake wiring.

The two rows separate outgoing payloads from returning data; they do not duplicate hardware. Request/response handshakes and CPU-side issue, completion, and fault controls are specified in the pin tables below.

4.3.5.1. RV32IMemoryLanes

IO pins

Pin Direction Width Description
ADDR Input 32 CPU byte address
WRITE_DATA Input 32 Unshifted store source register
WORD_DATA Input 32 Complete word returned by the endpoint
SIZE Input 2 0: byte; 1: halfword; 2: word; 3: invalid
SIGN_EXTEND Input 1 Sign-extend byte/halfword loads
WORD_ADDR Output 32 Endpoint byte address, not a word index
WORD_WRITE_DATA Output 32 Store data shifted to its byte lane
READ_DATA Output 32 CPU load result
WRITE_MASK Output 4 One enable per endpoint byte lane

Behavior

Offset is ADDR[1:0]. Byte lane 0 is bits 7:0; lane 3 is bits 31:24. Valid accesses use WORD_ADDR = ADDR & ~3. Byte stores enable one lane; aligned halfword stores enable lanes 0โ€“1 or 2โ€“3; word stores enable all four. Store data moves left by offset*8; load data moves right by that amount, then is narrowed and sign/zero-extended.

A halfword at an odd address, word at a nonzero offset, or SIZE=3 must not silently become an aligned legal access. The output address therefore sets bit 0 on these cases, making the endpoint reject the request as unaligned. There is no split transaction across words. Invalid inputs still produce deterministic combinational data/masks, but these are not permission to write: the endpoint must reject the bad address. SIZE=3 gives read data and mask zero.

C++ example

#include <cstdint>
namespace memory_access_example {
struct Lanes { uint32_t WORD_ADDR, WORD_WRITE_DATA, READ_DATA; unsigned WRITE_MASK; };
Lanes lanes(uint32_t address, uint32_t write, uint32_t word, unsigned size, bool sign) {
    const unsigned offset=address&3;
    const bool bad=size==3 || (size==1 && (offset&1)) || (size==2 && offset!=0);
    const uint32_t shifted=word>>(8*offset);
    uint32_t read=size==0 ? shifted&255 : size==1 ? shifted&65535 : size==2 ? shifted : 0;
    if (sign && size==0 && (read&128)) read|=0xffffff00U;
    if (sign && size==1 && (read&32768)) read|=0xffff0000U;
    const unsigned mask=size==0 ? 1U<<offset : size==1 ? 3U<<(offset&2) : size==2 ? 15 : 0;
    return {(address&~uint32_t{3})|uint32_t(bad),write<<(8*offset),read,mask};
}
}

Unknown inputs and timing

This is a combinational structural network. Splitters and rewires preserve individual X/Z bits; muxes and sign-extension gates can mask or propagate them. A known size or disabled sign extension may isolate unrelated bits. The binary example does not model those cases or the different path delays.

Implementation

Structural implementation

Nine top-level children expose the data flow instead of placing every bit gate side by side:

Child Structural helper / responsibility
ADDRESS RV32IMemoryAddress: address/size decoding, guarded word address, byte offset, byte/halfword/word enables
LANE_0 โ€ฆ LANE_3 Rewire four possible byte placements for store and load data
STORE_LANES, LOAD_LANES Select the requested byte offset
LOAD_EXTEND RV32ILoadExtender: select byte/halfword/word data and sign/zero extension
WRITE_MASK RV32IByteWriteMask: generate the four byte-write enables

ADDRESS receives ADDR[32] and SIZE[2]; it outputs WORD_ADDR[32], OFFSET[2], and BYTE/HALF/WORD. LOAD_EXTEND receives shifted DATA[32], those three enables, and SIGN_EXTEND; its OUT[32] is assembled from four RV32ILoadByte<0โ€ฆ3> circuits. Each byte circuit contains eight numbered bit lanes; lower bytes retain input bits while higher bytes select the relevant sign fill. WRITE_MASK receives the offset and size enables and produces MASK[4].

The internal helpers are fixed structural parts with no state and no behavioral variants of their own; grouping does not turn them into behavioral memory devices.

Behavioral implementation

RV32IMemoryLanesBehavioral computes the four outputs with the same lane functions the behavioral cores call (memoryWordAddress, memoryLoadData, memoryWriteMask, and the store shift), with gate-derived output timing when selected through the catalog. It is defined for known binary inputs: if any input bit is X or Z, every output is unknown. Partial-unknown behavior is specified by the structural gates only.

Examples

All 32 recorded rows of RV32IMemoryLanesTest, 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: canonical-default-preview / structural (855fad65681ed169). Changing fidelity or the circuit can change these times.

Checkpointzero-based number ยท timeline label Timesimulator units ADDRInput ยท 32 bit SIGN_EXTENDInput ยท 1 bit SIZEInput ยท 2 bit WORD_DATAInput ยท 32 bit WRITE_DATAInput ยท 32 bit READ_DATAExpected output ยท 32 bit WORD_ADDRExpected output ยท 32 bit WORD_WRITE_DATAExpected output ยท 32 bit WRITE_MASKExpected output ยท 4 bit
#0size-0-lane-0-sign-011 0x00000100 0 0x0 0x80FF3412 0xDEADBEEF 0x00000012 0x00000100 0xDEADBEEF 0x1
#1size-0-lane-0-sign-113 0x00000100 1 0x0 0x80FF3412 0xDEADBEEF 0x00000012 0x00000100 0xDEADBEEF 0x1
#2size-0-lane-1-sign-025 0x00000101 0 0x0 0x80FF3412 0xDEADBEEF 0x00000034 0x00000100 0xADBEEF00 0x2
#3size-0-lane-1-sign-128 0x00000101 1 0x0 0x80FF3412 0xDEADBEEF 0x00000034 0x00000100 0xADBEEF00 0x2
#4size-0-lane-2-sign-040 0x00000102 0 0x0 0x80FF3412 0xDEADBEEF 0x000000FF 0x00000100 0xBEEF0000 0x4
#5size-0-lane-2-sign-145 0x00000102 1 0x0 0x80FF3412 0xDEADBEEF 0xFFFFFFFF 0x00000100 0xBEEF0000 0x4
#6size-0-lane-3-sign-057 0x00000103 0 0x0 0x80FF3412 0xDEADBEEF 0x00000080 0x00000100 0xEF000000 0x8
#7size-0-lane-3-sign-162 0x00000103 1 0x0 0x80FF3412 0xDEADBEEF 0xFFFFFF80 0x00000100 0xEF000000 0x8
#8size-1-lane-0-sign-074 0x00000100 0 0x1 0x80FF3412 0xDEADBEEF 0x00003412 0x00000100 0xDEADBEEF 0x3
#9size-1-lane-0-sign-176 0x00000100 1 0x1 0x80FF3412 0xDEADBEEF 0x00003412 0x00000100 0xDEADBEEF 0x3
#10size-1-lane-1-sign-088 0x00000101 0 0x1 0x80FF3412 0xDEADBEEF 0x0000FF34 0x00000101 0xADBEEF00 0x3
#11size-1-lane-1-sign-193 0x00000101 1 0x1 0x80FF3412 0xDEADBEEF 0xFFFFFF34 0x00000101 0xADBEEF00 0x3
#12size-1-lane-2-sign-0105 0x00000102 0 0x1 0x80FF3412 0xDEADBEEF 0x000080FF 0x00000100 0xBEEF0000 0xC
#13size-1-lane-2-sign-1110 0x00000102 1 0x1 0x80FF3412 0xDEADBEEF 0xFFFF80FF 0x00000100 0xBEEF0000 0xC
#14size-1-lane-3-sign-0122 0x00000103 0 0x1 0x80FF3412 0xDEADBEEF 0x00000080 0x00000101 0xEF000000 0xC
#15size-1-lane-3-sign-1125 0x00000103 1 0x1 0x80FF3412 0xDEADBEEF 0x00000080 0x00000101 0xEF000000 0xC
#16size-2-lane-0-sign-0136 0x00000100 0 0x2 0x80FF3412 0xDEADBEEF 0x80FF3412 0x00000100 0xDEADBEEF 0xF
#17size-2-lane-0-sign-1138 0x00000100 1 0x2 0x80FF3412 0xDEADBEEF 0x80FF3412 0x00000100 0xDEADBEEF 0xF
#18size-2-lane-1-sign-0149 0x00000101 0 0x2 0x80FF3412 0xDEADBEEF 0x0080FF34 0x00000101 0xADBEEF00 0xF
#19size-2-lane-1-sign-1152 0x00000101 1 0x2 0x80FF3412 0xDEADBEEF 0x0080FF34 0x00000101 0xADBEEF00 0xF
#20size-2-lane-2-sign-0163 0x00000102 0 0x2 0x80FF3412 0xDEADBEEF 0x000080FF 0x00000101 0xBEEF0000 0xF
#21size-2-lane-2-sign-1166 0x00000102 1 0x2 0x80FF3412 0xDEADBEEF 0x000080FF 0x00000101 0xBEEF0000 0xF
#22size-2-lane-3-sign-0177 0x00000103 0 0x2 0x80FF3412 0xDEADBEEF 0x00000080 0x00000101 0xEF000000 0xF
#23size-2-lane-3-sign-1180 0x00000103 1 0x2 0x80FF3412 0xDEADBEEF 0x00000080 0x00000101 0xEF000000 0xF
#24size-3-lane-0-sign-0190 0x00000100 0 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xDEADBEEF 0x0
#25size-3-lane-0-sign-1192 0x00000100 1 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xDEADBEEF 0x0
#26size-3-lane-1-sign-0202 0x00000101 0 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xADBEEF00 0x0
#27size-3-lane-1-sign-1205 0x00000101 1 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xADBEEF00 0x0
#28size-3-lane-2-sign-0215 0x00000102 0 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xBEEF0000 0x0
#29size-3-lane-2-sign-1218 0x00000102 1 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xBEEF0000 0x0
#30size-3-lane-3-sign-0228 0x00000103 0 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xEF000000 0x0
#31size-3-lane-3-sign-1231 0x00000103 1 0x3 0x80FF3412 0xDEADBEEF 0x00000000 0x00000101 0xEF000000 0x0

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.

Embedded simulation

Open memory lanes

Tests

RV32IMemoryLanesTest exposes 32 checkpoints covering all four size encodings, four offsets, and both sign modes. RV32IMemoryMigrationTest additionally exercises formatting against real endpoint responses and checks that rejected stores do not change storage. These are sampled data words, not an exhaustive 32-bit operand test.

4.3.5.2. RV32IMemoryAlignmentUnit

IO pins

Pin Direction Width Description
ADDRESS Input 32 CPU byte address
SIZE Input 2 Access-size encoding
MISALIGNED Output 1 Address violates the selected alignment

Behavior

Byte accesses accept every address; halfwords require bit 0 zero; words require bits 1:0 zero. The circuit equation is SIZE[0]ยทADDRESS[0] OR SIZE[1]ยท(ADDRESS[0] OR ADDRESS[1]). Consequently reserved SIZE=3 has the same alignment predicate as word accesses; an aligned address produces zero. This component is not a size-validity checker. The lane formatter and execution-status unit separately reject size 3.

The single-cycle Memory stage also adds a size-3 check to its public MISALIGNED output. Fetch and Next PC use this building block with constant word size.

C++ example

namespace memory_access_example {
bool misaligned(uint32_t address, unsigned size) {
    return ((size&1) && (address&1)) || ((size&2) && (address&3));
}
}

Unknown inputs and timing

Only the low two address bits and both size bits matter. AND with zero and OR with one mask unknowns; other indeterminate gate results become X. Both implementations use that equation, including SIZE=3 and X/Z. The registered behavioral checker uses gate-derived per-path delays; structural timing follows its individual gates.

Implementation

Structural implementation

Two splitters, two AND gates, and two OR gates evaluate the predicate. It is registered as rv32i.pipeline.memory-alignment, but its address check is not intrinsically pipeline-specific.

Behavioral implementation

RV32IMemoryAlignmentBehavioral evaluates the same four-state gate expression without internal components. It does not coerce unknown bits into a binary integer.

Examples

All 262 recorded rows of RV32IMemoryAlignmentUnitTest, 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: rv32i-component-preview-preview / structural (4a6379727cf50a7a). Changing fidelity or the circuit can change these times.

Checkpointzero-based number ยท timeline label Timesimulator units ADDRESSInput ยท 32 bit SIZEInput ยท 2 bit MISALIGNEDExpected output ยท 1 bit
#0byte-any-address3 0x00000103 0x0 0
#1aligned-halfword6 0x00000102 0x1 0
#2misaligned-halfword10 0x00000103 0x1 1
#3aligned-word15 0x00000104 0x2 0
#4word-offset-one20 0x00000105 0x2 1
#5word-offset-two23 0x00000106 0x2 1
#6four-state-027 0x00000100 0x0 0
#7four-state-131 0x00000101 0x0 0
#8four-state-235 0b0000000000000000000000010000000X 0x0 0
#9four-state-338 0b0000000000000000000000010000000Z 0x0 0
#10four-state-442 0x00000102 0x0 0
#11four-state-545 0x00000103 0x0 0
#12four-state-648 0b0000000000000000000000010000001X 0x0 0
#13four-state-751 0b0000000000000000000000010000001Z 0x0 0
#14four-state-855 0b000000000000000000000001000000X0 0x0 0
#15four-state-959 0b000000000000000000000001000000X1 0x0 0
#16four-state-1063 0b000000000000000000000001000000XX 0x0 0
#17four-state-1166 0b000000000000000000000001000000XZ 0x0 0
#18four-state-1269 0b000000000000000000000001000000Z0 0x0 0
#19four-state-1373 0b000000000000000000000001000000Z1 0x0 0
#20four-state-1477 0b000000000000000000000001000000ZX 0x0 0
#21four-state-1580 0b000000000000000000000001000000ZZ 0x0 0
#22four-state-1684 0x00000100 0x1 0
#23four-state-1788 0x00000101 0x1 1
#24four-state-1892 0b0000000000000000000000010000000X 0x1 X
#25four-state-1995 0b0000000000000000000000010000000Z 0x1 X
#26four-state-2099 0x00000102 0x1 0
#27four-state-21103 0x00000103 0x1 1
#28four-state-22107 0b0000000000000000000000010000001X 0x1 X
#29four-state-23110 0b0000000000000000000000010000001Z 0x1 X
#30four-state-24114 0b000000000000000000000001000000X0 0x1 0
#31four-state-25118 0b000000000000000000000001000000X1 0x1 1
#32four-state-26122 0b000000000000000000000001000000XX 0x1 X
#33four-state-27125 0b000000000000000000000001000000XZ 0x1 X
#34four-state-28129 0b000000000000000000000001000000Z0 0x1 0
#35four-state-29133 0b000000000000000000000001000000Z1 0x1 1
#36four-state-30137 0b000000000000000000000001000000ZX 0x1 X
#37four-state-31140 0b000000000000000000000001000000ZZ 0x1 X
#38four-state-32144 0x00000100 0b0X 0
#39four-state-33148 0x00000101 0b0X X
#40four-state-34152 0b0000000000000000000000010000000X 0b0X X
#41four-state-35155 0b0000000000000000000000010000000Z 0b0X X
#42four-state-36159 0x00000102 0b0X 0
#43four-state-37163 0x00000103 0b0X X
#44four-state-38166 0b0000000000000000000000010000001X 0b0X X
#45four-state-39169 0b0000000000000000000000010000001Z 0b0X X
#46four-state-40173 0b000000000000000000000001000000X0 0b0X 0
#47four-state-41177 0b000000000000000000000001000000X1 0b0X X
#48four-state-42181 0b000000000000000000000001000000XX 0b0X X
#49four-state-43184 0b000000000000000000000001000000XZ 0b0X X
#50four-state-44188 0b000000000000000000000001000000Z0 0b0X 0
#51four-state-45192 0b000000000000000000000001000000Z1 0b0X X
#52four-state-46196 0b000000000000000000000001000000ZX 0b0X X
#53four-state-47199 0b000000000000000000000001000000ZZ 0b0X X
#54four-state-48203 0x00000100 0b0Z 0
#55four-state-49207 0x00000101 0b0Z X
#56four-state-50211 0b0000000000000000000000010000000X 0b0Z X
#57four-state-51214 0b0000000000000000000000010000000Z 0b0Z X
#58four-state-52218 0x00000102 0b0Z 0
#59four-state-53222 0x00000103 0b0Z X
#60four-state-54225 0b0000000000000000000000010000001X 0b0Z X
#61four-state-55228 0b0000000000000000000000010000001Z 0b0Z X
#62four-state-56232 0b000000000000000000000001000000X0 0b0Z 0
#63four-state-57236 0b000000000000000000000001000000X1 0b0Z X
#64four-state-58240 0b000000000000000000000001000000XX 0b0Z X
#65four-state-59243 0b000000000000000000000001000000XZ 0b0Z X
#66four-state-60247 0b000000000000000000000001000000Z0 0b0Z 0
#67four-state-61251 0b000000000000000000000001000000Z1 0b0Z X
#68four-state-62255 0b000000000000000000000001000000ZX 0b0Z X
#69four-state-63258 0b000000000000000000000001000000ZZ 0b0Z X
#70four-state-64263 0x00000100 0x2 0
#71four-state-65268 0x00000101 0x2 1
#72four-state-66273 0b0000000000000000000000010000000X 0x2 X
#73four-state-67276 0b0000000000000000000000010000000Z 0x2 X
#74four-state-68281 0x00000102 0x2 1
#75four-state-69284 0x00000103 0x2 1
#76four-state-70287 0b0000000000000000000000010000001X 0x2 1
#77four-state-71290 0b0000000000000000000000010000001Z 0x2 1
#78four-state-72295 0b000000000000000000000001000000X0 0x2 X
#79four-state-73300 0b000000000000000000000001000000X1 0x2 1
#80four-state-74305 0b000000000000000000000001000000XX 0x2 X
#81four-state-75308 0b000000000000000000000001000000XZ 0x2 X
#82four-state-76311 0b000000000000000000000001000000Z0 0x2 X
#83four-state-77316 0b000000000000000000000001000000Z1 0x2 1
#84four-state-78321 0b000000000000000000000001000000ZX 0x2 X
#85four-state-79324 0b000000000000000000000001000000ZZ 0x2 X
#86four-state-80329 0x00000100 0x3 0
#87four-state-81334 0x00000101 0x3 1
#88four-state-82339 0b0000000000000000000000010000000X 0x3 X
#89four-state-83342 0b0000000000000000000000010000000Z 0x3 X
#90four-state-84347 0x00000102 0x3 1
#91four-state-85351 0x00000103 0x3 1
#92four-state-86355 0b0000000000000000000000010000001X 0x3 1
#93four-state-87358 0b0000000000000000000000010000001Z 0x3 1
#94four-state-88363 0b000000000000000000000001000000X0 0x3 X
#95four-state-89368 0b000000000000000000000001000000X1 0x3 1
#96four-state-90373 0b000000000000000000000001000000XX 0x3 X
#97four-state-91376 0b000000000000000000000001000000XZ 0x3 X
#98four-state-92380 0b000000000000000000000001000000Z0 0x3 X
#99four-state-93385 0b000000000000000000000001000000Z1 0x3 1
#100four-state-94390 0b000000000000000000000001000000ZX 0x3 X
#101four-state-95393 0b000000000000000000000001000000ZZ 0x3 X
#102four-state-96398 0x00000100 0b1X 0
#103four-state-97403 0x00000101 0b1X 1
#104four-state-98408 0b0000000000000000000000010000000X 0b1X X
#105four-state-99411 0b0000000000000000000000010000000Z 0b1X X
#106four-state-100416 0x00000102 0b1X 1
#107four-state-101420 0x00000103 0b1X 1
#108four-state-102423 0b0000000000000000000000010000001X 0b1X 1
#109four-state-103426 0b0000000000000000000000010000001Z 0b1X 1
#110four-state-104431 0b000000000000000000000001000000X0 0b1X X
#111four-state-105436 0b000000000000000000000001000000X1 0b1X 1
#112four-state-106441 0b000000000000000000000001000000XX 0b1X X
#113four-state-107444 0b000000000000000000000001000000XZ 0b1X X
#114four-state-108448 0b000000000000000000000001000000Z0 0b1X X
#115four-state-109453 0b000000000000000000000001000000Z1 0b1X 1
#116four-state-110458 0b000000000000000000000001000000ZX 0b1X X
#117four-state-111461 0b000000000000000000000001000000ZZ 0b1X X
#118four-state-112466 0x00000100 0b1Z 0
#119four-state-113471 0x00000101 0b1Z 1
#120four-state-114476 0b0000000000000000000000010000000X 0b1Z X
#121four-state-115479 0b0000000000000000000000010000000Z 0b1Z X
#122four-state-116484 0x00000102 0b1Z 1
#123four-state-117488 0x00000103 0b1Z 1
#124four-state-118491 0b0000000000000000000000010000001X 0b1Z 1
#125four-state-119494 0b0000000000000000000000010000001Z 0b1Z 1
#126four-state-120499 0b000000000000000000000001000000X0 0b1Z X
#127four-state-121504 0b000000000000000000000001000000X1 0b1Z 1
#128four-state-122509 0b000000000000000000000001000000XX 0b1Z X
#129four-state-123512 0b000000000000000000000001000000XZ 0b1Z X
#130four-state-124516 0b000000000000000000000001000000Z0 0b1Z X
#131four-state-125521 0b000000000000000000000001000000Z1 0b1Z 1
#132four-state-126526 0b000000000000000000000001000000ZX 0b1Z X
#133four-state-127529 0b000000000000000000000001000000ZZ 0b1Z X
#134four-state-128534 0x00000100 0bX0 0
#135four-state-129539 0x00000101 0bX0 X
#136four-state-130543 0b0000000000000000000000010000000X 0bX0 X
#137four-state-131546 0b0000000000000000000000010000000Z 0bX0 X
#138four-state-132550 0x00000102 0bX0 X
#139four-state-133553 0x00000103 0bX0 X
#140four-state-134556 0b0000000000000000000000010000001X 0bX0 X
#141four-state-135559 0b0000000000000000000000010000001Z 0bX0 X
#142four-state-136563 0b000000000000000000000001000000X0 0bX0 X
#143four-state-137567 0b000000000000000000000001000000X1 0bX0 X
#144four-state-138571 0b000000000000000000000001000000XX 0bX0 X
#145four-state-139574 0b000000000000000000000001000000XZ 0bX0 X
#146four-state-140577 0b000000000000000000000001000000Z0 0bX0 X
#147four-state-141581 0b000000000000000000000001000000Z1 0bX0 X
#148four-state-142585 0b000000000000000000000001000000ZX 0bX0 X
#149four-state-143588 0b000000000000000000000001000000ZZ 0bX0 X
#150four-state-144593 0x00000100 0bX1 0
#151four-state-145598 0x00000101 0bX1 1
#152four-state-146602 0b0000000000000000000000010000000X 0bX1 X
#153four-state-147605 0b0000000000000000000000010000000Z 0bX1 X
#154four-state-148609 0x00000102 0bX1 X
#155four-state-149613 0x00000103 0bX1 1
#156four-state-150617 0b0000000000000000000000010000001X 0bX1 X
#157four-state-151620 0b0000000000000000000000010000001Z 0bX1 X
#158four-state-152624 0b000000000000000000000001000000X0 0bX1 X
#159four-state-153628 0b000000000000000000000001000000X1 0bX1 1
#160four-state-154632 0b000000000000000000000001000000XX 0bX1 X
#161four-state-155635 0b000000000000000000000001000000XZ 0bX1 X
#162four-state-156639 0b000000000000000000000001000000Z0 0bX1 X
#163four-state-157643 0b000000000000000000000001000000Z1 0bX1 1
#164four-state-158647 0b000000000000000000000001000000ZX 0bX1 X
#165four-state-159650 0b000000000000000000000001000000ZZ 0bX1 X
#166four-state-160655 0x00000100 0bXX 0
#167four-state-161660 0x00000101 0bXX X
#168four-state-162664 0b0000000000000000000000010000000X 0bXX X
#169four-state-163667 0b0000000000000000000000010000000Z 0bXX X
#170four-state-164671 0x00000102 0bXX X
#171four-state-165675 0x00000103 0bXX X
#172four-state-166678 0b0000000000000000000000010000001X 0bXX X
#173four-state-167681 0b0000000000000000000000010000001Z 0bXX X
#174four-state-168685 0b000000000000000000000001000000X0 0bXX X
#175four-state-169689 0b000000000000000000000001000000X1 0bXX X
#176four-state-170693 0b000000000000000000000001000000XX 0bXX X
#177four-state-171696 0b000000000000000000000001000000XZ 0bXX X
#178four-state-172700 0b000000000000000000000001000000Z0 0bXX X
#179four-state-173704 0b000000000000000000000001000000Z1 0bXX X
#180four-state-174708 0b000000000000000000000001000000ZX 0bXX X
#181four-state-175711 0b000000000000000000000001000000ZZ 0bXX X
#182four-state-176716 0x00000100 0bXZ 0
#183four-state-177721 0x00000101 0bXZ X
#184four-state-178725 0b0000000000000000000000010000000X 0bXZ X
#185four-state-179728 0b0000000000000000000000010000000Z 0bXZ X
#186four-state-180732 0x00000102 0bXZ X
#187four-state-181736 0x00000103 0bXZ X
#188four-state-182739 0b0000000000000000000000010000001X 0bXZ X
#189four-state-183742 0b0000000000000000000000010000001Z 0bXZ X
#190four-state-184746 0b000000000000000000000001000000X0 0bXZ X
#191four-state-185750 0b000000000000000000000001000000X1 0bXZ X
#192four-state-186754 0b000000000000000000000001000000XX 0bXZ X
#193four-state-187757 0b000000000000000000000001000000XZ 0bXZ X
#194four-state-188761 0b000000000000000000000001000000Z0 0bXZ X
#195four-state-189765 0b000000000000000000000001000000Z1 0bXZ X
#196four-state-190769 0b000000000000000000000001000000ZX 0bXZ X
#197four-state-191772 0b000000000000000000000001000000ZZ 0bXZ X
#198four-state-192777 0x00000100 0bZ0 0
#199four-state-193782 0x00000101 0bZ0 X
#200four-state-194786 0b0000000000000000000000010000000X 0bZ0 X
#201four-state-195789 0b0000000000000000000000010000000Z 0bZ0 X
#202four-state-196793 0x00000102 0bZ0 X
#203four-state-197796 0x00000103 0bZ0 X
#204four-state-198799 0b0000000000000000000000010000001X 0bZ0 X
#205four-state-199802 0b0000000000000000000000010000001Z 0bZ0 X
#206four-state-200806 0b000000000000000000000001000000X0 0bZ0 X
#207four-state-201810 0b000000000000000000000001000000X1 0bZ0 X
#208four-state-202814 0b000000000000000000000001000000XX 0bZ0 X
#209four-state-203817 0b000000000000000000000001000000XZ 0bZ0 X
#210four-state-204820 0b000000000000000000000001000000Z0 0bZ0 X
#211four-state-205824 0b000000000000000000000001000000Z1 0bZ0 X
#212four-state-206828 0b000000000000000000000001000000ZX 0bZ0 X
#213four-state-207831 0b000000000000000000000001000000ZZ 0bZ0 X
#214four-state-208836 0x00000100 0bZ1 0
#215four-state-209841 0x00000101 0bZ1 1
#216four-state-210845 0b0000000000000000000000010000000X 0bZ1 X
#217four-state-211848 0b0000000000000000000000010000000Z 0bZ1 X
#218four-state-212852 0x00000102 0bZ1 X
#219four-state-213856 0x00000103 0bZ1 1
#220four-state-214860 0b0000000000000000000000010000001X 0bZ1 X
#221four-state-215863 0b0000000000000000000000010000001Z 0bZ1 X
#222four-state-216867 0b000000000000000000000001000000X0 0bZ1 X
#223four-state-217871 0b000000000000000000000001000000X1 0bZ1 1
#224four-state-218875 0b000000000000000000000001000000XX 0bZ1 X
#225four-state-219878 0b000000000000000000000001000000XZ 0bZ1 X
#226four-state-220882 0b000000000000000000000001000000Z0 0bZ1 X
#227four-state-221886 0b000000000000000000000001000000Z1 0bZ1 1
#228four-state-222890 0b000000000000000000000001000000ZX 0bZ1 X
#229four-state-223893 0b000000000000000000000001000000ZZ 0bZ1 X
#230four-state-224898 0x00000100 0bZX 0
#231four-state-225903 0x00000101 0bZX X
#232four-state-226907 0b0000000000000000000000010000000X 0bZX X
#233four-state-227910 0b0000000000000000000000010000000Z 0bZX X
#234four-state-228914 0x00000102 0bZX X
#235four-state-229918 0x00000103 0bZX X
#236four-state-230921 0b0000000000000000000000010000001X 0bZX X
#237four-state-231924 0b0000000000000000000000010000001Z 0bZX X
#238four-state-232928 0b000000000000000000000001000000X0 0bZX X
#239four-state-233932 0b000000000000000000000001000000X1 0bZX X
#240four-state-234936 0b000000000000000000000001000000XX 0bZX X
#241four-state-235939 0b000000000000000000000001000000XZ 0bZX X
#242four-state-236943 0b000000000000000000000001000000Z0 0bZX X
#243four-state-237947 0b000000000000000000000001000000Z1 0bZX X
#244four-state-238951 0b000000000000000000000001000000ZX 0bZX X
#245four-state-239954 0b000000000000000000000001000000ZZ 0bZX X
#246four-state-240959 0x00000100 0bZZ 0
#247four-state-241964 0x00000101 0bZZ X
#248four-state-242968 0b0000000000000000000000010000000X 0bZZ X
#249four-state-243971 0b0000000000000000000000010000000Z 0bZZ X
#250four-state-244975 0x00000102 0bZZ X
#251four-state-245979 0x00000103 0bZZ X
#252four-state-246982 0b0000000000000000000000010000001X 0bZZ X
#253four-state-247985 0b0000000000000000000000010000001Z 0bZZ X
#254four-state-248989 0b000000000000000000000001000000X0 0bZZ X
#255four-state-249993 0b000000000000000000000001000000X1 0bZZ X
#256four-state-250997 0b000000000000000000000001000000XX 0bZZ X
#257four-state-2511000 0b000000000000000000000001000000XZ 0bZZ X
#258four-state-2521004 0b000000000000000000000001000000Z0 0bZZ X
#259four-state-2531008 0b000000000000000000000001000000Z1 0bZZ X
#260four-state-2541012 0b000000000000000000000001000000ZX 0bZZ X
#261four-state-2551015 0b000000000000000000000001000000ZZ 0bZZ X

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.

Embedded simulation

Open alignment checker

Tests

RV32IMemoryAlignmentUnitTest includes six named binary cases and all \(4^4=256\) combinations of LOW/HIGH/X/Z for the four meaningful bits. It checks 262 checkpoints in each implementation. Source: src/modules/rv32i/RV32IMemoryAlignmentUnit.cpp (structural) and src/modules/rv32i/RV32IPipelineControlBehavioral.cpp (behavioral).

4.3.5.3. RV32IMemoryRequest

IO pins

Pin Direction Width Description
CLK, RST Input 1 each Rising-edge transaction state; asynchronous active-high reset
ISSUE Input 1 Capture a new request when idle
TAKE Input 1 CPU can consume the current response
TAG Input 32 Current CPU request identity; a change abandons the saved request
ADDR, WRITE_DATA Input 32 each Endpoint byte address and lane-placed data
OP Input 3 Universal protocol operation (read=0, write=1); forwarded without decoding
WRITE_MASK Input 4 Endpoint byte write enables
BUS_REQ_READY Input 1 Endpoint can accept the request
BUS_RSP_VALID Input 1 Endpoint holds a response
BUS_RSP_READ_DATA Input 32 Endpoint response word
BUS_RSP_STATUS Input 3 Universal response status; zero is success
BUS_REQ_VALID Output 1 Saved request is awaiting acceptance
BUS_REQ_OP Output 3 Saved operation
BUS_REQ_ADDR, BUS_REQ_WRITE_DATA Output 32 each Saved request payload
BUS_REQ_WRITE_MASK Output 4 Saved byte mask
BUS_RSP_READY Output 1 Consume or discard endpoint response
DONE Output 1 A valid response belongs to the current CPU request
READ_DATA Output 32 Direct copy of response data; meaningful with DONE
FAULT Output 1 Nonzero response status; meaningful with DONE

Behavior

There is at most one outstanding transaction:

  1. While idle, ISSUE and the live payload immediately drive the bus. If the transaction cannot finish on the first edge, capture tag/payload to hold it.
  2. Keep BUS_REQ_VALID and the saved payload stable until a rising edge with BUS_REQ_READY=1. CPU input changes cannot mutate this request.
  3. A response may arrive during the request cycle or after acceptance. DONE announces a matching valid response even if TAKE=0; the endpoint holds response data/status under this backpressure.
  4. With TAKE or an abandoned tag, assert BUS_RSP_READY. A rising edge with response valid completes/drains the transaction. After completion, idle bypass exposes the next request during the following cycle. A ready zero-wait endpoint can therefore complete one request per cycle.

TAG is local bookkeeping, not a bus transaction ID. A mismatch immediately suppresses DONE and enables draining once the request has been sent. A mismatch sampled while busy is sticky: Aโ†’Bโ†’A across clock edges cannot make the old response valid again. A transient mismatch entirely between edges is not stored. Abandonment does not withdraw a stalled request or cancel an accepted store; it discards its eventual response. The CPU must choose tags that distinguish its requests and coordinate any redirects.

Reset clears busy/sent/abandoned and saved payload, suppresses bus valid/ready and DONE, and does not undo memory writes. Reset must be coordinated with the connected endpoint's transaction reset. READ_DATA and FAULT remain direct combinational response signals, even while idle or reset; they are not gated by DONE. ISSUE held high can start another transaction after the current one finishes, so the caller must manage it.

C++ example

This binary reference covers every output, payload hold, reset, completion, and abandonment rule. Start with reset asserted; input values must settle before each clock edge.

observe reads combinational outputs without advancing state. evaluate applies reset/edge changes and returns the resulting outputs. The core models use this distinction to capture all inputs from the old state.

namespace memory_access_example {
struct RequestInputs {
    bool CLK, RST, ISSUE, TAKE;
    uint32_t TAG, ADDR, WRITE_DATA;
    unsigned OP, WRITE_MASK;
    bool BUS_REQ_READY, BUS_RSP_VALID;
    uint32_t BUS_RSP_READ_DATA;
    unsigned BUS_RSP_STATUS;
};
struct RequestOutputs {
    bool DONE, FAULT;
    uint32_t READ_DATA;
    bool BUS_REQ_VALID, BUS_RSP_READY;
    unsigned BUS_REQ_OP;
    uint32_t BUS_REQ_ADDR, BUS_REQ_WRITE_DATA;
    unsigned BUS_REQ_WRITE_MASK;
};
class Request {
    bool busy=false, sent=false, abandoned=false, previous_clock=false;
    uint32_t tag=0, address=0, data=0;
    unsigned op=0, mask=0;
    bool discard(const RequestInputs& i) const { return busy && (abandoned || tag!=i.TAG); }
    RequestOutputs outputs(const RequestInputs& i) const {
        const bool sending=(busy||i.ISSUE)&&!sent&&!i.RST;
        const bool accepted=sending&&i.BUS_REQ_READY;
        return {(sent||accepted)&&i.BUS_RSP_VALID&&!discard(i)&&!i.RST,
                i.BUS_RSP_STATUS!=0,i.BUS_RSP_READ_DATA,
                sending,(sent||sending)&&(i.TAKE||discard(i))&&!i.RST,
                busy?op:i.OP,busy?address:i.ADDR,busy?data:i.WRITE_DATA,busy?mask:i.WRITE_MASK};
    }
public:
    RequestOutputs observe(const RequestInputs& i) const { return outputs(i); }
    RequestOutputs evaluate(const RequestInputs& i) {
        if (i.RST) {
            busy=sent=abandoned=false; tag=address=data=0; op=mask=0;
        } else if (!previous_clock && i.CLK) {
            const auto before=outputs(i);
            if (before.BUS_RSP_READY && i.BUS_RSP_VALID) busy=sent=abandoned=false;
            else if (!busy && i.ISSUE) {
                busy=true; sent=before.BUS_REQ_VALID&&i.BUS_REQ_READY; abandoned=false;
                tag=i.TAG; address=i.ADDR; data=i.WRITE_DATA; op=i.OP; mask=i.WRITE_MASK;
            } else if (busy) {
                abandoned=discard(i);
                if (before.BUS_REQ_VALID && i.BUS_REQ_READY) sent=true;
            }
        }
        previous_clock=i.CLK;
        return outputs(i);
    }
};
}

Unknown inputs and timing

State is initially unknown until reset. Four-state behavior follows the FF cells, payload registers, equality gates, and enables. Response data is rewired and preserves X/Z; status is OR-reduced. The example assumes binary, stable handshake controls and does not model setup/hold violations or propagation glitches. Request/response handshakes are sampled on clock edges, not whenever valid and ready happen to overlap between edges.

Implementation

Structural implementation

BUSY, SENT, and ABANDONED are always-clocked ClockedStateBit children. The general requester retains five fields in Register children. Payload multiplexers select live fields while idle and held fields while busy. TAG_MATCH is a fixed structural RV32IRequestTagMatch: inputs CURRENT[32] and SAVED[32] feed 32 XOR comparisons and an OR-reduction tree, producing CHANGED. Payload, handshake state, and response handling remain visible at the requester level.

Payload register Width Purpose
REQUEST_TAG 32 Compare the saved request identity with the current tag
REQUEST_OP 3 Hold the operation while the request is pending
REQUEST_ADDR 32 Hold the byte address
REQUEST_WRITE_DATA 32 Hold the store data
REQUEST_WRITE_MASK 4 Hold the byte enables

These are 103 payload bits plus three handshake-state bits. A payload register is one word with shared CLK/RST/WE, not independently addressed bits. Its structural implementation contains FF cells; its behavioral implementation stores the same vector in one component.

The advanced core's fetch requester is read-only and uses its saved address as the request tag. It stores only REQUEST_ADDR (32 payload bits), while driving the constant Read operation, zero write data, and full byte mask onto the bus. The general data requester retains all five fields, including its variable store payload, to keep a pending request stable under backpressure.

Response data is wired straight from BUS_RSP_READ_DATA to READ_DATA; there is no response register. The retained request/state is why a requester cannot be replaced with a port rename.

Behavioral implementation

RV32IMemoryRequestBehavioral holds its own four-state BUSY, SENT, and ABANDONED bits and saved request fields. It evaluates the request, response, tag-comparison, and register rules used by the structural requester, including uncertain inputs. The compact cores use the separate binary MemoryRequestState for their instruction and data requests. Catalog-selected outputs follow the requesterโ€™s characterized combinational or clock-to-output delays. Fault is still the OR of the status bits and response data is passed through unchanged.

Request presence, reset qualification and response validity are prepared before the late TAKE/discard decision. This shortens the combinational completion path without adding a cycle or changing when either handshake is accepted.

Examples

All 21 recorded rows of RV32IMemoryRequestTest, 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: canonical-default-preview / structural (2d30c34a9a12ed13). Changing fidelity or the circuit can change these times.

Checkpointzero-based number ยท timeline label Timesimulator units ADDRInput ยท 32 bit BUS_REQ_READYInput ยท 1 bit BUS_RSP_READ_DATAInput ยท 32 bit BUS_RSP_STATUSInput ยท 3 bit BUS_RSP_VALIDInput ยท 1 bit CLKInput ยท 1 bit ISSUEInput ยท 1 bit OPInput ยท 3 bit RSTInput ยท 1 bit TAGInput ยท 32 bit TAKEInput ยท 1 bit WRITE_DATAInput ยท 32 bit WRITE_MASKInput ยท 4 bit BUS_REQ_ADDRExpected output ยท 32 bit BUS_REQ_OPExpected output ยท 3 bit BUS_REQ_VALIDExpected output ยท 1 bit BUS_REQ_WRITE_DATAExpected output ยท 32 bit BUS_REQ_WRITE_MASKExpected output ยท 4 bit BUS_RSP_READYExpected output ยท 1 bit DONEExpected output ยท 1 bit FAULTExpected output ยท 1 bit READ_DATAExpected output ยท 32 bit
#0reset13 0x00000100 0 0x00000000 0x0 0 0 0 0x1 1 0x00000000 0 0x12345678 0xF 0x00000100 not checked 0 not checked not checked 0 0 not checked not checked
#1issue-before-edge23 0x00000100 0 0x00000000 0x0 0 0 1 0x1 0 0x00000000 0 0x12345678 0xF 0x00000100 not checked 1 not checked not checked 0 0 not checked not checked
#2capture35 0x00000100 0 0x00000000 0x0 0 1 1 0x1 0 0x00000000 0 0x12345678 0xF 0x00000100 not checked 1 not checked not checked 0 0 not checked not checked
#3payload-held40 0x00000200 0 0x00000000 0x0 0 0 0 0x0 0 0x00000000 0 0x00000000 0x0 0x00000100 0x1 1 0x12345678 0xF not checked not checked not checked not checked
#4backpressure-edge45 0x00000200 0 0x00000000 0x0 0 1 0 0x0 0 0x00000000 0 0x00000000 0x0 0x00000100 not checked 1 not checked not checked 0 0 not checked not checked
#5accept-setup54 0x00000200 1 0x00000000 0x0 0 0 0 0x0 0 0x00000000 0 0x00000000 0x0 0x00000100 not checked 1 not checked not checked 0 0 not checked not checked
#6accepted63 0x00000200 1 0x00000000 0x0 0 1 0 0x0 0 0x00000000 0 0x00000000 0x0 0x00000100 not checked 0 not checked not checked 0 0 not checked not checked
#7response-held68 0x00000200 1 0x89ABCDEF 0x2 1 0 0 0x0 0 0x00000000 0 0x00000000 0x0 not checked not checked not checked not checked not checked 0 1 1 0x89ABCDEF
#8response-held-edge73 0x00000200 1 0x89ABCDEF 0x2 1 1 0 0x0 0 0x00000000 0 0x00000000 0x0 0x00000100 not checked 0 not checked not checked 0 1 not checked not checked
#9take-setup85 0x00000200 1 0x89ABCDEF 0x2 1 0 0 0x0 0 0x00000000 1 0x00000000 0x0 0x00000100 not checked 0 not checked not checked 1 1 not checked not checked
#10taken96 0x00000200 1 0x89ABCDEF 0x2 1 1 0 0x0 0 0x00000000 1 0x00000000 0x0 0x00000200 not checked 0 not checked not checked 0 0 not checked not checked
#11new-issue-setup109 0x00000200 0 0x89ABCDEF 0x2 0 0 1 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 1 not checked not checked 0 0 not checked not checked
#12second-capture126 0x00000200 0 0x89ABCDEF 0x2 0 1 1 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 1 not checked not checked 0 0 not checked not checked
#13redirect-before-accept143 0x00000200 0 0x89ABCDEF 0x2 0 0 0 0x0 0 0x00000008 0 0x00000000 0x0 0x00000200 not checked 1 not checked not checked 1 0 not checked not checked
#14record-abandonment149 0x00000200 0 0x89ABCDEF 0x2 0 1 0 0x0 0 0x00000008 0 0x00000000 0x0 0x00000200 not checked 1 not checked not checked 1 0 not checked not checked
#15tag-returns-ABA158 0x00000200 1 0x89ABCDEF 0x2 0 0 0 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 1 not checked not checked 1 0 not checked not checked
#16abandoned-accepted167 0x00000200 1 0x89ABCDEF 0x2 0 1 0 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 0 not checked not checked 1 0 not checked not checked
#17stale-response179 0x00000200 1 0x89ABCDEF 0x2 1 0 0 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 0 not checked not checked 1 0 not checked not checked
#18stale-drained189 0x00000200 1 0x89ABCDEF 0x2 1 1 0 0x0 0 0x00000004 0 0x00000000 0x0 0x00000200 not checked 0 not checked not checked 0 0 not checked not checked
#19ungated-response-wires194 0x00000200 1 0x89ABCDEF 0x2 0 0 0 0x0 0 0x00000004 0 0x00000000 0x0 not checked not checked not checked not checked not checked not checked 0 1 0x89ABCDEF
#20reset-again208 0x00000200 1 0x89ABCDEF 0x2 0 0 0 0x0 1 0x00000004 0 0x00000000 0x0 0x00000200 not checked 0 not checked not checked 0 0 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.

Embedded simulation

Open memory requester

Tests

RV32IMemoryRequestTest records 21 checkpoints: capture, backpressure, payload stability, acceptance, held response, faults, redirect/ABA abandonment, draining, and reset. RV32IMemoryMigrationTest checks transaction endpoints and zero-wait single-cycle integration. RV32IBuildingBlocksDocumentationTest executes the C++ examples. Sources: RV32IMemoryLanes.cpp and RV32IMemoryRequest.cpp.