Professional Documents
Culture Documents
ECE448 Lecture19 Memory
ECE448 Lecture19 Memory
Programmable Logic
Memories
Recommended reading
• Vivado Design Suite User Guide: Synthesis
Chapter 4
• RAM HDL Coding Techniques
• Initializing RAM Contents
• 7 Series FPGAs Memory Resources: User Guide
• Chapter 1: Block RAM Resources
• 7 Series FPGAs Configurable Logic Block: User Guide
• Chapter 2: Functional Details: Distributed RAM
2
Memory Types
3
Memory Types
Memory
ROM RAM
Memory
Memory
4
Memory Types specific to Xilinx FPGAs
Memory
Memory
Inferred Instantiated
Manually Using
Vivado
5
FPGA Distributed
Memory
Location of Distributed RAM
Logic resources
RAM blocks
RAM blocks
(CLB slices)
DSP units
Multipliers
Logic
Logic blocks
resources
7
SLICEL
8
SLICEM
16-bit SR
32-bit SR
16
64xx 11 RAM
RAM
4-input LUT
64 x 1 ROM
(logic)
10
Single-port 64 x 1-bit RAM
11
Single-port 64 x 1-bit RAM
12
Memories Built of Neighboring MLUTs
13
Dual-port 64 x 1 RAM
• Dual-port 64 x 1-bit RAM : 64x1D
• Single-port 128 x 1-bit RAM: 128x1S
14
Dual-port 64 x 1 RAM
• Dual-port 64 x 1-bit RAM : 64x1D
• Single-port 128 x 1-bit RAM: 128x1S
15
FPGA Block RAM
16
Location of Block RAMs
Logic resources
RAM blocks
RAM blocks
(CLB slices)
DSP units
Multipliers
Logic
Logic blocks
resources
17
Block RAM
Configured as
1 x 36 kbit RAM
or
2 x 18 kbit RAMs
18
Block RAM
8k x 2 4k x 4
4,095
16k x 1 8,191
8+1
0
2k x (8+1)
2047
16+2
0
1023
1024 x (16+2)
16,383
20
21
22
18k Block RAM Port Aspect Ratios
23
Block RAM Interface
24
Block RAM Ports
25
Cascadable Block RAM
26
Block RAM Waveforms – READ_FIRST mode
27
Block RAM Waveforms – WRITE_FIRST mode
28
Block RAM Waveforms – NO_CHANGE mode
29
Features of Block RAMs
30
Inference
vs.
Instantiation
31
32
Generic
Inferred
ROM
33
Distributed ROM with asynchronous read
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
Entity ROM is
generic ( w : integer := 12;
-- number of bits per ROM word
r : integer := 3);
-- 2^r = number of words in ROM
port (addr : in std_logic_vector(r-1 downto 0);
dout : out std_logic_vector(w-1 downto 0));
end ROM;
34
Distributed ROM with asynchronous read
35
Distributed ROM with asynchronous read
36
Generic
Inferred
RAM
37
Distributed versus Block RAM Inference
Examples:
1. Distributed single-port RAM with asynchronous read
38
Distributed single-port RAM with asynchronous
read
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
entity raminfr is
generic ( w : integer := 32;
-- number of bits per RAM word
r : integer := 6);
-- 2^r = number of words in RAM
port (clk : in std_logic;
we : in std_logic;
a : in std_logic_vector(r-1 downto 0);
di : in std_logic_vector(w-1 downto 0);
do : out std_logic_vector(w-1 downto 0));
end raminfr;
39
Distributed single-port RAM with asynchronous
read
architecture behavioral of raminfr is
type ram_type is array (0 to 2**r-1)
of std_logic_vector (w-1 downto 0);
signal RAM : ram_type := (others => (others => '0'));
begin
process (clk)
begin
if rising_edge(clk) then
if (we = '1') then
RAM(to_integer(unsigned(a))) <= di;
end if;
end if;
end process;
do <= RAM(to_integer(unsigned(a)));
end behavioral;
40
Distributed dual-port RAM with asynchronous read
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity raminfr is
generic ( w : integer := 32;
-- number of bits per RAM word
r : integer := 6);
-- 2^r = number of words in RAM
port (clk : in std_logic;
we : in std_logic;
a : in std_logic_vector(r-1 downto 0);
dpra : in std_logic_vector(r-1 downto 0);
di : in std_logic_vector(w-1 downto 0);
spo : out std_logic_vector(w-1 downto 0);
dpo : out std_logic_vector(w-1 downto 0));
end raminfr;
41
Distributed dual-port RAM with asynchronous read
42
Block RAM Waveforms – READ_FIRST mode
43
Block RAM with synchronous read
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
entity raminfr is
generic ( w : integer := 32;
-- number of bits per RAM word
r : integer := 9);
-- 2^r = number of words in RAM
port (clk : in std_logic;
we : in std_logic;
en : in std_logic;
addr : in std_logic_vector(r-1 downto 0);
di : in std_logic_vector(w-1 downto 0);
do : out std_logic_vector(w-1 downto 0));
end raminfr;
44
Block RAM with synchronous read
Read-First Mode - cont'd
architecture behavioral of raminfr is
type ram_type is array (0 to 2**r-1) of
std_logic_vector (w-1 downto 0);
signal RAM : ram_type := (others => (others => '0'));
begin
process (clk)
begin
if rising_edge(clk) then
if (en = '1') then
do <= RAM(to_integer(unsigned(addr)));
if (we = '1') then
RAM(to_integer(unsigned(addr))) <= di;
end if;
end if;
end if;
end process;
end behavioral;
45
Block RAM Waveforms – WRITE_FIRST mode
46
Block RAM with synchronous read
Write-First Mode - cont'd
architecture behavioral of raminfr is
type ram_type is array (0 to 2**r-1) of
std_logic_vector (w-1 downto 0);
signal RAM : ram_type := (others => (others => '0'));
begin
process (clk)
begin
if (clk'event and clk = '1') then
if (en = '1') then
if (we = '1') then
RAM(to_integer(unsigned(addr))) <= di;
do <= di;
else
do <= RAM(to_integer(unsigned(addr)));
end if;
end if;
end if;
end process;
end behavioral;
47
Block RAM Waveforms – NO_CHANGE mode
48
Block RAM with synchronous read
No-Change Mode - cont'd
architecture behavioral of raminfr is
type ram_type is array (0 to 2**r-1) of
std_logic_vector (w-1 downto 0);
signal RAM : ram_type := (others => (others => '0'));
begin
process (clk)
begin
if (clk'event and clk = '1') then
if (en = '1') then
if (we = '1') then
RAM(to_integer(unsigned(addr))) <= di;
else
do <= RAM(to_integer(unsigned(addr)));
end if;
end if;
end if;
end process;
end behavioral;
49
Criteria for Implementing Inferred RAM in BRAMs
50
FIFOs
51
FIFO Interface
clk rst
clk rst
FIFO
din dout
8 8
full empty
write read
−−−−− A B C D
53
Operation of the First-Word Fall-Through FIFO
54