For the same Verilog RAM, requesting block RAM in AMD Vivado uses ram_style = "block", while Altera Quartus Prime may require ramstyle = "M20K", and Pango Design Suite (PDS) uses syn_ramstyle = "block_ram". When porting a design, check three things: the attribute name, the attribute value, and the object to which the attribute must be applied. Then inspect the synthesis report to confirm which memory resources were actually used.
| Synthesis tool | Attribute name | Dedicated block RAM | Distributed RAM | Registers or general-purpose logic | Common placement |
|---|---|---|---|---|---|
| AMD (Xilinx) Vivado | ram_style |
block; ultra is also available on devices with UltraRAM |
distributed |
registers |
Array declaration, XDC |
| Altera Quartus Prime | ramstyle |
M9K, M10K, M20K, M144K, etc. |
MLAB |
logic |
Array declaration, QSF |
| Lattice Synplify Pro | syn_ramstyle |
block_ram (EBR) |
distributed |
registers |
Synthesis directive after the array declaration |
| Anlogic TangDynasty (TD) | ram_style |
bram |
dram |
none |
Array declaration |
| GowinSynthesis | syn_ramstyle |
block_ram (BSRAM) |
distributed_ram (SSRAM) |
registers |
Array or module declaration, GSC |
| Pango Design Suite (PDS) | syn_ramstyle |
block_ram (DRM) |
lut_ram |
registers |
Read-data port; see the example below |
RAM inference is the process by which a synthesis tool recognizes a memory from a Verilog array and its read/write logic, then implements it using device resources. Block RAM is dedicated memory hardware on the device and is commonly used for larger buffers. Distributed RAM uses part of the logic resources to store data and is commonly used for small buffers. A register implementation uses flip-flops to store individual bits. Attributes can influence resource selection, while the ports, read latency, and reset behavior described in the code also affect whether inference succeeds. AMD Vivado UG912: RAM_STYLE · Quartus Prime: Controlling RAM Inference and Implementation
The ram_style attribute can be placed before an array declaration or set in an XDC file used during synthesis. In the XDC command, replace mem with a name that matches the RAM object in your project. AMD Vivado UG912: RAM_STYLE
(* ram_style = "block" *) reg [7:0] mem [0:1023];
set_property ram_style block [get_cells mem]
The ramstyle attribute can directly select a memory block type available on the device. For example, if the target device has M10K blocks, use the declaration below. You can also set RAMSTYLE_ATTRIBUTE in the Quartus QSF file; the example here uses LOGIC to request implementation in general-purpose logic. Quartus Prime: Controlling RAM Inference and Implementation
(* ramstyle = "M10K" *) reg [7:0] mem [0:1023];
set_instance_assignment -name RAMSTYLE_ATTRIBUTE LOGIC -to mem
Quartus also provides two separate attributes. (* no_ram *) prevents the specified array from being inferred as RAM. (* max_depth = 512 *) limits the depth of each memory block used to implement the array. For example, when applied before reg [7:0] mem [0:1023], the logical RAM still has 1024 addresses. Quartus Prime: Controlling RAM Inference and Implementation
Place the synthesis directive after the array declaration. block_ram selects dedicated EBR, while distributed RAM uses the value distributed. Lattice Synplify Pro Documentation
reg [7:0] mem [0:1023] /* synthesis syn_ramstyle = "block_ram" */;
TD uses ram_style = "bram" to select block RAM. To specify a particular block type or optimization goal, consult the synthesis help for your installed version for options such as bram_9k, bram_20k, bram_32k, and bram_144k, as well as forms such as bram_9k(fast). The suffixes (fast), (power), and (area) target timing, power, and area, respectively. Available combinations depend on the tool version and device family. Anlogic TD Documentation Downloads
(* ram_style = "bram" *) reg [7:0] mem [0:1023];
Gowin also uses syn_ramstyle = "block_ram" for block RAM, while distributed RAM uses distributed_ram. The attribute can be applied to an array declaration or set at the module level or in a synthesis constraint file (GSC). rw_check and no_rw_check control whether the tool inserts or omits compensation logic for reads and writes to the same address. GowinSynthesis User Guide SUG550 §5.16
reg [7:0] mem [0:1023] /* synthesis syn_ramstyle = "block_ram" */;
In PDS, block_ram refers to the device's Dedicated RAM Module (DRM). The following example is a RAM with a single clock, one read port, and one write port. It applies the attribute to the read-data port q; check the synthesis help for your tool version to confirm the accepted attribute locations and values. we and re are the write and read enables, and waddr and raddr are their respective addresses. Pango PDS Tool Page
module ram_sdp #(
parameter ADDR_W = 11,
parameter DATA_W = 18
) (
input wire clk,
input wire we,
input wire re,
input wire [ADDR_W-1:0] waddr,
input wire [ADDR_W-1:0] raddr,
input wire [DATA_W-1:0] din,
output reg [DATA_W-1:0] q /* synthesis syn_ramstyle = "block_ram" */
);
reg [DATA_W-1:0] mem [0:(2**ADDR_W)-1];
always @(posedge clk) begin
if (we)
mem[waddr] <= din;
if (re)
q <= mem[raddr];
end
endmodule
In functional simulation, this code reads the old value when a read and a write access the same address in the same cycle. Logos2 DRM requires avoiding this access pattern in simple dual-port mode. When instantiating this module, therefore, ensure that the two addresses differ whenever we and re are both asserted. Pango Logos2 DRM User Guide UG040002 §4.5
low_power Prioritize Matching the Width?The setting syn_ramstyle = "block_ram,low_power" requests DRM with a preference for low-power mapping. “Match width first, then depth” can be understood as arranging each group of memory blocks to hold a complete data word where possible, then grouping them by address range. Consider a 2048 × 18 memory: it has 2048 addresses, each storing 18 bits. When using exactly two Logos2 18K blocks, there are two possible arrangements. Pango Logos2 DRM User Guide UG040002, Table 4-3
2048 × 9 blocks, one for the upper 9 bits and one for the lower 9 bits of each word. Reading address 1500 activates both blocks.1024 × 18 blocks, one for the first 1024 addresses and one for the remaining 1024. When reading address 1500, the most significant address bit selects the second block, and only its local address 1500 - 1024 = 476 is read.When the upper address bits also control the block enables, each port access needs to activate only one bank, potentially reducing internal switching and dynamic power. Dividing the memory into address banks adds bank-selection and read-data multiplexing logic. This example is derived from the configurations supported by the device; inspect the mapped netlist to confirm the actual partitioning and enable connections. AMD Vivado UG901: A Similar Low-Power Decomposition Example
no_rw_check affects behavior during a collision cycle. Whether it is appropriate depends on whether the design relies on that cycle's output and whether the device permits such accesses. Quartus Prime: Check Read-During-Write Behavior