Professional Documents
Culture Documents
Memories in Verilog
Memories on the FPGA
External Memories
-- SRAM (async, sync)
-- DRAM
-- Flash
6.111 Fall 2008
Lecture 7
Lecture 7
Memories in Verilog
reg bit; // a single register
reg [31:0] word;
// a 32-bit register
reg [31:0] array[15:0]; // 16 32-bit regs
wire [31:0] read_data,write_data;
wire [3:0] index;
// combinational (asynch) read
assign read_data = array[index];
// clocked (synchronous) write
always @(posedge clock)
array[index] <= write_data;
Lecture 7
Lecture 7
FIFOs
WIDTH
WIDTH
din
wr
dout
FIFO
full
reset
rd
empty
1<<LOGSIZE
locations
overflow
clk
// a simple synchronous FIFO (first-in first-out) buffer
// Parameters:
//
LOGSIZE (parameter) FIFO has 1<<LOGSIZE elements
//
WIDTH
(parameter) each element has WIDTH bits
// Ports:
//
clk
(input) all actions triggered on rising edge
//
reset
(input) synchronously empties fifo
//
din
(input, WIDTH bits) data to be stored
//
wr
(input) when asserted, store new data
//
full
(output) asserted when FIFO is full
//
dout
(output, WIDTH bits) data read from FIFO
//
rd
(input) when asserted, removes first element
//
empty
(output) asserted when fifo is empty
//
overflow (output) asserted when WR but no room, cleared on next RD
module fifo #(parameter LOGSIZE = 2,
// default size is 4 elements
WIDTH = 4)
// default width is 4 bits
(input clk,reset,wr,rd, input [WIDTH-1:0] din,
output full,empty,overflow, output [WIDTH-1:0] dout);
endmodule
Lecture 7
FIFOs in action
// make a fifo with 8 8-bit locations
fifo #(.LOGSIZE(3),.WIDTH(8))
f8x8(.clk(clk),.reset(reset),
.wr(wr),.din(din),.full(full),
.rd(rd),.dout(dout),.empty(empty),
.overflow(overflow));
Lecture 7
Lecture 7
LUT-based RAMs
Lecture 7
Lecture 7
=============================================
*
HDL Synthesis
*
=============================================
Synthesizing Unit <lab2_2>.
Related source file is "../lab2_2.v".
...
Lecture 7
10
16K,8K,4K,2K,1K,512
1
2
4
8
16
32
6.111 Fall 2008
Lecture 7
11
BRAM Operation
Data_in
Address
WE
CLK
Data_out
BRAM
Single-port
Config.
Source: Xilinx
App Note 463
Lecture 7
12
BRAM timing
Lecture 7
13
Lecture 7
14
BRAM Example
Lecture 7
15
BRAM Example
Fill in name
(again?!)
Select RAM vs
ROM
Fill in width
& depth
Usually Read After
Write is what you
want
Click Next
6.111 Fall 2008
Lecture 7
16
BRAM Example
Click Next
6.111 Fall 2008
Lecture 7
17
BRAM Example
Select polarity of
control pins; active
high default is
usually just fine
Click Next
6.111 Fall 2008
Lecture 7
18
BRAM Example
Lecture 7
19
Lecture 7
20
endmodule
Use to instantiate instances in your code:
ram64x8 foo(.addr(addr),.clk(clk),.we(we),
.din(din),.dout(dout));
Lecture 7
21
Sequential
Access
Non-Volatile
Read-Write
Memory
Read-Only
Memory
EPROM
E2PROM
FLASH
MaskProgrammed
ROM
FIFO
Lecture 7
22
Register Memory
D
D
Q
Q
D Q
D Q
D Q
D Q
Address
Works fine for small memory blocks (e.g., small register files)
Inefficient in area for large memories
Density is the key metric in large memory circuits
Lecture 7
23
2LxM memory
2L-K
AL-1
Row Decode
AK
AK+1
Bit Line
Storage Cell
Word Line
2L-K row
by
K
Mx2 column
cell array
M*2K
Sense Amps/Driver
A0
AK-1
Column Decode
Amplify swing to
rail-to-rail amplitude
Input-Output
(M bits)
Lecture 7
24
WL
M2
M5
Q
M1
BL
VDD
BL
WL
M4
Q
M6
M3
BL
Lecture 7
25
Memory Matrix
Row Decoder
Address
Pins
Chip Enable
Data
Pins
Read
Logic
Sense Amps/Drivers
Column Decoder
Write enable
Lecture 7
Write enable
Output
Enable
Tri-state Driver
enable
in
out
If enable=0
out = Z
If enable =1
out = in
On the outside:
13
Address
Chip Enables E1
E2
MCM6264C
Write Enable WE
Data
DQ[7:0]
Output Enable OE
DQ[7:0]
E1
E2
Memory matrix
256 rows
32 Column
A2
A3
A4
A5
A7
A8
A9
A11
Row Decoder
On the inside:
W
G
A0
A1
A6
A10
A12
Sense Amps/Drivers
Column Decoder
Pinout
Lecture 7
27
Address Valid
E1
OE
Data
(Tristate)
Data Valid
Read cycle begins when all enable signals (E1, E2, OE) are active
Data is valid after read access time
Lecture 7
28
Address 1
Address 2
Address 3
E1
OE
Data
Bus enable
time
Data
Bus tristate
time Data
Data
1
2
E2 assumed high (enabled), WE =1 (read mode)
Lecture 7
29
Address Valid
E1
WE
Data
Data setup
time
Lecture 7
30
Clock/E1
OE
WE
Address
Data
Drive data bus only when
clock is low
Read cycle
Data read
FPGA
VCC
ext_chip_enable
ext_write_enable
FSM
ext_output_enable
int_data
D
Lecture 7
E2
E1
W
G
SRAM
Data[7:0]
Q D
Data can be
latched
here
ext_data
ext_address
Address[12:0]
31
int_data
Write data
Read data
ext_data
Lecture 7
32
Address
Pins
Write
Logic
Memory
matrix
Data
Pins
Read
Logic
Sense Amps/Drivers
Column Decoder
CE
R2
Output Enable
long flow-through
combinational path creates high
CLK-Q delay
Write Enable
Chip Enable
W3
R4
W5
WE
CLK
Address
Data
6.111 Fall 2008
A1
A2
Q1
A3
Q2
D3
Lecture 7
A4
A5
Q4
D5
33
ZBT (zero bus turnaround) memories change the rules for writes
On a write, data is set up after the clock edge
(so that it is read on the following edge)
Result: no wait states, higher memory throughput
R1
CE
R2
W3
R4
W5
WE
CLK
Address
Data
A1
A2
A3
Q1
Q2
A4
D3
A5
Q4
D5
Lecture 7
34
Good: Greatly reduces CLK-Q delay, allows higher clock (more throughput)
Bad: Introduces an extra cycle before data is available (more latency)
Row Decoder
Address
Pins
ZBT
Write
Logic
Memory
matrix
Write Enable
Chip Enable
Data
Pins
Read
Logic
Sense Amps/Drivers
Column Decoder
As an example, see
the CY7C147X ZBT
Synchronous SRAM
Output Enable
pipelining register
R1
CE
R2
W3
R4
W5
WE
CLK
Address
Data
6.111 Fall 2008
A1
A2
one-cycle
latency...
A3
Q1
A4
Q2
A5
D3
Lecture 7
Q4
D5
EEPROM
20 V
Floating
gate
10 V
5V
0V
20 V
Avalanche injection
5V
[Rabaey03]
0V
Removing programming
voltage leaves charge trapped
Lecture 7
36
Vcc (5V)
Address
Data
Charge
pump
Chip Enable
Output Enable
Write Enable
6.111 Fall 2008
FSM
Lecture 7
Programming
voltage (12V)
EPROM omits
FSM, charge
pump, and
write enable
37
BL
Write "1"
DRAM uses
Special
Capacitor
Structures
Read "1"
WL
M1
CS
GND
VDD
BL
CBL
VDD/2
sensing
[Rabaey03]
VDD /2
Cell Plate Si
Capacitor Insulator
Refilling Poly
Si Substrate
Lecture 7
38
Row
Col
RAS
CAS
Data
WE
(Tristate)
RAS-before-CAS
for a read or write
CAS-before-RAS
for a refresh
Lecture 7
39
Memory Map
0xE000
0xDFFF
0xC000
0xBFFF
0xA000
0x9FFF
0x2000
0x1FFF
0x0000
EPROM
SRAM 2
SRAM 1
~G2B
~G2A
G1
Bus Enable
+5V
Y7
Y6
Y5
Y4
Y3
Y2
Y1
Y0
~E1
Address[12:0]
Data[7:0]
[12:0]
[12:0]
C
B
A
Data[7:0]
ADC
ADC
Lecture 7
~G
~W
~E1
Address[2:0]
Data[7:0]
0xFFFF
15
14
13
138
Address[15:0]
OE
WE
[2:0]
EPROM
~G
~G
~W
~E1
Address[12:0]
Data[7:0]
SRAM 2
[12:0]
SRAM 1
~G
~W
~E1
Address[12:0]
Data[7:0]
Analog
Input
40
Non-Volatile Memory
Fast Read, but very slow write (EPROM must be removed from
the system for programming!)
Holds state even if the power supply is turned off
Memory Internals
Device details
Lecture 7
41
Lecture 7
42