Skip to content

Memories

A memory is declared as an array. __memory(READ_TIMING, COLLISION) states how it behaves.

sample_buffer.flux
__fpga void sampleBuffer(clock clk, bits<10> addr, bits<8> dataIn,
bits<1> writeEnable, bits<8>& dataOut) {
__memory(clocked, write_first) bits<8> samples[1024];
__onRise(clk) {
if (writeEnable) {
samples[addr] = dataIn;
}
}
dataOut = samples[addr];
}
Option Values Meaning
Read timing clocked, async Read on the clock edge, or immediately
Collision write_first, read_first, undefined What a read returns while that address is written

read_first requires clocked reads. A memory without the annotation reads asynchronously, which limits it to distributed RAM (4096 bits in the generic technology).

You do not name block sizes or counts. The selected board decides how many blocks a memory needs.

flux --emit=hardblocks sample_buffer.flux

A memory that needs more blocks than the board has is rejected.