1
|
--- GPIO Test Core
|
2
|
---
|
3
|
--- Top Level Test Code
|
4
|
---
|
5
|
--- conor.orourke@scorpionnetworks.com
|
6
|
--- 15 October 2012
|
7
|
---
|
8
|
|
9
|
|
10
|
-- Library Declarations
|
11
|
|
12
|
library WORK;
|
13
|
library IEEE;
|
14
|
library UNISIM;
|
15
|
|
16
|
use IEEE.std_logic_1164.all; -- basic IEEE library
|
17
|
use IEEE.numeric_std.all; -- IEEE library for the unsigned type and arith
|
18
|
|
19
|
use UNISIM.VCOMPONENTS.ALL;
|
20
|
|
21
|
use WORK.MityDSP_L138_pkg.ALL;
|
22
|
|
23
|
|
24
|
-- Entity
|
25
|
|
26
|
entity Gpio_Test_Top is
|
27
|
|
28
|
generic (
|
29
|
BOARD_REV : string := "C";
|
30
|
DECODE_BITS : integer range 1 to 9 := 5
|
31
|
);
|
32
|
|
33
|
port (
|
34
|
i_ema_clk : in std_logic; -- 100 MHz EMIF clock
|
35
|
|
36
|
-- DSP EMIFA BUS Interface
|
37
|
i_ema_cs0_n : in std_logic; -- RESERVED for SDRAM Controller
|
38
|
i_ema_cs2_n : in std_logic; -- ARM core CE space
|
39
|
i_ema_cs3_n : in std_logic; -- NAND FLASH space, not used
|
40
|
i_ema_cs4_n : in std_logic; -- DSP core CE space
|
41
|
i_ema_cs5_n : in std_logic; -- Reserved core space, not used
|
42
|
i_ema_oe_n : in std_logic;
|
43
|
i_ema_we_n : in std_logic;
|
44
|
io_ema_wait_n : inout std_logic_vector(1 downto 0);
|
45
|
io_ema_d : inout std_logic_vector(15 downto 0);
|
46
|
i_ema_a : in std_logic_vector(13 downto 0);
|
47
|
i_ema_ba : in std_logic_vector(1 downto 0);
|
48
|
i_ema_wen_dqm : in std_logic_vector(1 downto 0);
|
49
|
i_ema_cas : in std_logic; -- reserved for SDRAM controller, not used
|
50
|
i_ema_ras : in std_logic; -- reserved for SDRAM controller, not used
|
51
|
i_ema_sdcke : in std_logic; -- reserved for SDRAM controller, not used
|
52
|
i_ema_rnw : in std_logic; -- reserved for SDRAM controller, not used
|
53
|
|
54
|
-- DSP IRQ lines
|
55
|
o_int : out std_logic_vector(1 downto 0);
|
56
|
o_nmi_n : out std_logic;
|
57
|
|
58
|
-- GPIO Test Lines
|
59
|
io_j702_3_gpio : inout std_logic;
|
60
|
io_j702_4_gpio : inout std_logic
|
61
|
);
|
62
|
|
63
|
end Gpio_Test_Top;
|
64
|
|
65
|
|
66
|
-- Architecture
|
67
|
|
68
|
architecture gpio_arch of Gpio_Test_Top is
|
69
|
|
70
|
-- Constants --
|
71
|
|
72
|
constant FPGA_APPLICATION_ID : std_logic_vector(7 downto 0) := "00000000";
|
73
|
constant FPGA_VERSION_MAJOR : std_logic_vector(3 downto 0) := "0001";
|
74
|
constant FPGA_VERSION_MINOR : std_logic_vector(3 downto 0) := "0000";
|
75
|
constant FPGA_YEAR : std_logic_vector(4 downto 0) := "01010";
|
76
|
constant FPGA_MONTH : std_logic_vector(3 downto 0) := "0010";
|
77
|
constant FPGA_DAY : std_logic_vector(4 downto 0) := "10100";
|
78
|
|
79
|
-- CPU Mapping: ARM is INT0
|
80
|
-- DSP is INT1
|
81
|
|
82
|
constant CORE_BASE_MODULE : integer := 0;
|
83
|
constant CORE_GPIO_MODULE : integer := 5;
|
84
|
|
85
|
constant CORE_GPIO_IRQ_LEVEL : integer := 0;
|
86
|
constant CORE_GPIO_IRQ_VECTOR : integer := 0;
|
87
|
|
88
|
-- Clock Signals --
|
89
|
|
90
|
signal Ema_clk : std_logic;
|
91
|
|
92
|
-- EMIFA Signals
|
93
|
|
94
|
signal Ema_d : std_logic_vector(15 downto 0);
|
95
|
signal Ema_wait_n : std_logic_vector(1 downto 0) := "11";
|
96
|
signal T_ema_wait : std_logic;
|
97
|
signal T_ema_d : std_logic;
|
98
|
|
99
|
signal Irq_map : bus16_vector(1 downto 0) := (others=>(others=>'0'));
|
100
|
|
101
|
-- Core Logic signals
|
102
|
|
103
|
signal Be_r : std_logic_vector(1 downto 0);
|
104
|
signal Addr_r : std_logic_vector(5 downto 0);
|
105
|
signal Arm_cs5_r : std_logic_vector((2**DECODE_BITS)-1 downto 0);
|
106
|
signal Dsp_cs4_r : std_logic_vector((2**DECODE_BITS)-1 downto 0);
|
107
|
signal Edi_r : std_logic_vector(15 downto 0);
|
108
|
signal Edo_arm : bus16_vector((2**DECODE_BITS)-1 downto 0);
|
109
|
signal Edo_dsp : bus16_vector((2**DECODE_BITS)-1 downto 0);
|
110
|
signal Rd_r : std_logic;
|
111
|
signal Wr_r : std_logic;
|
112
|
|
113
|
|
114
|
begin
|
115
|
|
116
|
---------------
|
117
|
-- PORT MAPS --
|
118
|
---------------
|
119
|
|
120
|
-- Route i_ema_clk via Global Net (Xilinx specific) to EMA_CLK
|
121
|
|
122
|
emaclk_inst : BUFG
|
123
|
port map (O => Ema_clk,
|
124
|
I => i_ema_clk);
|
125
|
|
126
|
|
127
|
-----------------
|
128
|
-- EMIF_Iface --
|
129
|
----------------
|
130
|
|
131
|
emifa_iface_inst : EMIFA_iface
|
132
|
generic map (
|
133
|
DECODE_BITS => DECODE_BITS,
|
134
|
CONFIG => "MityDSP_L138"
|
135
|
)
|
136
|
port map (
|
137
|
ema_clk => Ema_clk,
|
138
|
i_ema_cs0_n => i_ema_cs0_n,
|
139
|
i_ema_cs2_n => i_ema_cs2_n,
|
140
|
i_ema_cs3_n => i_ema_cs3_n,
|
141
|
i_ema_cs4_n => i_ema_cs4_n,
|
142
|
i_ema_cs5_n => i_ema_cs5_n,
|
143
|
i_ema_oe_n => i_ema_oe_n,
|
144
|
i_ema_we_n => i_ema_we_n,
|
145
|
o_ema_wait_n => Ema_wait_n,
|
146
|
|
147
|
t_ema_wait => T_ema_wait,
|
148
|
i_ema_d => io_ema_d,
|
149
|
o_ema_d => Ema_d,
|
150
|
t_ema_d => T_ema_d,
|
151
|
|
152
|
i_ema_a => i_ema_a,
|
153
|
i_ema_ba => i_ema_ba,
|
154
|
i_ema_wen_dqm => i_ema_wen_dqm,
|
155
|
i_ema_cas => i_ema_cas,
|
156
|
i_ema_ras => i_ema_ras,
|
157
|
i_ema_sdcke => i_ema_sdcke,
|
158
|
i_ema_rnw => i_ema_rnw,
|
159
|
|
160
|
-- Internal Core Bus Signals
|
161
|
|
162
|
o_core_be => Be_r,
|
163
|
o_core_addr => Addr_r,
|
164
|
o_core_cs5 => Arm_cs5_r,
|
165
|
o_core_cs4 => Dsp_cs4_r,
|
166
|
o_core_edi => Edi_r,
|
167
|
i_core_edo5 => Edo_arm,
|
168
|
i_core_edo4 => Edo_dsp,
|
169
|
o_core_rd => Rd_r,
|
170
|
o_core_wr => Wr_r
|
171
|
);
|
172
|
-- end emififace_inst
|
173
|
|
174
|
-- Port Assignments for EMIFA:
|
175
|
|
176
|
o_nmi_n <= '1';
|
177
|
|
178
|
io_ema_d <= Ema_d when T_ema_d = '0' else (others=>'Z');
|
179
|
|
180
|
io_ema_wait_n <= Ema_wait_n when T_ema_wait = '0' else (others=>'Z');
|
181
|
|
182
|
|
183
|
-----------------
|
184
|
-- Base Module --
|
185
|
-----------------
|
186
|
|
187
|
base_core_inst : base_module
|
188
|
generic map (
|
189
|
CONFIG => "MityDSP_L138"
|
190
|
)
|
191
|
port map (
|
192
|
ema_clk => Ema_clk,
|
193
|
i_cs => Arm_cs5_r(CORE_BASE_MODULE),
|
194
|
i_ID => FPGA_APPLICATION_ID,
|
195
|
i_version_major => FPGA_VERSION_MAJOR,
|
196
|
i_version_minor => FPGA_VERSION_MINOR,
|
197
|
i_year => FPGA_YEAR,
|
198
|
i_month => FPGA_MONTH,
|
199
|
i_day => FPGA_DAY,
|
200
|
i_ABus => Addr_r,
|
201
|
i_DBus => Edi_r,
|
202
|
o_DBus => Edo_arm(CORE_BASE_MODULE),
|
203
|
i_wr_en => Wr_r,
|
204
|
i_rd_en => Rd_r,
|
205
|
i_be_r => Be_r,
|
206
|
|
207
|
o_dcm_reset => open,
|
208
|
i_dcm_status => "000",
|
209
|
i_dcm_lock => '0',
|
210
|
|
211
|
i_irq_map => Irq_map,
|
212
|
o_irq_output => o_int
|
213
|
);
|
214
|
-- end base_core_inst
|
215
|
|
216
|
|
217
|
-----------------
|
218
|
-- GPIO Module --
|
219
|
-----------------
|
220
|
|
221
|
gpio_core_inst : gpio
|
222
|
generic map (
|
223
|
NUM_BANKS => 1,
|
224
|
NUM_IO_PER_BANK => 2
|
225
|
)
|
226
|
port map (
|
227
|
clk => Ema_clk,
|
228
|
i_ABus => Addr_r,
|
229
|
i_DBus => Edi_r,
|
230
|
o_DBus => Edo_arm(CORE_GPIO_MODULE),
|
231
|
i_wr_en => Wr_r,
|
232
|
i_rd_en => Rd_r,
|
233
|
i_cs => Arm_cs5_r(CORE_GPIO_MODULE),
|
234
|
o_irq => Irq_map(CORE_GPIO_IRQ_LEVEL)(CORE_GPIO_IRQ_VECTOR),
|
235
|
i_ilevel => std_logic_vector(to_unsigned(CORE_GPIO_IRQ_LEVEL, 2)),
|
236
|
i_ivector => std_logic_vector(to_unsigned(CORE_GPIO_IRQ_VECTOR, 4)),
|
237
|
|
238
|
-- Output only, not tristated. Input copy of output
|
239
|
i_io(0) => io_j702_3_gpio,
|
240
|
i_io(1) => io_j702_4_gpio,
|
241
|
t_io => open,
|
242
|
o_io(0) => io_j702_3_gpio,
|
243
|
o_io(1) => io_j702_4_gpio,
|
244
|
|
245
|
i_initdir => "11",
|
246
|
i_initoutval => "11"
|
247
|
);
|
248
|
-- end gpio_core_inst
|
249
|
|
250
|
end gpio_arch;
|
251
|
|
252
|
|