FPGA4U FPGA SDRAM Controller
-- https://fpga4u.epfl.ch/wiki/FPGA4U_Description
-- The SDRAM is an ISSI IS42S32800B. With bits data bus, validated by SDRAM_DQM<..> signals,
-- one for each Byte of data bus SDRAM_DQ<..>.
-- This memory is a synchronous SDRAM, validating address and control signals with the rising edge of SDRAM_CLK,
-- while SDRAM_CKE activated (''). The organisation is banks selected by SDRAM_BA<..>.
-- Each bank as ^ Row and ^ Column selected by SDRAM_AD<11.0>, with bits words
-- (SDRAM_DQ<..> (^ * ^ * ^ = * 2M x = 8Mx32 = 32MBytes).
-- In SOPC Builder, with the SDRAM Controller, select:
-- Banks
-- Rows addresses lines
-- Columns addresses lines library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all; entity fpga4u_sdram_controller is
port(
--Avalon slave interface (pipelined, variable latency)
signal clk, reset : in std_logic;
signal as_address : in std_logic_vector( downto );
signal as_read, as_write : in std_logic;
signal as_byteenable : in std_logic_vector( downto );
signal as_readdata : out std_logic_vector( downto );
signal as_writedata : in std_logic_vector( downto );
signal as_waitrequest : out std_logic;
signal as_readdatavalid : out std_logic; --SDRAM interface to FPGA4U SDRAM
signal ram_addr : out std_logic_vector( downto );
signal ram_ba : out std_logic_vector( downto );
signal ram_cas_n : out std_logic;
signal ram_cke : out std_logic;
signal ram_cs_n : out std_logic;
signal ram_dq : inout std_logic_vector( downto );
signal ram_dqm : out std_logic_vector( downto );
signal ram_ras_n : out std_logic;
signal ram_we_n : out std_logic
);
end entity; architecture arch of fpga4u_sdram_controller is
--Initialisation signals
type init_state_t is (init_reset, init_pre, init_wait_pre, init_ref, init_wait_ref, init_mode, init_wait_mode, init_done);
signal init_state : init_state_t := init_reset;
signal init_wait_counter : unsigned( downto );
signal init_ref_counter : unsigned( downto ); --Main state machine
type state_t is (idle, ref, wait_ref, act, wait_act, read, spin_read, write, spin_write, precharge_all, wait_precharge);
signal state : state_t := idle;
signal ref_counter : unsigned( downto );
signal ref_req : std_logic;
signal wait_counter : unsigned( downto ); --Active transaction signals
signal int_address : std_logic_vector( downto );
signal int_readdata : std_logic_vector( downto );
signal int_writedata : std_logic_vector( downto );
signal int_byteenable : std_logic_vector( downto );
signal int_writeop : std_logic; --open bank and row
signal open_bank : std_logic_vector( downto );
signal open_row : std_logic_vector( downto ); --readdata ready pipeline
signal readdata_ready : std_logic_vector( downto ); signal ram_cmd : std_logic_vector( downto );
begin
--State machine to handle SDRAM initialization
INITSTATE : process(clk, reset)
begin
if reset = '' then
init_state <= init_reset;
--power up delay
init_wait_counter <= to_unsigned(,init_wait_counter'length);
--number refresh cycles before mode register write
init_ref_counter <= to_unsigned(,init_ref_counter'length);
elsif rising_edge(clk) then
--count down when not
if init_wait_counter /= then
init_wait_counter <= init_wait_counter - ;
end if;
case init_state is
when init_reset =>
if init_wait_counter = then
init_state <= init_pre;
end if;
--do a precharge
when init_pre =>
init_wait_counter <= to_unsigned(,init_wait_counter'length);
init_state <= init_wait_pre;
when init_wait_pre =>
if init_wait_counter = then
init_state <= init_ref;
end if;
--do a refresh
when init_ref =>
init_wait_counter <= to_unsigned(,init_wait_counter'length);
init_ref_counter <= init_ref_counter - ;
init_state <= init_wait_ref;
when init_wait_ref =>
if init_wait_counter = then
if init_ref_counter = then
init_state <= init_mode;
else
init_state <= init_ref;
end if;
end if;
--set the mode register
when init_mode =>
init_wait_counter <= to_unsigned(,init_wait_counter'length);
init_state <= init_wait_mode;
when init_wait_mode =>
if init_wait_counter = then
init_state <= init_done;
end if;
when others =>
null;
end case;
end if;
end process; --Asynchronous waitrequest to allow one transfer per cycle (critical path)
as_waitrequest <= '' when (state = idle and ref_req = '' and (as_read = '' or as_write = ''))
or ((state = read or state = spin_read) and ref_req = '' and as_read = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank)
or ((state = write or state = spin_write) and ref_req = '' and as_write = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank)
else ''; --Main state machine
make_state : process(clk, reset)
begin
if reset = '' then
state <= idle;
ref_counter <= (others=>'');
ref_req <= ''; --begin with a refresh
wait_counter <= (others=>'');
readdata_ready <= (others=>'');
elsif rising_edge(clk) then
--counters for delays and refresh generation
if wait_counter /= then
wait_counter <= wait_counter - ;
end if;
if ref_counter /= then
ref_counter <= ref_counter - ;
else
ref_req <= '';
ref_counter <= to_unsigned(,ref_counter'length);
end if;
--main state machine runs when the initialization is done
if init_state = init_done then
case state is
when idle =>
if ref_req = '' then --go do a refresh
ref_req <= '';
state <= ref;
elsif as_write = '' or as_read = '' then --accept the request and go to open the row
int_address <= as_address;
int_writedata <= as_writedata;
int_byteenable <= as_byteenable;
int_writeop <= as_write;
state <= act;
end if;
when ref =>
wait_counter <= to_unsigned(,wait_counter'length);
state <= wait_ref;
when wait_ref =>
if wait_counter = then
state <= idle;
end if;
when act => --save the open bank and row
open_bank <= int_address( downto );
open_row <= int_address( downto );
wait_counter <= to_unsigned(,wait_counter'length);
state <= wait_act;
when wait_act =>
if wait_counter = then
if int_writeop = '' then
state <= read;
else
state <= write;
end if;
end if;
when read => --issue a read command, feed a one in the readdata_ready pipeline, when it exits data is ready for the master
as_readdata <= int_readdata;
as_readdatavalid <= readdata_ready();
readdata_ready <= readdata_ready( downto )&'';
if ref_req = '' and as_read = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank then
int_address <= as_address;
state <= read;
else
state <= spin_read;
end if;
when spin_read => --wait for reads to complete and eventually issue more compatible reads
as_readdata <= int_readdata;
as_readdatavalid <= readdata_ready();
readdata_ready <= readdata_ready( downto )&'';
if readdata_ready = "" and (ref_req = '' or as_write = '') then
state <= precharge_all;
elsif ref_req = '' and as_read = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank then
int_address <= as_address;
state <= read;
elsif readdata_ready = "" and as_read = '' then
state <= precharge_all;
end if;
when write => --the same as read, except there is no pipeline as data is presented to the SDRAM on the same cycle as the command
wait_counter <= to_unsigned(,wait_counter'length);
if ref_req = '' and as_write = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank then
int_address <= as_address;
int_writedata <= as_writedata;
int_byteenable <= as_byteenable;
state <= write;
else
state <= spin_write;
end if;
when spin_write => --same as for read
if wait_counter = and (ref_req = '' or as_read = '') then
state <= precharge_all;
elsif ref_req = '' and as_write = '' and as_address( downto ) = open_row and as_address( downto ) = open_bank then
int_address <= as_address;
int_writedata <= as_writedata;
int_byteenable <= as_byteenable;
state <= write;
elsif wait_counter = and as_write = '' then
state <= precharge_all;
end if;
when precharge_all =>
state <= wait_precharge;
when wait_precharge =>
state <= idle;
when others=>
null;
end case;
end if;
end if;
end process; --data from the ram needs to be sampled on the falling edge of the controller clock for proper operation
process(clk)
begin
if falling_edge(clk) then
int_readdata <= ram_dq;
end if;
end process; --process generating the command sequence for the SDRAM
ram_cke <= '';
ram_cs_n <= ram_cmd();
ram_ras_n <= ram_cmd();
ram_cas_n <= ram_cmd();
ram_we_n <= ram_cmd();
OUTPUTS : process(clk, reset)
begin
if reset = '' then
ram_addr <= (others=>'');
ram_cmd <= "";
ram_ba <= (others=>'');
ram_dq <= (others=>'Z');
ram_dqm <= (others=>'');
elsif rising_edge(clk) then
if init_state = init_pre then
ram_cmd <= ""; --precharge
ram_addr <= (=>'', others=>'');
elsif init_state = init_ref then
ram_cmd <= ""; --refresh
elsif init_state = init_mode then
ram_cmd <= ""; --mode set
ram_addr <= ""; --no burst, three cycles latency
elsif init_state = init_done then
if state = ref then
ram_cmd <= ""; --refresh
elsif state = act then
ram_cmd <= ""; --activate
ram_addr <= int_address( downto );
ram_ba <= int_address( downto );
elsif state = read then
ram_cmd <= ""; --read
ram_addr <= ""&int_address( downto );
ram_dqm <= "";
elsif state = write then
ram_cmd <= ""; --write
ram_addr <= ""&int_address( downto );
ram_dq <= int_writedata;
ram_dqm <= not int_byteenable;
elsif state = precharge_all then
ram_cmd <= ""; --precharge
ram_addr <= ""&int_address( downto );
ram_dqm <= "";
else
ram_cmd <= ""; --nop
ram_dq <= (others=>'Z');
end if;
else
ram_cmd <= ""; --nop
end if;
end if;
end process;
end arch;
FPGA4U FPGA SDRAM Controller的更多相关文章
- 模拟摄像头解码模块最新测试 TVP5150模块 FPGA+SDRAM+TVP5150+VGA 实现PAL AV输入 VGA视频输出
模拟摄像头解码模块最新测试 TVP5150模块 FPGA+SDRAM+TVP5150+VGA 实现PAL AV输入 VGA视频输出 测试使用电视机顶盒的AV模拟信号输入,VGA显示器输出测试,效 ...
- 基于FPGA摄像头图像采集显示系统
本系统主要由FPGA主控模块.图像采集模块.图像存储模块以及图像显示模块等模块组成.其中图像采集模块选择OV7670摄像头模块,完成对视频图像的采集和解码功能,并以RGB565标准输出RGB 5:6: ...
- SDRAM interface slashes pin count
Many designs need deep buffering but don't require ultrahigh-memory bandwidth. Examples include imag ...
- FPGA在电平接口领域的应用
电子技术的发展,产生了各种各样的电平接口. TTL电平: TTL电平信号之所以被广泛使用,原因是因为:通常我们采用二进制来表示数据.而且规定,+5V等价于逻辑"1",0V等价于逻辑 ...
- FPGA DDR3调试
FPGA DDR3调试 Spartan6 FPGA芯片中集成了MCB硬核,它可以支持到DDR3.在Xilinx的开发工具Xilinx ISE中提供了MIG IP核,设计者可以用它来直接生成 DDR3 ...
- Using the SDRAM on Altera’s DE1-SoC Board with Verilog Designs
Using the SDRAM on Altera’sDE1-SoC Board with Verilog Designs 1.DE1-SOC Board上SDRAM资源 2.系统架构框图 3.关于S ...
- DDR SDRAM芯片DQS的作用以及读写DQS/DQ对齐方式不同的原因
节选内容转载自https://www.design-reuse.com/articles/13805/the-love-hate-relationship-with-ddr-sdram-control ...
- 玩转摄像头之 基于SDRAM缓冲 USB2.0视频采集系统 MT9T001、MT9P031 演示 展示
玩转摄像头之 基于SDRAM缓冲 USB视频采集系统 MT9T001.MT9P031 最新设计的系统: 核心板(FPGA+SDRAM)+底板(68013+DVP)+sensor 先看图 核心板 正 ...
- 从FPGA搞定OV7670 VGA显示 移植到 STM32F10x TFT显示 总结及疑问(高手请进)
OV7670不愧是最便宜的摄像头了最大显示像素:640*480(在VGA显示器上显示效果还不赖,用usb模块采集显示依然显著) 第一步:VGA显示 视频图像(实时)FPGA+SDRAM+OV7670= ...
随机推荐
- 問題排查:行動裝置網頁前端 UI 設計 (2)
之前上網找了個星級評分的範例來玩, 當然這個範例已經用在另一個專案了, 目前看起來沒什麼狀況, 不過在移植到目前的專案之後, 就出現了怪現象: 1. 在大部份時間裡,點擊星星不會有任何反應 2. 即便 ...
- AIX 开机启动网络服务配置
aix7 administrator An administrator notices that the ntp group subsystem is not starting up at boot ...
- aix 6+ mount 光驱
AIX 挂载光驱的方法 系统环境: [root@Big A:/1]#oslevel -s6100-06-00-0000 [root@Big A:/]#crfs -v cdrfs -p ro -d '/ ...
- 《深入理解Spark:核心思想与源码分析》一书正式出版上市
自己牺牲了7个月的周末和下班空闲时间,通过研究Spark源码和原理,总结整理的<深入理解Spark:核心思想与源码分析>一书现在已经正式出版上市,目前亚马逊.京东.当当.天猫等网站均有销售 ...
- 【Java学习笔记】Map借口的子接口----HashMap
存储在HashMap集合中的元素,必须覆盖hashCode和equals方法(与HashSet类似) import java.util.HashMap; import java.util.Iter ...
- com.alibaba.fastjson.JSONObject学习
JSONObject json = new JSONObject(); //设置json属性,可以是对象,数值 json.put("key",value); //获取json的普通 ...
- FME规划数据GIS更新入库
规划数据经过转换处理入库GIS,城市规划的特殊性,使得GIS里面数据经过分析处理后直接导出为CAD数据的话,肯定难以满足原来规划的要求,这个是硬伤.又要用GIS来进行空间分析处理统计,数据管理就必须了 ...
- 第45讲:Scala中Context Bounds代码实战及其在Spark中的应用源码解析
今天学业习了上下文界定的内容,看下这段代码 class Pair_Ordering[T:Ordering](val first : T,val second : T){ def bigger(imp ...
- Android:res之layer-list的用法
layer-list可以将多个图片按照顺序层叠起来,让其看起来像一个图一样. 和 叠加为: 用法: 在在drawable下建立一个xml文件,faceleft.xml <?xml ver ...
- signalR制作微信墙 开源
微信墙 上一篇文章中已经用PHP搭建了一个微信墙获取信息的服务器,我这里使用微软的signalr搭建一个客户端,signalr是一个为开发者开发实时应用的 一个库文件,支持windows server ...