Skip to content

§ 3.3.6. Scalable Native Devices

Each FF, SRAM, DRAM, ROM and NOR-flash native device has a structural form and a scalable behavioral form under the same device contract. Both have the technology's native pins and behavior. A standalone device has no request queue or response register.

Component Description Structural Behavioral
FFMemory<W>, SRAM<W>, DRAM<W>, ROM<W>, NORFlash<W> Native device; structural form for small geometries, behavioral form for scalable capacity Yes Yes

The technology pages document the structural cells and complete native interfaces. A memory controller can drive either form of the same device contract.

Configuration

W fixes the data-pin width: 8, 16, or 32 bits. N=depth_words is selected at construction. Capacity is N×W/8 bytes and must fit the 32-bit byte-address range. K=words_per_row describes physical row organization, not host paging. FF does not use K; the other devices accept K=1/2/4/8/16 dividing N.

Parameter Default Meaning
depth_words 4 in C++; 4096 in the Python factory Number of addressed words
paged 1 Allocate host pages only when contents differ from the initial fill
max_resident_bytes 67,108,864 Content allocation budget; DRAM also checks row metadata
record_history 1 Record memory-content history
max_history_bytes 16,777,216 Fail-fast history budget; no silent eviction

Geometry parameters follow the selected device; its timing comes from the active profile. Refresh is a controller's job: a DRAM device does not refresh itself.

Host pages cover 4096 simulated bytes and store value/known masks. Untouched capacity does not allocate content pages. DRAM keeps metadata only for visited rows, and ROM parses only the supplied image prefix. Budgets are not a process-RSS cap: event history, objects, temporary buffers, and allocator overhead also consume memory. Disable memory and simulator histories separately for long performance runs.

Python creates a 1 MiB direct FF device as follows:

memory = circuit_backend.create_memory_device(
    "MEMORY", "ff", data_width=32, depth_words=262144,
    parameters={"paged": "1", "record_history": "0"},
)

The C++ helper is createBehavioralMemoryDevice("MEMORY", 32, Technology::FF, config). The catalog ID is memory.<technology>.device.<width> at both fidelities. For a transaction interface, request memory.<technology>.scalable-endpoint.<width>; its structural form contains a controller and requires the native device's behavioral fidelity.

3.3.6.1. FFMemory<W> and other behavioral native devices

The selected technology fixes the native pin schema. Changing capacity does not change the pins; changing technology may.

IO pins

The following table is the FF-model interface used by the embedded example and strict single-cycle core.

Pin Direction Width Description
WORD_ADDR Input 32 Word index, not byte address
WRITE_DATA Input W Positioned store bits
WRITE_MASK Input W/8 Enabled byte lanes
WE, READ_EN Input 1 Rising-edge write enable; asynchronous read enable
CLK, RST Input 1 Write clock; active-high storage reset
READ_DATA Output W Selected word, or zero when disabled/out of range
FAULT Output 1 Invalid active access; X for unknown required controls

Other models expose the complete interfaces in SRAM, DRAM, ROM, and NOR flash, including DRAM ROW_OPEN and flash WRITE_ENABLED. They do not expose REQ/RSP pins. A universal requester connects to a matching technology controller, not directly to these native pins.

Behavior

Model Access and storage rules Direct single-cycle CPU suitability
FF Asynchronous read; masked write on LOW→HIGH CLK; native reset clears all words Yes, with sufficient combinational settling time
SRAM Asynchronous CE/WE/OE (a change restarts the access, READY reports completion), or a clocked macro Needs wait cycles from a controller; the clocked macro fits a clocked system directly
DRAM ACT, column READ/WRITE, PRECHARGE, REFRESH; destructive sampling, restore, retention Requires command sequencing; not an instantaneous RAM
ROM Asynchronous read with READY; construction image with zero-filled tail; no runtime write Needs wait cycles from a controller when the read is longer than a cycle
NOR flash WREN, timed PROGRAM/ERASE, READ; programming clears bits and erase restores ones Requires command sequencing for modifications

The strict single-cycle system currently uses the FF model for both instruction and data storage. It ties native memory RST low so resetting the CPU preserves its images. PC, registers, and data-memory writes use the same edge. Capacity affects host storage, not a mandatory number of CPU cycles.

Image provisioning through initializeMemoryBytes is allowed only before the first evaluation. It is distinct from runtime pins and from reset; reset never reopens provisioning. ROM/flash provisioning describes an initial image, not an instruction that changes read-only/flash programming rules. Native-device references remain authoritative for all technology-specific behavior.

C++ example

This four-state FF reference spells out the direct-access behavior. It reuses only value helpers and bounded MemoryStorage, not the simulator's device algorithm. Native SRAM/DRAM/ROM/flash use the complete behavioral examples in their respective sections; choosing behavioral fidelity adds no protocol state.

