1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-----------------------------------------------------------------------------
|
19 |
|
|
-- Entity: ddr_phy
|
20 |
|
|
-- File: ddr_phy.vhd
|
21 |
|
|
-- Author: Jiri Gaisler, Gaisler Research
|
22 |
|
|
-- Description: DDR1 PHY for Altera, Virtex-2, Virtex-4, Spartan-3e
|
23 |
|
|
-- DDR2 PHY for Virtex-5
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
library ieee;
|
27 |
|
|
use ieee.std_logic_1164.all;
|
28 |
|
|
|
29 |
|
|
library grlib;
|
30 |
|
|
use grlib.stdlib.all;
|
31 |
|
|
library techmap;
|
32 |
|
|
use techmap.gencomp.all;
|
33 |
|
|
library gaisler;
|
34 |
|
|
use gaisler.memctrl.all;
|
35 |
|
|
|
36 |
|
|
------------------------------------------------------------------
|
37 |
|
|
-- DDR1 PHY -------------------------------------------------------
|
38 |
|
|
------------------------------------------------------------------
|
39 |
|
|
|
40 |
|
|
entity ddr_phy is
|
41 |
|
|
generic (tech : integer := virtex2; MHz : integer := 100;
|
42 |
|
|
rstdelay : integer := 200; dbits : integer := 16;
|
43 |
|
|
clk_mul : integer := 2 ; clk_div : integer := 2;
|
44 |
|
|
rskew : integer :=0; mobile : integer := 0);
|
45 |
|
|
port (
|
46 |
|
|
rst : in std_ulogic;
|
47 |
|
|
clk : in std_logic; -- input clock
|
48 |
|
|
clkout : out std_ulogic; -- system clock
|
49 |
|
|
clkread : out std_ulogic; -- read clock
|
50 |
|
|
lock : out std_ulogic; -- DCM locked
|
51 |
|
|
|
52 |
|
|
ddr_clk : out std_logic_vector(2 downto 0);
|
53 |
|
|
ddr_clkb : out std_logic_vector(2 downto 0);
|
54 |
|
|
ddr_clk_fb_out : out std_logic;
|
55 |
|
|
ddr_clk_fb : in std_logic;
|
56 |
|
|
ddr_cke : out std_logic_vector(1 downto 0);
|
57 |
|
|
ddr_csb : out std_logic_vector(1 downto 0);
|
58 |
|
|
ddr_web : out std_ulogic; -- ddr write enable
|
59 |
|
|
ddr_rasb : out std_ulogic; -- ddr ras
|
60 |
|
|
ddr_casb : out std_ulogic; -- ddr cas
|
61 |
|
|
ddr_dm : out std_logic_vector (dbits/8-1 downto 0); -- ddr dm
|
62 |
|
|
ddr_dqs : inout std_logic_vector (dbits/8-1 downto 0); -- ddr dqs
|
63 |
|
|
ddr_ad : out std_logic_vector (13 downto 0); -- ddr address
|
64 |
|
|
ddr_ba : out std_logic_vector (1 downto 0); -- ddr bank address
|
65 |
|
|
ddr_dq : inout std_logic_vector (dbits-1 downto 0); -- ddr data
|
66 |
|
|
|
67 |
|
|
sdi : out sdctrl_in_type;
|
68 |
|
|
sdo : in sdctrl_out_type);
|
69 |
|
|
end;
|
70 |
|
|
|
71 |
|
|
architecture rtl of ddr_phy is
|
72 |
|
|
|
73 |
|
|
begin
|
74 |
|
|
|
75 |
|
|
ddr_phy0 : ddrphy
|
76 |
|
|
generic map (tech => tech, MHz => MHz, rstdelay => rstdelay
|
77 |
|
|
-- reduce 200 us start-up delay during simulation
|
78 |
|
|
-- pragma translate_off
|
79 |
|
|
/ 200
|
80 |
|
|
-- pragma translate_on
|
81 |
|
|
, dbits => dbits, clk_mul => clk_mul, clk_div => clk_div,
|
82 |
|
|
rskew => rskew, mobile => mobile)
|
83 |
|
|
port map (
|
84 |
|
|
rst, clk, clkout, clkread, lock,
|
85 |
|
|
ddr_clk, ddr_clkb, ddr_clk_fb_out, ddr_clk_fb,
|
86 |
|
|
ddr_cke, ddr_csb, ddr_web, ddr_rasb, ddr_casb,
|
87 |
|
|
ddr_dm, ddr_dqs, ddr_ad, ddr_ba, ddr_dq,
|
88 |
|
|
sdo.address(15 downto 2), sdo.ba,
|
89 |
|
|
sdi.data(dbits*2-1 downto 0), sdo.data(dbits*2-1 downto 0),
|
90 |
|
|
sdo.dqm(dbits/4-1 downto 0), sdo.bdrive, sdo.bdrive, sdo.qdrive,
|
91 |
|
|
sdo.rasn, sdo.casn, sdo.sdwen, sdo.sdcsn, sdo.sdcke, sdo.sdck, sdo.moben);
|
92 |
|
|
|
93 |
|
|
end;
|
94 |
|
|
|
95 |
|
|
library ieee;
|
96 |
|
|
use ieee.std_logic_1164.all;
|
97 |
|
|
|
98 |
|
|
library grlib;
|
99 |
|
|
use grlib.stdlib.all;
|
100 |
|
|
library techmap;
|
101 |
|
|
use techmap.gencomp.all;
|
102 |
|
|
library gaisler;
|
103 |
|
|
use gaisler.memctrl.all;
|
104 |
|
|
|
105 |
|
|
------------------------------------------------------------------
|
106 |
|
|
-- DDR2 PHY -------------------------------------------------------
|
107 |
|
|
------------------------------------------------------------------
|
108 |
|
|
|
109 |
|
|
entity ddr2_phy is
|
110 |
|
|
generic (tech : integer := virtex2; MHz : integer := 100;
|
111 |
|
|
rstdelay : integer := 200; dbits : integer := 16;
|
112 |
|
|
clk_mul : integer := 2 ; clk_div : integer := 2;
|
113 |
|
|
ddelayb0 : integer := 0; ddelayb1 : integer := 0; ddelayb2 : integer := 0;
|
114 |
|
|
ddelayb3 : integer := 0; ddelayb4 : integer := 0; ddelayb5 : integer := 0;
|
115 |
|
|
ddelayb6 : integer := 0; ddelayb7 : integer := 0;
|
116 |
|
|
numidelctrl : integer := 4; norefclk : integer := 0; odten : integer := 0;
|
117 |
|
|
rskew : integer := 0);
|
118 |
|
|
port (
|
119 |
|
|
rst : in std_ulogic;
|
120 |
|
|
clk : in std_logic; -- input clock
|
121 |
|
|
clkref200 : in std_logic; -- input 200MHz clock
|
122 |
|
|
clkout : out std_ulogic; -- system clock
|
123 |
|
|
lock : out std_ulogic; -- DCM locked
|
124 |
|
|
|
125 |
|
|
ddr_clk : out std_logic_vector(2 downto 0);
|
126 |
|
|
ddr_clkb : out std_logic_vector(2 downto 0);
|
127 |
|
|
ddr_clk_fb_out : out std_logic;
|
128 |
|
|
ddr_clk_fb : in std_logic;
|
129 |
|
|
ddr_cke : out std_logic_vector(1 downto 0);
|
130 |
|
|
ddr_csb : out std_logic_vector(1 downto 0);
|
131 |
|
|
ddr_web : out std_ulogic; -- ddr write enable
|
132 |
|
|
ddr_rasb : out std_ulogic; -- ddr ras
|
133 |
|
|
ddr_casb : out std_ulogic; -- ddr cas
|
134 |
|
|
ddr_dm : out std_logic_vector (dbits/8-1 downto 0); -- ddr dm
|
135 |
|
|
ddr_dqs : inout std_logic_vector (dbits/8-1 downto 0); -- ddr dqs
|
136 |
|
|
ddr_dqsn : inout std_logic_vector (dbits/8-1 downto 0); -- ddr dqs
|
137 |
|
|
ddr_ad : out std_logic_vector (13 downto 0); -- ddr address
|
138 |
|
|
ddr_ba : out std_logic_vector (1 downto 0); -- ddr bank address
|
139 |
|
|
ddr_dq : inout std_logic_vector (dbits-1 downto 0); -- ddr data
|
140 |
|
|
ddr_odt : out std_logic_vector(1 downto 0);
|
141 |
|
|
|
142 |
|
|
sdi : out sdctrl_in_type;
|
143 |
|
|
sdo : in sdctrl_out_type
|
144 |
|
|
);
|
145 |
|
|
end;
|
146 |
|
|
|
147 |
|
|
architecture rtl of ddr2_phy is
|
148 |
|
|
|
149 |
|
|
begin
|
150 |
|
|
|
151 |
|
|
ddr_phy0 : ddr2phy
|
152 |
|
|
generic map (tech => tech, MHz => MHz, rstdelay => rstdelay
|
153 |
|
|
-- reduce 200 us start-up delay during simulation
|
154 |
|
|
-- pragma translate_off
|
155 |
|
|
/ 200
|
156 |
|
|
-- pragma translate_on
|
157 |
|
|
, dbits => dbits, clk_mul => clk_mul, clk_div => clk_div,
|
158 |
|
|
ddelayb0 => ddelayb0, ddelayb1 => ddelayb1, ddelayb2 => ddelayb2,
|
159 |
|
|
ddelayb3 => ddelayb3, ddelayb4 => ddelayb4, ddelayb5 => ddelayb5,
|
160 |
|
|
ddelayb6 => ddelayb6, ddelayb7 => ddelayb7,
|
161 |
|
|
numidelctrl => numidelctrl, norefclk => norefclk, rskew => rskew)
|
162 |
|
|
port map (
|
163 |
|
|
rst, clk, clkref200, clkout, lock,
|
164 |
|
|
ddr_clk, ddr_clkb, ddr_clk_fb_out, ddr_clk_fb,
|
165 |
|
|
ddr_cke, ddr_csb, ddr_web, ddr_rasb, ddr_casb,
|
166 |
|
|
ddr_dm, ddr_dqs, ddr_dqsn, ddr_ad, ddr_ba, ddr_dq, ddr_odt,
|
167 |
|
|
sdo.address(15 downto 2), sdo.ba,
|
168 |
|
|
sdi.data(dbits*2-1 downto 0), sdo.data(dbits*2-1 downto 0),
|
169 |
|
|
sdo.dqm(dbits/4-1 downto 0), sdo.bdrive, sdo.bdrive, sdo.qdrive,
|
170 |
|
|
sdo.rasn, sdo.casn, sdo.sdwen, sdo.sdcsn, sdo.sdcke,
|
171 |
|
|
sdo.cal_en(dbits/8-1 downto 0), sdo.cal_inc(dbits/8-1 downto 0),
|
172 |
|
|
sdo.cal_pll, sdo.cal_rst, sdo.odt
|
173 |
|
|
);
|
174 |
|
|
end;
|
175 |
|
|
|