1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
library work;
use work.sdram_util.ALL;
entity sdram is
port (
clock_50 : in std_logic;
reset_n : in std_logic;
seven_seg : out std_logic_vector(7 downto 0);
sdram_clk : out std_logic;
sdram_cs_n : out std_logic;
sdram_cas_n : out std_logic;
sdram_ras_n : out std_logic;
sdram_we_n : out std_logic;
sdram_cke : out std_logic;
sdram_addr : out std_logic_vector(12 downto 0);
sdram_ba : out std_logic_vector(1 downto 0);
sdram_dq : inout std_logic_vector(15 downto 0);
sdram_dqm : out std_logic_vector(1 downto 0)
);
end entity;
architecture rtl of sdram is
component pllx2 IS
PORT
(
areset : IN STD_LOGIC := '0';
inclk0 : IN STD_LOGIC := '0';
c0 : OUT STD_LOGIC ;
locked : OUT STD_LOGIC
);
end component;
component sdram_mcu is
port (
clk_clk : in std_logic := 'X'; -- clk
reset_reset_n : in std_logic := 'X'; -- reset_n
pio_0_d_export : out std_logic_vector(7 downto 0); -- export
ebb_0_cs_n : out std_logic; -- cs_n
ebb_0_rd_n : out std_logic; -- rd_n
ebb_0_wr_n : out std_logic; -- wr_n
ebb_0_wait_n : in std_logic := 'X'; -- wait_n
ebb_0_addr : out std_logic_vector(15 downto 0); -- addr
ebb_0_data : inout std_logic_vector(7 downto 0) := (others => 'X') -- data
);
end component sdram_mcu;
entity sdram_ctrl is
port
(
clock_100 : in std_logic;
reset_n : in std_logic;
bus_cs_n : in std_logic;
bus_rnw : in std_logic;
bus_wait_n : out std_logic;
bus_addr : in addr_t;
bus_data_in : in data_t;
bus_data_out : out data_t;
sdram_clk : out std_logic;
sdram_cke : out std_logic;
sdram_cs_n : out std_logic;
sdram_cas_n : out std_logic;
sdram_ras_n : out std_logic;
sdram_we_n : out std_logic;
sdram_addr : out std_logic_vector(12 downto 0);
sdram_ba : out std_logic_vector(1 downto 0);
sdram_dq : inout data_t;
sdram_dqm : out dqm_t
);
end entity;
signal b_addr : addr_t;
signal b_data : data_t;
signal b_cs_n : std_logic;
signal b_rnw : std_logic;
signal b_wait_n : std_logic;
signal pll_reset : std_logic;
signal clock_100 : std_logic;
signal pll_locked : std_logic;
signal global_reset_n : std_logic;
begin
pll: pllx2 port map (
pll_reset,
clock_50,
clock_100,
pll_locked );
u0 : component sdram_mcu port map (
clk_clk => clock_50, -- clk.clk
reset_reset_n => global_reset_n, -- reset.reset_n
pio_0_d_export => seven_seg, -- pio_0_d.export
ebb_0_cs_n => b_cs_n, -- ebb_0.cs_n
ebb_0_rd_n => b_rd_n, -- .rd_n
ebb_0_wr_n => b_wr_n, -- .wr_n
ebb_0_wait_n => b_wait_n, -- .wait_n
ebb_0_addr => b_addr, -- .addr
ebb_0_data => b_data -- .data
);
sdram_ctrl0: sdram_ctrl port map (
clock_100,
global_reset_n,
b_cs_n,
b_rnw,
b_wait_n,
sdram_cke,
b_addr,
b_data_in,
b_data_out,
sdram_clk,
sdram_cke,
sdram_cs_n,
sdram_cas_n,
sdram_ras_n,
sdram_we_n,
sdram_addr,
sdram_ba,
sdram_dq,
sdram_dqm
);
pll_reset <= '0';
global_reset_n <= reset_n and pll_locked;
end architecture;
|