#include "modules/memory/DigitalMemory.hpp"
namespace memory_native_example {
using namespace circuit::memory_device;
template<size_t W> class FF {
    MemoryStorage storage;
    LogicValue previous = X;
public:
    struct Inputs {
        Bits WORD_ADDR = bits(32,0), WRITE_DATA = Bits(W,L),
             WRITE_MASK = Bits(W/8,L);
        LogicValue CLK=L, RST=L, WE=L, READ_EN=L;
    };
    struct Outputs { Bits READ_DATA; LogicValue FAULT; };
    explicit FF(size_t words)
        : storage(words,W,X,true,{true,64*1024*1024,16*1024*1024}) {}
    Outputs evaluate(size_t time,const Inputs& i) {
        const bool address_known=known(i.WORD_ADDR);
        const bool mask_known=known(i.WRITE_MASK);
        const auto word=number(i.WORD_ADDR);
        const bool selected=address_known && word<storage.capacityWords();
        LogicValue fault=L;
        if(i.WE!=L || i.READ_EN!=L) {
            if(!binary(i.WE)||!binary(i.READ_EN)||!address_known||(i.WE==H&&!mask_known)) fault=X;
            else if(!selected) fault=H;
        }
        if(i.RST==H) storage.fill(time,L);
        else if(!binary(i.RST)) storage.fill(time,X);
        else if(previous==L && i.CLK==H && i.WE==H && selected && mask_known && fault==L) {
            for(size_t byte=0;byte<W/8;++byte) if(i.WRITE_MASK[byte]==H)
                storage.writeLogic(time,word*(W/8)+byte,
                    Bits(i.WRITE_DATA.begin()+byte*8,i.WRITE_DATA.begin()+(byte+1)*8),true);
        }
        previous=i.CLK;
        Bits result(W,L);
        if(!binary(i.READ_EN)||(i.READ_EN==H&&!address_known)) result.assign(W,X);
        else if(i.READ_EN==H&&selected) result=storage.readLogic(word*(W/8),W/8);
        return {result,fault};
    }
};
}

Unknown inputs

Stored Z becomes X. The FF model reads without any clock edge and writes only on a known LOW→HIGH transition. Unknown reset makes FF contents unknown; unknown required access controls produce FAULT=X. Reads still take time to settle, so “single-cycle” does not mean zero delay. The SRAM, DRAM and flash timing stays in force at any capacity; a large capacity does not remove it or turn it into CPU wait cycles.

Implementation

The native device contract selects its tested behavioral implementation at scalable capacity. Each technology keeps its own rules (the FF array, the SRAM access, the DRAM and NOR command controls edge for edge, the ROM read); they share host allocation and provisioning, not one universal cell algorithm.

For a visible transaction wrapper, request memory.<technology>.scalable-endpoint.<width>: its structural controller drives the native device at behavioral fidelity. The endpoint's fused behavioral alternative is BehavioralMemoryEndpoint, documented in 3.5.

Timing. A device too large to build from gates cannot have delays proven on its own gates. Every device is therefore also proven at 64 and 128 words, and a larger device gets a table in which each delay keeps growing per doubling as it did between those two sizes; its evidence line says it is an estimate. The read path of two technologies at the proven sizes:

Latest time each path can still change after its input (for a setup row: how long before the edge the input must be stable), proven on the gate-level form.

Pathunitticksembeddedpsdesktopps
FF, scenario size WORD_ADDR → READ_DATA8390271
FF, 64 words WORD_ADDR → READ_DATA14692482
FF, 128 words WORD_ADDR → READ_DATA16794553
SRAM, 64 words WORD_ADDR → READ_DATA2182,4401,695
SRAM, 128 words WORD_ADDR → READ_DATA2362,9302,038

Examples

The FF scenario starts with behavioral fidelity and can switch to the structural form through the profile control. It covers all four words, asynchronous reads, edge-triggered writes, byte masks, invalid addresses, and storage reset. It does not need a request-accept or response-consume edge.

