Altera® AXI4 Bus Functional Model User Guides

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

1.4.2. Using the Altera® AXI4 Memory-Mapped Subordinate BFM Flow

The following steps guide you through the Subordinate BFM flow:
  1. For the Subordinate BFM, import the altera_axi_bfm_pkg and host_memory_class_pkg from the altera_lnsim_ver library:
    import altera_lnsim_ver.altera_axi_bfm_pkg::*;
    import altera_lnsim_ver.host_memory_class_pkg::*;
    
  2. Make declarations for read and write transactions and the subordinate BFM:
    AlteraAxiTransaction wr_resp_tr, rd_resp_tr; 
    BaseAxiBfm#(ADDR_WIDTH, DATA_WIDTH, ID_WIDTH, USER_WIDTH) axi_sub_bfm;
    
    
  3. Assign the BaseAxiBfm object to the subordinate BFM, using the proper mode.

    For AXI4:

    axi_sub_bfm = <bfm_intf>.AXI4SUB.bfm;

    For AXI4-Lite:

    axi_sub_bfm = <bfm inst>.AXI4LITESUB.bfm
  4. Before using the BFM, use s_reset to reset the BFM:
    axi_sub_bfm.s_reset();
  5. Create the read and write response transactions:
    wr_resp_tr = axi_sub_bfm.subordinate_bfm_wr_resp_tx(); 
    rd_resp_tr = axi_sub_bfm.subordinate_bfm_rd_resp_tx();
    
  6. Optionally, initialize host memory by using initialize data():
    byte_t init_buf[];
    ...
    fork 
    	//Initialise the memory 
    	init_buf = new[8]; 
    	
    	init_buf = {<<byte_t{64'h0000_ffff_0000_ffff}};
    	<bfm_intf>.host_memory.initialize_data(0, init_buf); 
          init_buf = {<<byte_t{64'hffff_1111_ffff_1111}}; 
    	<bfm_intf>.host_memory.initialize_data(8, init_buf); 
    	init_buf = {<<byte_t{64'h2222_ffff_2222_ffff}}; 
    	<bfm_intf>.host_memory.initialize_data(16, init_buf); 
          init_buf = {<<byte_t{64'h1111_2222_3333_4444}}; 
    	<bfm_intf>.host_memory.initialize_data(24, init_buf);
    join
  7. Execute response transactions for both read and write responses:
    fork 
    	forever begin	
    	axi_sub_bfm.put_transaction(rd_resp_tr);  		   
    	axi_sub_bfm.drive_transaction();   
    	end
    	
    	forever begin
    	axi_sub_bfm.put_transaction(wr_resp_tr); 	 		   
    	axi_sub_bfm.drive_transaction();   
    	end
    join