FPGA AI Suite Handbook

ID 863373
Date 11/21/2025
Public
Document Table of Contents

12.5.1. Updating Hostless DDR-Free MIF Files Through the CSR

The FPGA AI Suite IP compiler generates the following MIF files in the parameter_rom subdirectory of the compiler output directory:
  • ddrfree_filter_hw_<kvec-index>.mif

    Store the graph weights targeting the M20Ks in each K-vector.

  • ddrfree_bias_scale_hw_<kvec-index>.mif

    Stores the K-vector bias-scale values.

  • ddrfree_config.mif

    The configuration MIF file.

To update the M20K content with a set of new MIF files via the CSR interface, follow this pseudocode:
1  # Update the Filter-Bias-Scale scratchpad
2  # Load all filter-bias-scale MIFs into memory.
3  # All filter MIFs are named as ddrfree_filter_hw_<kvec_id>.mif
4  # All bias-cale MIFs are named as ddrfree_bias_scale_hw_<kvec_id>.mif
5  fbs_mifs[] = load_mifs(fbs_mif_path);
6  for mif in fbs_mifs:
7    for addr, word in mif:
8      for i in [0, 32):
9        # Perform a 32-bit write to the CSR register. The base address is numerated as “byte address”
10       write_to_csr(MODEL_UPDATE_WORD_0 + i*4, word[32*i+31:32*i] if i < number_of_bytes(word)/4 else 0x0);
11     is_bias_scale = 1 if mif.type == bias_scale else 0;
12     write_to_csr(MODEL_UPDATE_CONTROL, (1 << 31) | (is_bias_scale << 30) | (mif.kvec_id << 16) | addr));
13 # Update configuration memory.
14 # Load the configuration MIF file, ddrfree_config.mif
15 conf_mif = load_mif(conf_mif_path);
16 for addr, word in conf_mif:
17   for i in [0, 32):
18     # Perform a 32-bit write to the CSR register. The base address is numerated as “byte address”
19     write_to_csr(MODEL_UPDATE_WORD + i*4, word[32*i+31:32*i] if i < number_of_bytes(word)/4 else 0x0));
20   write_to_csr(MODEL_UPDATE_CONTROL, addr & 0xFFFF);
21 # Wait for data to propagate to the M20Ks.
22 sleep
23 # Invalidate FIFOs holding outdated configuration words
24 assert_reset()  

Each word in an MIF file needs to be broken down into 32-bit chunks and written to the Model Update Word registers, with the least significant chunk targeting Model Update Word 0. Unused Model Update Word registers should be set to 0x0. Once all the chunks of the MIF word are sent, perform another write to register Model Update Control to indicate the type of word and k-vector index (only necessary if the MIF file contains filter weights or bias-scales) information to commit the update, according to the table that follows. The write to the Model Update Control update would cause the CSR interface to assemble the chunks into a memory word, and send it to the embedded memory.

Table 58.  Bit layout of the Model Update Control register
Bit Indices 31 30 29:22 21:16 15:0
Configuration 1’b0 Reserved Word Address in RAM
Filter 1’b1 1’b0 Reserved K-vector Index
Bias-Scale 1’b1 1’b1 Reserved

Finally, wait for 1024 cycles on the ddr_clk for the data to propagate to the M20Ks, and issue a reset to the FPGA AI Suite IP to invalidate FIFOs holding outdated configuration words.