1 |
7 |
parrado |
-- Xiang Li, olivercamel@gmail.com
|
2 |
|
|
-- Last Revised: 2008/06/27
|
3 |
|
|
--
|
4 |
|
|
-- This is an interface for the SDRAM IS42S16160B of DE2-70 Board.
|
5 |
|
|
-- The interface only includes tri-state logic for external pins.
|
6 |
|
|
-- All read/write timing logics are implemented by Memory Controller (MC) Core.
|
7 |
|
|
--
|
8 |
|
|
-- The SDRAM is 64 MBytes.
|
9 |
|
|
-- The SDRAM address is configured as: 0x2000_0000 - 0x23FF_FFFC,
|
10 |
|
|
-- as the Memory Controller is attached to conmax slave 2.
|
11 |
|
|
--
|
12 |
|
|
-- The MC registers in our system could config as following
|
13 |
|
|
-- (Only valid at 50MHz system clk):
|
14 |
|
|
-- CSR 0x2800_0000: 0x1700_0300
|
15 |
|
|
-- POC 0x2800_0004: 0x0000_0002 This is done in mc_defines.v
|
16 |
|
|
-- BA_MASK 0x2800_0008: 0x0000_0020 Only judge addr(26)
|
17 |
|
|
-- CSC0 0x2800_0018: 0x0000_0691 for SDRAM
|
18 |
|
|
-- TMS0 0x2800_001C: 0x0724_0230 for SDRAM
|
19 |
|
|
|
20 |
|
|
library ieee;
|
21 |
|
|
use ieee.std_logic_1164.all;
|
22 |
|
|
|
23 |
|
|
entity sdram_interface_top is
|
24 |
|
|
port(
|
25 |
|
|
-- Memory Controller (MC) Interface
|
26 |
|
|
-- Same signals as MC but inverted in/out (except for mc_clk_i)
|
27 |
|
|
mc_clk_i: in std_logic;
|
28 |
|
|
mc_br_pad_i: out std_logic;
|
29 |
|
|
mc_bg_pad_o: in std_logic;
|
30 |
|
|
mc_ack_pad_i: out std_logic;
|
31 |
|
|
mc_addr_pad_o: in std_logic_vector (23 downto 0);
|
32 |
|
|
mc_data_pad_i: out std_logic_vector (31 downto 0);
|
33 |
|
|
mc_data_pad_o: in std_logic_vector (31 downto 0);
|
34 |
|
|
mc_dp_pad_i: out std_logic_vector (3 downto 0);
|
35 |
|
|
mc_dp_pad_o: in std_logic_vector (3 downto 0);
|
36 |
|
|
mc_doe_pad_doe_o: in std_logic;
|
37 |
|
|
mc_dqm_pad_o: in std_logic_vector (3 downto 0);
|
38 |
|
|
mc_oe_pad_o: in std_logic;
|
39 |
|
|
mc_we_pad_o: in std_logic;
|
40 |
|
|
mc_cas_pad_o: in std_logic;
|
41 |
|
|
mc_ras_pad_o: in std_logic;
|
42 |
|
|
mc_cke_pad_o: in std_logic;
|
43 |
|
|
mc_cs_pad_o: in std_logic_vector (7 downto 0);
|
44 |
|
|
mc_sts_pad_i: out std_logic;
|
45 |
|
|
mc_rp_pad_o: in std_logic;
|
46 |
|
|
mc_vpen_pad_o: in std_logic;
|
47 |
|
|
mc_adsc_pad_o: in std_logic;
|
48 |
|
|
mc_adv_pad_o: in std_logic;
|
49 |
|
|
mc_zz_pad_o: in std_logic;
|
50 |
|
|
mc_coe_pad_coe_o: in std_logic;
|
51 |
|
|
|
52 |
|
|
-- SDRAM chip 1 interface
|
53 |
|
|
dram0_a_o: out std_logic_vector (12 downto 0);
|
54 |
|
|
dram0_d_io: inout std_logic_vector (15 downto 0);
|
55 |
|
|
dram0_ba_o: out std_logic_vector (1 downto 0);
|
56 |
|
|
dram0_ldqm0_o: out std_logic;
|
57 |
|
|
dram0_udqm1_o: out std_logic;
|
58 |
|
|
dram0_ras_n_o: out std_logic;
|
59 |
|
|
dram0_cas_n_o: out std_logic;
|
60 |
|
|
dram0_cke_o: out std_logic;
|
61 |
|
|
dram0_clk_o: out std_logic;
|
62 |
|
|
dram0_we_n_o: out std_logic;
|
63 |
|
|
dram0_cs_n_o: out std_logic;
|
64 |
|
|
|
65 |
|
|
-- SDRAM chip 2 interface
|
66 |
|
|
dram1_a_o: out std_logic_vector (12 downto 0);
|
67 |
|
|
dram1_d_io: inout std_logic_vector (15 downto 0);
|
68 |
|
|
dram1_ba_o: out std_logic_vector (1 downto 0);
|
69 |
|
|
dram1_ldqm0_o: out std_logic;
|
70 |
|
|
dram1_udqm1_o: out std_logic;
|
71 |
|
|
dram1_ras_n_o: out std_logic;
|
72 |
|
|
dram1_cas_n_o: out std_logic;
|
73 |
|
|
dram1_cke_o: out std_logic;
|
74 |
|
|
dram1_clk_o: out std_logic;
|
75 |
|
|
dram1_we_n_o: out std_logic;
|
76 |
|
|
dram1_cs_n_o: out std_logic
|
77 |
|
|
);
|
78 |
|
|
end sdram_interface_top;
|
79 |
|
|
|
80 |
|
|
architecture behave of sdram_interface_top is
|
81 |
|
|
|
82 |
|
|
begin
|
83 |
|
|
|
84 |
|
|
-- take care of unused output signals
|
85 |
|
|
mc_br_pad_i <= '0';
|
86 |
|
|
mc_ack_pad_i <= '0';
|
87 |
|
|
mc_sts_pad_i <= '0';
|
88 |
|
|
mc_dp_pad_i <= (others => '0');
|
89 |
|
|
|
90 |
|
|
-- the following signals are not in use in our system
|
91 |
|
|
--mc_bg_pad_o: in std_logic;
|
92 |
|
|
--mc_rp_pad_o: in std_logic;
|
93 |
|
|
--mc_vpen_pad_o: in std_logic;
|
94 |
|
|
--mc_zz_pad_o: in std_logic;
|
95 |
|
|
--mc_cs_pad_o: in std_logic_vector (7 downto 1);
|
96 |
|
|
--mc_adsc_pad_o: in std_logic;
|
97 |
|
|
--mc_adv_pad_o: in std_logic;
|
98 |
|
|
--mc_dp_pad_o: in std_logic_vector (3 downto 0);
|
99 |
|
|
--mc_oe_pad_o: in std_logic;
|
100 |
|
|
|
101 |
|
|
-- clk output for sdram chip,
|
102 |
|
|
-- this should be exactly a half of system clock frequency
|
103 |
|
|
dram0_clk_o <= mc_clk_i;
|
104 |
|
|
dram1_clk_o <= mc_clk_i;
|
105 |
|
|
|
106 |
|
|
-- SDRAM control signals with tri-state
|
107 |
|
|
dram0_a_o <= mc_addr_pad_o (12 downto 0) when mc_coe_pad_coe_o = '1' else (others => 'Z');
|
108 |
|
|
dram0_ba_o <= mc_addr_pad_o (14 downto 13) when mc_coe_pad_coe_o = '1' else (others => 'Z');
|
109 |
|
|
dram0_ldqm0_o <= mc_dqm_pad_o (0) when mc_coe_pad_coe_o = '1' else 'Z';
|
110 |
|
|
dram0_udqm1_o <= mc_dqm_pad_o (1) when mc_coe_pad_coe_o = '1' else 'Z';
|
111 |
|
|
dram0_ras_n_o <= mc_ras_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
112 |
|
|
dram0_cas_n_o <= mc_cas_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
113 |
|
|
dram0_cke_o <= mc_cke_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
114 |
|
|
dram0_we_n_o <= mc_we_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
115 |
|
|
dram0_cs_n_o <= mc_cs_pad_o (0) when mc_coe_pad_coe_o = '1' else 'Z';
|
116 |
|
|
dram1_a_o <= mc_addr_pad_o (12 downto 0) when mc_coe_pad_coe_o = '1' else (others => 'Z');
|
117 |
|
|
dram1_ba_o <= mc_addr_pad_o (14 downto 13) when mc_coe_pad_coe_o = '1' else (others => 'Z');
|
118 |
|
|
dram1_ldqm0_o <= mc_dqm_pad_o (2) when mc_coe_pad_coe_o = '1' else 'Z';
|
119 |
|
|
dram1_udqm1_o <= mc_dqm_pad_o (3) when mc_coe_pad_coe_o = '1' else 'Z';
|
120 |
|
|
dram1_ras_n_o <= mc_ras_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
121 |
|
|
dram1_cas_n_o <= mc_cas_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
122 |
|
|
dram1_cke_o <= mc_cke_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
123 |
|
|
dram1_we_n_o <= mc_we_pad_o when mc_coe_pad_coe_o = '1' else 'Z';
|
124 |
|
|
dram1_cs_n_o <= mc_cs_pad_o (0) when mc_coe_pad_coe_o = '1' else 'Z';
|
125 |
|
|
|
126 |
|
|
-- SDRAM data with tri-state
|
127 |
|
|
dram0_d_io <= mc_data_pad_o (15 downto 0) when mc_doe_pad_doe_o = '1' else (others => 'Z');
|
128 |
|
|
dram1_d_io <= mc_data_pad_o (31 downto 16) when mc_doe_pad_doe_o = '1' else (others => 'Z');
|
129 |
|
|
|
130 |
|
|
-- tri-state input
|
131 |
|
|
mc_data_pad_i (15 downto 0) <= dram0_d_io;
|
132 |
|
|
mc_data_pad_i (31 downto 16) <= dram1_d_io;
|
133 |
|
|
|
134 |
|
|
end behave;
|