All 52 recorded rows of NativeMemoryDeviceTest, 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-visual-v1 / behavioral (d40d996d657bc2a7). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units CLKInput · 1 bit READ_ENInput · 1 bit RSTInput · 1 bit WEInput · 1 bit WORD_ADDRInput · 32 bit WRITE_DATAInput · 8 bit WRITE_MASKInput · 1 bit FAULTExpected output · 1 bit READ_DATAExpected output · 8 bit
#0initial-disabled17 0 0 1 0 0x00000000 0x00 1 0 0x00
#1release-reset18 0 0 0 0 0x00000000 0x00 1 0 0x00
#2setup-019 0 0 0 0 0x00000000 0x81 1 0 0x00
#3write-enable-020 0 0 0 1 0x00000000 0x81 1 0 0x00
#4write-edge-021 1 0 0 1 0x00000000 0x81 1 0 0x00
#5finish-write-022 0 0 0 0 0x00000000 0x81 1 0 0x00
#6read-025 0 1 0 0 0x00000000 0x81 1 0 0x81
#7setup-128 0 0 0 0 0x00000001 0x80 1 0 0x00
#8write-enable-129 0 0 0 1 0x00000001 0x80 1 0 0x00
#9write-edge-130 1 0 0 1 0x00000001 0x80 1 0 0x00
#10finish-write-131 0 0 0 0 0x00000001 0x80 1 0 0x00
#11read-134 0 1 0 0 0x00000001 0x80 1 0 0x80
#12setup-237 0 0 0 0 0x00000002 0x83 1 0 0x00
#13write-enable-238 0 0 0 1 0x00000002 0x83 1 0 0x00
#14write-edge-239 1 0 0 1 0x00000002 0x83 1 0 0x00
#15finish-write-240 0 0 0 0 0x00000002 0x83 1 0 0x00
#16read-243 0 1 0 0 0x00000002 0x83 1 0 0x83
#17setup-346 0 0 0 0 0x00000003 0x82 1 0 0x00
#18write-enable-347 0 0 0 1 0x00000003 0x82 1 0 0x00
#19write-edge-348 1 0 0 1 0x00000003 0x82 1 0 0x00
#20finish-write-349 0 0 0 0 0x00000003 0x82 1 0 0x00
#21read-352 0 1 0 0 0x00000003 0x82 1 0 0x82
#22read-back-353 0 1 0 0 0x00000003 0x82 1 0 0x82
#23read-back-268 0 1 0 0 0x00000002 0x82 1 0 0x83
#24read-back-183 0 1 0 0 0x00000001 0x82 1 0 0x80
#25read-back-098 0 1 0 0 0x00000000 0x82 1 0 0x81
#26invalid-4-read107 0 1 0 0 0x00000004 0x82 1 1 0x00
#27invalid-4-disabled110 0 0 0 0 0x00000004 0x82 1 0 0x00
#28invalid-4-write-enable113 0 0 0 1 0x00000004 0x00 1 1 0x00
#29invalid-4-write-edge114 1 0 0 1 0x00000004 0x00 1 1 0x00
#30invalid-4-write-end117 0 0 0 0 0x00000004 0x00 1 0 0x00
#31invalid-2147483648-read125 0 1 0 0 0x80000000 0x00 1 1 0x00
#32invalid-2147483648-disabled128 0 0 0 0 0x80000000 0x00 1 0 0x00
#33invalid-2147483648-write-enable131 0 0 0 1 0x80000000 0x00 1 1 0x00
#34invalid-2147483648-write-edge132 1 0 0 1 0x80000000 0x00 1 1 0x00
#35invalid-2147483648-write-end135 0 0 0 0 0x80000000 0x00 1 0 0x00
#36invalid-4294967295-read138 0 1 0 0 0xFFFFFFFF 0x00 1 1 0x00
#37invalid-4294967295-disabled141 0 0 0 0 0xFFFFFFFF 0x00 1 0 0x00
#38invalid-4294967295-write-enable144 0 0 0 1 0xFFFFFFFF 0x00 1 1 0x00
#39invalid-4294967295-write-edge145 1 0 0 1 0xFFFFFFFF 0x00 1 1 0x00
#40invalid-4294967295-write-end148 0 0 0 0 0xFFFFFFFF 0x00 1 0 0x00
#41after-invalid-writes-3163 0 1 0 0 0x00000003 0x00 1 0 0x82
#42after-invalid-writes-2178 0 1 0 0 0x00000002 0x00 1 0 0x83
#43after-invalid-writes-1193 0 1 0 0 0x00000001 0x00 1 0 0x80
#44after-invalid-writes-0208 0 1 0 0 0x00000000 0x00 1 0 0x81
#45disable-after-range-checks211 0 0 0 0 0x00000000 0x00 1 0 0x00
#46masked-setup212 0 0 0 0 0x00000000 0x78 1 0 0x00
#47masked-enable213 0 0 0 1 0x00000000 0x78 1 0 0x00
#48masked-edge214 1 0 0 1 0x00000000 0x78 1 0 0x00
#49masked-end215 0 0 0 0 0x00000000 0x78 1 0 0x00
#50masked-read218 0 1 0 0 0x00000000 0x78 1 0 0x78
#51reset-retention236 0 1 1 0 0x00000000 0x78 1 0 0x00

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 native FF device

Source and tests

NativeMemoryDeviceTest supplies every displayed row. MemoryEndpointIntegrationTest.py compiles the exact FF example and checks its outputs against those rows. NativeMemoryDeviceContractTest compares behavioral and structural native devices, checks visible controllers with scalable storage for all five technologies, and exercises 256 MiB logical capacities under small resident budgets. Existing endpoint tests retain handshake/backpressure/reset coverage.

Sources: NativeMemoryDevice.hpp/.cpp, MemoryDeviceStorage.hpp, the native device implementations, and src/tests/MemoryEndpointTests.cpp.