Dillon Engineering
  • Home
  • Company
    • About Us
    • Contact Us
    • Jobs
  • Services
    • Applications
    • Markets
    • Why Hire DE? >
      • Top Down Meets Bottom Up
    • When to Hire DE?
  • FFT IP
    • Load Unload FFT
    • UltraLong FFT >
      • UltraLong FFT IP Core for Xilinx FPGAs
    • Parallel FFT
    • Dual Parallel FFT
    • Parallel Butterfly FFT
    • Mixed Radix FFT >
      • Mixed Radix FFT IP Core for Xilinx FPGAs
    • Pipelined FFT >
      • FFT_PIPE IP Core for Xilinx FPGAs
    • 2D FFT
    • Other IP Cores >
      • Floating Point IP >
        • FPLIC Riviera Evaluation
        • FPLIC Download
        • FPLIC ParaCore Parameters
      • AES Crypto IP >
        • AES PatraCore Parameters
        • AES Background Information
    • FFT/IFFT ParaCore Parameters
  • Ingenuity
    • ParaCore Architect IP Generation >
      • PCA Flow
      • PCA Example
    • Modeling
    • Verification
    • Fixed vs. Floating Point
    • Fixed Point Math
  • News
    • DE Releases Mixed Radix FFT IP Cores for Xilinx FPGAs
    • DE Release UltraLong FFT IP Cores for Xilinx FPGAs
    • DE Releases FFT_PIPE IP Cores for Xilinx FPGAs
    • Floating Point Modules Evaluation Available
    • Chip Design Magazine Article
    • BCD Math
    • UltraLong FFT IP Success
    • DE Releases FFT IP Cores
  • Docs
    • HowTo >
      • Power Calculation Using XPower
      • Strings in Verilog
      • Inferring Block RAM vs. Distributed RAM in XST and Precision
      • Verilog RTL Coding Style Guidelines, Tips and Template
    • Downloads >
      • gen_ise-sh
      • gen-ise-sh-py
      • deModel
      • deModel_tar_gz
      • deModel_win32_exe
    • HPEC Presentations >
      • HPEC 2003 Presentation
      • HPEC 2004 Presentation
      • HPEC 2007 Abstract
      • HPEC 2007 Posters
    • FFT >
      • Load Unload FFT IP Datasheet
      • FFT_MIXED Candidate Core Datasheet
      • DE FFT IP and Sundance SMT702 Flyer
      • UltraLong FFT IP Core for Xilinx Datasheet
      • PIPE_FFT for Xilinx FPGAs Datasheet
      • FFT Datasheet
      • Floating Point FFT Factsheet
      • FFT Success
    • Sundance DE Partnership Release
    • FPGA Webcast
    • FPGAs Go, Go, Go
    • AES Datasheet
    • FPLIC Specification
    • DE Overview

Inferring Block RAM vs. Distributed RAM in XST and Precision


This is a description of how to infer Xilinx FPGA block RAM or distributed RAM through HDL coding style and synthesis attributes/pragmas. Verilog GENERATE is an easy way to choose between the types without digging into the hierarchy. Verilog is the HDL of choice, and the tools are Xilinx XST (ISE 8.1) and Mentor Graphics Precision 2005c.99.

Intro

Sometimes it's desirable to have the ability to control whether an HDL memory block is inferred as a block RAM or distributed RAM easily, such as thru an attribute or parameter. Below is some example Verilog code for a 1Kb x 16 single port RAM (the attribute/pragma for both XST and Precision are present and have no effect on each other):

 
    input           Clk;
    input           We;
    input  [9:0]    Waddr;
    input  [9:0]    Raddr;
    input  [15:0]   Din;
    output [15:0]   Dout;
 
    //synthesis attribute ram_style of mem is distributed
    reg    [9:0]  mem[0:1023]; //pragma attribute mem ram_block FALSE
    reg    [9:0]  raddr_reg;
 
    always @ (posedge Clk)
    begin
      raddr_reg  <= Raddr;
 
      if (We) begin     
        mem[Waddr]  <= Din;  
      end
 
      //Dout  <= mem[raddr_reg];   //registered read
 
    end
 
    assign Dout = mem[raddr_reg];  //unregistered read            

input Clk; input We; input [9:0] Waddr; input [9:0] Raddr; input [15:0] Din; output [15:0] Dout; //synthesis attribute ram_style of mem is distributed reg [9:0] mem[0:1023]; //pragma attribute mem ram_block FALSE reg [9:0] raddr_reg; always @ (posedge Clk) begin raddr_reg <= Raddr; if (We) begin mem[Waddr] <= Din; end //Dout <= mem[raddr_reg]; //registered read end assign Dout = mem[raddr_reg]; //unregistered read 

XST

//synthesis attribute ram_style of mem is distributed (or block)

Xilinx's XST will infer block RAM if the read address is registered inside the module. Setting the ram_style attribute to block or absence of the attribute has no effect. If the read address is not registered or the ram_style attribute is set to distributed, distributed RAM will be inferred. Registering the write data & address or the read output have no effect on block RAM vs. distributed RAM. (Note: the first "s" in synthesis must be lower case.)

Precision

//pragma attribute mem ram_block FALSE (or TRUE)

Mentor's Precision will infer block RAM if 1) the memory read data is registered, or 2) the read address is registered. Setting the pragma to TRUE or absence of the pragma has no effect. If the above conditions aren't met or the ram_block pragma is set to FALSE, distributed RAM will be inferred. The XST ram_style attribute has no effect in Precision.

Hierarchically controlling the RAM inferrence

The synthesis attributes and pragmas listed above can't be used hierarchically, such as a level up where the RAM is instantiated. However, the Verilog 2001 generate can be used with a parameter (which can be passed down through the hierarchy) to choose between block RAM and distributed RAM. The RAM module is duplicated with the correct attribute or pragma. Here's an example:
    parameter blockram = 1;
 
    generate 
      if (blockram)
      begin: blockr          //block RAM
        memb bram (
          .Clk    (Clk),
          ....
          );
      end
      else begin : distr     //distributed RAM
        memd dram (
          .Clk    (Clk),
          ...
          );
      end
    endgenerate
OUR SERVICES

Applications
Markets

OUR IP

FFT
AES
Floating Point

CONTACT US

info@dilloneng.com
952.836.2413
Contact Page
Picture

© 2022 Dillon Logic LLC
All Rights Reserved