Intel® High Level Synthesis Compiler Standard Edition: Best Practices Guide
                    
                        ID
                        683259
                    
                
                
                    Date
                    12/18/2019
                
                
                    Public
                
            
                
                    
                    
                        1. Intel® HLS Compiler Standard Edition Best Practices Guide
                    
                
                    
                    
                        2. Best Practices for Coding and Compiling Your Component
                    
                
                    
                        3. Interface Best Practices
                    
                    
                
                    
                        4. Loop Best Practices
                    
                    
                
                    
                        5. Memory Architecture Best Practices
                    
                    
                
                    
                        6. Datatype Best Practices
                    
                    
                
                    
                        7. Advanced Troubleshooting
                    
                    
                
                    
                    
                        A. Intel® HLS Compiler Standard Edition Best Practices Guide Archives
                    
                
                    
                    
                        B. Document Revision History for Intel® HLS Compiler Standard Edition Best Practices Guide
                    
                
            
        5.3.2. Example: Merging Memories Width-Wise
Use the hls_merge("<mem_name>","width") attribute to force the Intel® HLS Compiler Standard Edition to implement variables in the same memory system, merging their memories by width.
All variables with the same <mem_name> label set in their hls_merge attributes are merged.
Consider the following component code:
component short width_manual (int raddr, int waddr, short wdata) {
  short a[256];
  short b[256];
  short rdata = 0;
  
  // Lock step write
  a[waddr] = wdata;
  b[waddr] = wdata;
  // Lock step read 
  rdata += a[raddr];
  rdata += b[raddr];
  return rdata;
}
   Figure 16. Implementation of Local Memory for Component width_manual 
    
     
  
 
  In this case, the Intel® HLS Compiler can coalesce the load and store instructions to local memories a and b because their accesses are to the same address, as shown below.
component short width_manual (int raddr, int waddr, short wdata) {
  short a[256] hls_merge("mem","width");
  short b[256] hls_merge("mem","width");
  short rdata = 0;
  
  // Lock step write
  a[waddr] = wdata;
  b[waddr] = wdata;
  // Lock step read 
  rdata += a[raddr];
  rdata += b[raddr];
  return rdata;
}
   Figure 17. Width-Wise Merge of Local Memories for Component width_manual