Altera® AXI4 Bus Functional Model User Guides

ID 838773
Date 5/19/2025
Public
Document Table of Contents

2.4.1. Using the Transmitter BFM Flow

The following steps describe implementation of the Transmitter BFM from the Quartus® Prime Pro Edition IP Catalog or from Platform Designer. You can use either the IP Catalog flow to define a single Transmitter BFM and testbench, or use the Platform Designer flow to integrate the BFM and testbench into a Platform Designer system.

IP Catalog Transmitter BFM Generation Flow

  1. From the Quartus® Prime Pro Edition software IP Catalog, search for the Altera AXI4 Streaming Transmitter BFM.
  2. In the IP parameter editor, specify appropriate parameters and generate the HDL for your transmitter configuration.
  3. Create a testbench and connect the Transmitter BFM to the DUT.
  4. To access the Transmitter BFM, use the following hierarchy:
    <bfm inst>.axi4_stream_bfm_transmitter_0.axi4_stream_tx_bfm

Platform Designer Transmitter BFM Generation Flow

  1. In the Quartus® Prime Pro Edition software, click Tools > Platform Designer.
  2. In Platform Designer's IP Catalog, search for the Altera AXI4 Streaming Transmitter BFM.
  3. In the IP parameter editor, specify appropriate parameters for your Transmitter configuration.
  4. To generate the Platform Designer system and testbench, click Generate HDL.
  5. To access the Transmitter BFM in the testbench, use the following hierarchy:
    <PD system inst>.<PD bfm inst>.<PD bfm inst>.axi4_stream_tx_bfm

Creating a Testbench using the AXI4 Streaming BFM

  1. Import the required Altera AXI4 Streaming BFM SystemVerilog packages:
    import altera_lnsim_ver.axi4_stream_bfm_types_pkg::*;
    import altera_lnsim_ver.axi4_stream_bytes_class_pkg::*;
    import altera_lnsim_ver.axi4_stream_transfer_class_pkg::*;
    import altera_lnsim_ver.axi4_stream_packet_class_pkg::*;
  2. Define the transfers and packets:
    // Transfer
    Axi4StreamTransfer#(.AXI4_STREAMING_DATA_BUS_WIDTH(DATA_BUS_WIDTH),
    .AXI4_STREAMING_TID_WIDTH(TID_WIDTH),
    .AXI4_STREAMING_TDEST_WIDTH(TDEST_WIDTH),
    .AXI4_STREAMING_TUSER_WIDTH(TUSER_WIDTH)) tx_tr;
    
    // Packet
    Axi4StreamPacket#(.AXI4_STREAMING_DATA_BUS_WIDTH(DATA_BUS_WIDTH),
    .AXI4_STREAMING_TID_WIDTH(TID_WIDTH),
    .AXI4_STREAMING_TDEST_WIDTH(TDEST_WIDTH),
    .AXI4_STREAMING_TUSER_WIDTH(TUSER_WIDTH)) p;
  3. Create the transfer:
    tx_tr = new();
  4. Load data from data buffer or from data queue:
    • Option 1: Load from data buffer:
      //Define data buffer
      byte_t byte_buf [];
      …
      byte_buf = '{8'h00, 8'h11, 8'h22, 8'h33, 8'h44, 8'h55, 8'h66, 8'h77,
      	8'h88, 8'h99, 8'hAA, 8'hBB, 8'hCC, 8'hDD, 8'hEE, 8'hFF,
      	8'h10, 8'h11, 8'h12, 8'h13, 8'h14, 8'h45, 8'h16, 8'h17,
      	8'h18, 8'h19, 8'h1A, 8'h1B, 8'h1C, 8'h1D, 8'h1E, 8'h1F};
      
      	tx_tr.set_payload_from_data(byte_buf);
      	tx_tr.set_gap(5);
    • Option 2: Load from data queue:
      //Define byte classes, byte arrays and queue
      Axi4StreamBytes#(AXI4_STREAMING_TUSER_WIDTH)         asb;// Super Class
      Axi4StreamBytesData#(AXI4_STREAMING_TUSER_WIDTH)     asbd;// data
      Axi4StreamBytesPosition#(AXI4_STREAMING_TUSER_WIDTH) asbp;// position
      Axi4StreamBytesNull#(AXI4_STREAMING_TUSER_WIDTH)     asbn;// null
      Axi4StreamBytes#(AXI4_STREAMING_TUSER_WIDTH)         ba[];// array
      Axi4StreamBytes#(AXI4_STREAMING_TUSER_WIDTH)         q[$];// queue
      …
      // Load queue with bytes
      	q.delete();
      	asbd = new(8'h00);
      	asbd.set_tuser_value('hbcd);
      	asb  = asbd;
      	q.push_back(asb);
      	asbd = new(8'h11);
      	asb  = asbd;
      	q.push_back(asb);
      	asbd = new(8'h22);
      	asb  = asbd;
      	q.push_back(asb);
      	asbd = new(8'h33);
      	asb  = asbd;
      	q.push_back(asb);
      …
      	//Position Byte
      	asbp = new();
      	asb  = asbp;
      	q.push_back(asb);
      	//Null Byte
      	asbn = new();
      	asb  = asbn;
      	q.push_back(asb);
          asbd = new(8'h17);
      	asb  = asbd;
      	q.push_back(asb);
      	asbd = new(8'h18);
      	asbd.set_tuser_value(0);
      	asb  = asbd;
      	q.push_back(asb);
      
      // Load byte array
      	ba = new[q.size()];
      	for(i=0; i<q.size(); i++)
      	begin
      		ba[i] = q[i];	
      	end
      
      // Configure transfer as needed:
      	tx_tr.set_tid('hf);
          tx_tr.set_tdest(7);
          tx_tr.set_gap(5);
          tx_tr.set_delay(5);
      
      Load byte array into transfer
      	tx_tr.set_payload_from_bytes(ba);
      
      Transmit packet:
          <bfm>.transmit_bfm.put_packet_for_transmit(p);