1
|
--- Title: EMIFA_ifaceMC.vhd
|
2
|
--- Description:
|
3
|
---
|
4
|
--- EMIFA interface for OMAP-L138 series CPU platform MODIFIED BY MICHELE CANEPA
|
5
|
|
6
|
--- Date: 18/04/2013
|
7
|
--- Version: 1.00
|
8
|
--- Revisions:
|
9
|
--- 1.00 - Baseline.
|
10
|
|
11
|
library WORK;
|
12
|
library IEEE;
|
13
|
library UNISIM;
|
14
|
use IEEE.STD_LOGIC_1164.ALL;
|
15
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
16
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
17
|
use UNISIM.VCOMPONENTS.ALL;
|
18
|
use WORK.MityDSP_L138_pkg.ALL;
|
19
|
|
20
|
entity EMIFA_ifaceMC is
|
21
|
generic (
|
22
|
DECODE_BITS : integer range 1 to 9 := 5;
|
23
|
DECODE_BITS4 : integer range 1 to 5 := 5; -- Custom decode bits. Address space is CS4
|
24
|
. CONFIG : string := "UNKNOWN" -- "MityDSP_L138"
|
25
|
);
|
26
|
port (
|
27
|
ema_clk : in std_logic; -- conditioned by a DCM
|
28
|
|
29
|
-- EMIFA direct-connect signals
|
30
|
i_ema_cs0_n : in std_logic; -- Reserved for SDRAM controller, not used
|
31
|
i_ema_cs2_n : in std_logic; -- Reserved core space, not used
|
32
|
i_ema_cs3_n : in std_logic; -- NAND FLASH space, not used
|
33
|
i_ema_cs4_n : in std_logic; -- Any CPU core space
|
34
|
i_ema_cs5_n : in std_logic; -- Any CPU core space
|
35
|
i_ema_oe_n : in std_logic;
|
36
|
i_ema_we_n : in std_logic;
|
37
|
o_ema_wait_n : out std_logic_vector(1 downto 0);
|
38
|
t_ema_wait : out std_logic;
|
39
|
i_ema_d : in std_logic_vector(15 downto 0);
|
40
|
o_ema_d : out std_logic_vector(15 downto 0);
|
41
|
t_ema_d : out std_logic;
|
42
|
i_ema_a : in std_logic_vector(13 downto 0);
|
43
|
i_ema_ba : in std_logic_vector(1 downto 0);
|
44
|
i_ema_wen_dqm : in std_logic_vector(1 downto 0);
|
45
|
i_ema_cas : in std_logic; -- reserved for SDRAM controller, not used
|
46
|
i_ema_ras : in std_logic; -- reserved for SDRAM controller, not used
|
47
|
i_ema_sdcke : in std_logic; -- reserved for SDRAM controller, not used
|
48
|
i_ema_rnw : in std_logic; -- reserved for SDRAM controller, not used
|
49
|
|
50
|
-- FPGA core interface signals
|
51
|
o_core_be : out std_logic_vector(1 downto 0);
|
52
|
o_core_addr : out std_logic_vector(5 downto 0);
|
53
|
o_core_addr4 : out std_logic_vector(9 downto 0);--Added to give 10 bits addressing.
|
54
|
|
55
|
o_core_cs5 : out std_logic_vector((2**DECODE_BITS)-1 downto 0);
|
56
|
o_core_cs4 : out std_logic_vector((2**DECODE_BITS4)-1 downto 0);-- Decode bits are custom.
|
57
|
o_core_edi : out std_logic_vector(15 downto 0);
|
58
|
i_core_edo5 : in bus16_vector((2**DECODE_BITS)-1 downto 0);
|
59
|
i_core_edo4 : in bus16_vector((2**DECODE_BITS)-1 downto 0);
|
60
|
o_core_rd : out std_logic;
|
61
|
o_core_wr : out std_logic
|
62
|
);
|
63
|
end EMIFA_ifaceMC;
|
64
|
|
65
|
architecture rtl of EMIFA_ifaceMC is
|
66
|
|
67
|
signal be : std_logic_vector(1 downto 0) := (others=>'1');
|
68
|
signal ea : std_logic_vector(14 downto 0) := (others=>'0');
|
69
|
signal cs5_n : std_logic := '1';
|
70
|
signal cs4_n : std_logic := '1';
|
71
|
signal oe_n : std_logic := '1';
|
72
|
signal we_n : std_logic := '1';
|
73
|
signal oe_dly : std_logic := '1';
|
74
|
signal we_dly : std_logic := '1';
|
75
|
signal edi : std_logic_vector(15 downto 0);
|
76
|
|
77
|
-- Caution! Despite disabling shift-register extraction on these signals,
|
78
|
-- setting Global Optimization in Map can still optimize them back into SRL's.
|
79
|
attribute shreg_extract : string;
|
80
|
attribute shreg_extract of be : signal is "no";
|
81
|
attribute shreg_extract of ea : signal is "no";
|
82
|
attribute shreg_extract of edi : signal is "no";
|
83
|
|
84
|
signal cs5 : std_logic_vector((2**DECODE_BITS)-1 downto 0) := (others=>'0');
|
85
|
signal cs4 : std_logic_vector((2**DECODE_BITS4)-1 downto 0) := (others=>'0');-- Modified decode bits
|
86
|
signal rd : std_logic := '0';
|
87
|
signal wr : std_logic := '0';
|
88
|
|
89
|
signal ema_d : std_logic_vector(15 downto 0) := (others=>'0');
|
90
|
attribute shreg_extract of ema_d : signal is "no";
|
91
|
|
92
|
begin -- architecture: rtl
|
93
|
|
94
|
-- register input signals
|
95
|
process (ema_clk)
|
96
|
begin
|
97
|
if rising_edge(ema_clk) then
|
98
|
-- capture byte-enables and address bus
|
99
|
be <= i_ema_wen_dqm;
|
100
|
ea <= i_ema_a & i_ema_ba(1);
|
101
|
-- capture control signals
|
102
|
cs5_n <= i_ema_cs5_n; -- These control signals are NOT inverted here
|
103
|
cs4_n <= i_ema_cs4_n; -- so that the registers can be packed into IOB's.
|
104
|
oe_n <= i_ema_oe_n;
|
105
|
we_n <= i_ema_we_n;
|
106
|
-- one-clock delayed registers
|
107
|
oe_dly <= oe_n;
|
108
|
we_dly <= we_n;
|
109
|
-- capture the data bus
|
110
|
edi <= i_ema_d;
|
111
|
end if;
|
112
|
end process;
|
113
|
|
114
|
-- address decode, ARM chip select space
|
115
|
process (cs5_n, ea)
|
116
|
begin
|
117
|
if cs5_n='0' then
|
118
|
for count in 0 to (2**DECODE_BITS)-1 loop
|
119
|
if ea(DECODE_BITS+5 downto 6) = conv_std_logic_vector(count, DECODE_BITS) then
|
120
|
cs5(count) <= '1';
|
121
|
else
|
122
|
cs5(count) <= '0';
|
123
|
end if;
|
124
|
end loop;
|
125
|
else
|
126
|
cs5 <= (others=>'0');
|
127
|
end if;
|
128
|
end process;
|
129
|
|
130
|
-- address decode, DSP chip select space, modified to be 1024 addresses per module.
|
131
|
process (cs4_n, ea)
|
132
|
begin
|
133
|
if cs4_n='0' then
|
134
|
for count in 0 to (2**DECODE_BITS4)-1 loop
|
135
|
if ea(DECODE_BITS4 +9 downto 10) = conv_std_logic_vector(count, DECODE_BITS4) then
|
136
|
cs4(count) <= '1';
|
137
|
else
|
138
|
cs4(count) <= '0';
|
139
|
end if;
|
140
|
end loop;
|
141
|
else
|
142
|
cs4 <= (others=>'0');
|
143
|
end if;
|
144
|
end process;
|
145
|
|
146
|
-- read/write strobes
|
147
|
rd <= oe_n and not oe_dly;
|
148
|
wr <= not we_n and we_dly;
|
149
|
|
150
|
-- register output signals
|
151
|
process (ema_clk)
|
152
|
begin
|
153
|
if rising_edge(ema_clk) then
|
154
|
o_core_be <= not be; -- invert to positive logic
|
155
|
o_core_addr <= ea(5 downto 0);
|
156
|
o_core_addr4<= ea(9 downto 0); --Modified to 10 bit.
|
157
|
o_core_cs5 <= cs5;
|
158
|
o_core_cs4 <= cs4;
|
159
|
o_core_rd <= rd;
|
160
|
o_core_wr <= wr;
|
161
|
o_core_edi <= edi;
|
162
|
end if;
|
163
|
end process;
|
164
|
|
165
|
-- multiplex module data-out busses
|
166
|
process (ema_clk)
|
167
|
variable ored : std_logic_vector(15 downto 0);
|
168
|
begin
|
169
|
if rising_edge(ema_clk) then
|
170
|
ored := x"0000";
|
171
|
|
172
|
for count in 0 to (2**DECODE_BITS)-1 loop
|
173
|
ored := ored or i_core_edo5(count) or i_core_edo4(count);
|
174
|
end loop;
|
175
|
|
176
|
ema_d <= ored; -- TODO - mux in other "custom" CS spaces???
|
177
|
o_ema_d <= ema_d; -- extra clock should allow packing in IOB
|
178
|
end if;
|
179
|
end process;
|
180
|
|
181
|
t_ema_d <= '0' when (i_ema_oe_n='0' and (i_ema_cs5_n='0' or i_ema_cs4_n='0')) else '1';
|
182
|
t_ema_wait <= '1';
|
183
|
|
184
|
end rtl;
|