1 |
145 |
lanttu |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : udp2hibi example
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : udp2hibi_example_top.vhd
|
6 |
|
|
-- Author : <alhonena@AHVEN>
|
7 |
|
|
-- Company :
|
8 |
|
|
-- Created : 2012-01-19
|
9 |
|
|
-- Last update: 2012-02-07
|
10 |
|
|
-- Platform :
|
11 |
|
|
-- Standard : VHDL'87
|
12 |
|
|
-------------------------------------------------------------------------------
|
13 |
|
|
-- Description: Instantiates NIOS II CPU, SDRAM CTRL, UDP2HIBI and HIBI to
|
14 |
|
|
-- interconnect those. UDP2HIBI further instantiates UDP/IP packetizer and
|
15 |
|
|
-- a controller for DM9000A eth chip.
|
16 |
|
|
-- Hence, you can demonstrate ethernet TX and RX operations from the software
|
17 |
|
|
-- on NIOS, utilizing SW-initiated DMA between SDRAM and UDP2HIBI.
|
18 |
|
|
-- You can connect an FPGA board and a PC, but it may be even easier to connect
|
19 |
|
|
-- two FPGA boards with identical configuration.
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
-- Copyright (c) 2012
|
22 |
|
|
-------------------------------------------------------------------------------
|
23 |
|
|
-- Revisions :
|
24 |
|
|
-- Date Version Author Description
|
25 |
|
|
-- 2012-01-19 1.0 alhonena Created
|
26 |
|
|
-------------------------------------------------------------------------------
|
27 |
|
|
|
28 |
|
|
library ieee;
|
29 |
|
|
use ieee.std_logic_1164.all;
|
30 |
|
|
|
31 |
|
|
entity udp2hibi_example_top is
|
32 |
|
|
|
33 |
|
|
port (
|
34 |
|
|
CLOCK_50 : in std_logic;
|
35 |
|
|
SW : in std_logic_vector(17 downto 0);
|
36 |
|
|
KEY : in std_logic_vector(3 downto 0);
|
37 |
|
|
LEDR : out std_logic_vector(17 downto 0);
|
38 |
|
|
LEDG : out std_logic_vector(8 downto 0);
|
39 |
|
|
|
40 |
|
|
DRAM_ADDR : out std_logic_vector(11 downto 0);
|
41 |
|
|
DRAM_BA : out std_logic_vector(1 downto 0);
|
42 |
|
|
DRAM_CAS_N : out std_logic;
|
43 |
|
|
DRAM_CKE : out std_logic;
|
44 |
|
|
DRAM_CLK : out std_logic;
|
45 |
|
|
DRAM_CS_N : out std_logic;
|
46 |
|
|
DRAM_DQ : inout std_logic_vector(15 downto 0);
|
47 |
|
|
DRAM_DQM : out std_logic_vector(1 downto 0);
|
48 |
|
|
DRAM_RAS_N : out std_logic;
|
49 |
|
|
DRAM_WE_N : out std_logic;
|
50 |
|
|
|
51 |
|
|
ENET_DATA : inout std_logic_vector(15 downto 0);
|
52 |
|
|
ENET_CLK : out std_logic;
|
53 |
|
|
ENET_CMD : out std_logic;
|
54 |
|
|
ENET_CS_N : out std_logic;
|
55 |
|
|
ENET_INT : in std_logic;
|
56 |
|
|
ENET_RD_N : out std_logic;
|
57 |
|
|
ENET_WR_N : out std_logic;
|
58 |
|
|
ENET_RST_N : out std_logic
|
59 |
|
|
|
60 |
|
|
);
|
61 |
|
|
|
62 |
|
|
end udp2hibi_example_top;
|
63 |
|
|
|
64 |
|
|
architecture structural of udp2hibi_example_top is
|
65 |
|
|
|
66 |
|
|
signal clk_cpu, clk_eth, rst_n : std_logic;
|
67 |
|
|
|
68 |
|
|
-- hibi terminology:
|
69 |
|
|
-- r4 interface = simpler interface; one signal set for both priorities, multiplexed addr&data (1-bit av signal)
|
70 |
|
|
-- r3 interface = two signal sets ("normal" and hi-prio ("msg")), separate addr and data.
|
71 |
|
|
|
72 |
|
|
constant hibi_comm_w_c : integer := 5;
|
73 |
|
|
constant hibi_data_w_c : integer := 32;
|
74 |
|
|
constant hibi_addr_w_c : integer := 32;
|
75 |
|
|
|
76 |
|
|
constant num_r4_ips_c : integer := 2; -- nios, udp2hibi
|
77 |
|
|
constant num_r3_ips_c : integer := 1; -- sdram
|
78 |
|
|
|
79 |
|
|
-- r3 signals for sdram
|
80 |
|
|
|
81 |
|
|
signal r3_wra_ag_addr : std_logic_vector(num_r3_ips_c*hibi_addr_w_c-1 downto 0);
|
82 |
|
|
signal r3_wra_ag_data : std_logic_vector(num_r3_ips_c*hibi_data_w_c-1 downto 0);
|
83 |
|
|
signal r3_wra_ag_comm : std_logic_vector(num_r3_ips_c*hibi_comm_w_c-1 downto 0);
|
84 |
|
|
signal r3_wra_ag_empty : std_logic_vector(num_r3_ips_c-1 downto 0);
|
85 |
|
|
signal r3_ag_wra_re : std_logic_vector(num_r3_ips_c-1 downto 0);
|
86 |
|
|
signal r3_ag_wra_addr : std_logic_vector(num_r3_ips_c*hibi_addr_w_c-1 downto 0);
|
87 |
|
|
signal r3_ag_wra_data : std_logic_vector(num_r3_ips_c*hibi_data_w_c-1 downto 0);
|
88 |
|
|
signal r3_ag_wra_comm : std_logic_vector(num_r3_ips_c*hibi_comm_w_c-1 downto 0);
|
89 |
|
|
signal r3_wra_ag_full : std_logic_vector(num_r3_ips_c-1 downto 0);
|
90 |
|
|
signal r3_ag_wra_we : std_logic_vector(num_r3_ips_c-1 downto 0);
|
91 |
|
|
signal r3_wra_ag_msg_addr : std_logic_vector(num_r3_ips_c*hibi_addr_w_c-1 downto 0);
|
92 |
|
|
signal r3_wra_ag_msg_data : std_logic_vector(num_r3_ips_c*hibi_data_w_c-1 downto 0);
|
93 |
|
|
signal r3_wra_ag_msg_comm : std_logic_vector(num_r3_ips_c*hibi_comm_w_c-1 downto 0);
|
94 |
|
|
signal r3_wra_ag_msg_empty : std_logic_vector(num_r3_ips_c-1 downto 0);
|
95 |
|
|
signal r3_ag_wra_msg_re : std_logic_vector(num_r3_ips_c-1 downto 0);
|
96 |
|
|
signal r3_ag_wra_msg_addr : std_logic_vector(num_r3_ips_c*hibi_addr_w_c-1 downto 0);
|
97 |
|
|
signal r3_ag_wra_msg_data : std_logic_vector(num_r3_ips_c*hibi_data_w_c-1 downto 0);
|
98 |
|
|
signal r3_ag_wra_msg_comm : std_logic_vector(num_r3_ips_c*hibi_comm_w_c-1 downto 0);
|
99 |
|
|
signal r3_wra_ag_msg_full : std_logic_vector(num_r3_ips_c-1 downto 0);
|
100 |
|
|
signal r3_ag_wra_msg_we : std_logic_vector(num_r3_ips_c-1 downto 0);
|
101 |
|
|
|
102 |
|
|
signal r4_wra_ag_av : std_logic_vector(num_r4_ips_c-1 downto 0);
|
103 |
|
|
signal r4_wra_ag_data : std_logic_vector(num_r4_ips_c*hibi_data_w_c-1 downto 0);
|
104 |
|
|
signal r4_wra_ag_comm : std_logic_vector(num_r4_ips_c*hibi_comm_w_c-1 downto 0);
|
105 |
|
|
signal r4_wra_ag_empty : std_logic_vector(num_r4_ips_c-1 downto 0);
|
106 |
|
|
signal r4_ag_wra_re : std_logic_vector(num_r4_ips_c-1 downto 0);
|
107 |
|
|
signal r4_ag_wra_av : std_logic_vector(num_r4_ips_c-1 downto 0);
|
108 |
|
|
signal r4_ag_wra_data : std_logic_vector(num_r4_ips_c*hibi_data_w_c-1 downto 0);
|
109 |
|
|
signal r4_ag_wra_comm : std_logic_vector(num_r4_ips_c*hibi_comm_w_c-1 downto 0);
|
110 |
|
|
signal r4_wra_ag_full : std_logic_vector(num_r4_ips_c-1 downto 0);
|
111 |
|
|
signal r4_ag_wra_we : std_logic_vector(num_r4_ips_c-1 downto 0);
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
begin -- structural
|
116 |
|
|
|
117 |
|
|
pll_1: entity work.pll
|
118 |
|
|
port map (
|
119 |
|
|
areset => not SW(17),
|
120 |
|
|
inclk0 => CLOCK_50,
|
121 |
|
|
c0 => clk_cpu, -- 50 MHz
|
122 |
|
|
c1 => DRAM_CLK, -- 50 MHz -54 deg
|
123 |
|
|
c2 => clk_eth, -- 25 MHz
|
124 |
|
|
locked => rst_n);
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
udp2hibi_demo_cpu_1 : entity work.udp2hibi_demo_cpu
|
128 |
|
|
port map(
|
129 |
|
|
hibi_av_out_from_the_n2h2_chan_0 => r4_ag_wra_av(0),
|
130 |
|
|
hibi_comm_out_from_the_n2h2_chan_0 => r4_ag_wra_comm(hibi_comm_w_c-1 downto 0),
|
131 |
|
|
hibi_data_out_from_the_n2h2_chan_0 => r4_ag_wra_data(hibi_data_w_c-1 downto 0),
|
132 |
|
|
hibi_re_out_from_the_n2h2_chan_0 => r4_ag_wra_re(0),
|
133 |
|
|
hibi_we_out_from_the_n2h2_chan_0 => r4_ag_wra_we(0),
|
134 |
|
|
out_port_from_the_pout => LEDR(7 downto 0),
|
135 |
|
|
clk_0 => clk_cpu,
|
136 |
|
|
hibi_av_in_to_the_n2h2_chan_0 => r4_wra_ag_av(0),
|
137 |
|
|
hibi_comm_in_to_the_n2h2_chan_0 => r4_wra_ag_comm(hibi_comm_w_c-1 downto 0),
|
138 |
|
|
hibi_data_in_to_the_n2h2_chan_0 => r4_wra_ag_data(hibi_data_w_c-1 downto 0),
|
139 |
|
|
hibi_empty_in_to_the_n2h2_chan_0 => r4_wra_ag_empty(0),
|
140 |
|
|
hibi_full_in_to_the_n2h2_chan_0 => r4_wra_ag_full(0),
|
141 |
|
|
in_port_to_the_pin => SW(7 downto 0),
|
142 |
|
|
reset_n => rst_n
|
143 |
|
|
);
|
144 |
|
|
|
145 |
|
|
hibi_segment_v3_1: entity work.hibi_segment_v3
|
146 |
|
|
generic map (
|
147 |
|
|
-- id_width_g => id_width_g,
|
148 |
|
|
addr_width_g => 32,
|
149 |
|
|
data_width_g => 32,
|
150 |
|
|
comm_width_g => 5,
|
151 |
|
|
-- counter_width_g => counter_width_g,
|
152 |
|
|
rel_agent_freq_g => 1,
|
153 |
|
|
rel_bus_freq_g => 1,
|
154 |
|
|
-- arb_type_g => arb_type_g,
|
155 |
|
|
fifo_sel_g => 0,
|
156 |
|
|
-- rx_fifo_depth_g => rx_fifo_depth_g,
|
157 |
|
|
-- rx_msg_fifo_depth_g => rx_msg_fifo_depth_g,
|
158 |
|
|
-- tx_fifo_depth_g => tx_fifo_depth_g,
|
159 |
|
|
-- tx_msg_fifo_depth_g => tx_msg_fifo_depth_g,
|
160 |
|
|
-- max_send_g => max_send_g,
|
161 |
|
|
-- n_cfg_pages_g => n_cfg_pages_g,
|
162 |
|
|
-- n_time_slots_g => n_time_slots_g,
|
163 |
|
|
-- keep_slot_g => keep_slot_g,
|
164 |
|
|
-- n_extra_params_g => n_extra_params_g,
|
165 |
|
|
-- cfg_re_g => cfg_re_g,
|
166 |
|
|
-- cfg_we_g => cfg_we_g,
|
167 |
|
|
-- debug_width_g => debug_width_g,
|
168 |
|
|
n_r3_agents_g => num_r3_ips_c,
|
169 |
|
|
n_r4_agents_g => num_r4_ips_c,
|
170 |
|
|
n_segments_g => 1,
|
171 |
|
|
separate_addr_g => 0)
|
172 |
|
|
port map (
|
173 |
|
|
clk_in => clk_cpu,
|
174 |
|
|
rst_n => rst_n,
|
175 |
|
|
r4_agent_comm_in => r4_ag_wra_comm,
|
176 |
|
|
r4_agent_data_in => r4_ag_wra_data,
|
177 |
|
|
r4_agent_av_in => r4_ag_wra_av,
|
178 |
|
|
r4_agent_we_in => r4_ag_wra_we,
|
179 |
|
|
r4_agent_re_in => r4_ag_wra_re,
|
180 |
|
|
r4_agent_comm_out => r4_wra_ag_comm,
|
181 |
|
|
r4_agent_data_out => r4_wra_ag_data,
|
182 |
|
|
r4_agent_av_out => r4_wra_ag_av,
|
183 |
|
|
r4_agent_full_out => r4_wra_ag_full,
|
184 |
|
|
r4_agent_one_p_out => open,
|
185 |
|
|
r4_agent_empty_out => r4_wra_ag_empty,
|
186 |
|
|
r4_agent_one_d_out => open,
|
187 |
|
|
r3_agent_comm_in => r3_ag_wra_comm,
|
188 |
|
|
r3_agent_data_in => r3_ag_wra_data,
|
189 |
|
|
r3_agent_addr_in => r3_ag_wra_addr,
|
190 |
|
|
r3_agent_we_in => r3_ag_wra_we,
|
191 |
|
|
r3_agent_re_in => r3_ag_wra_re,
|
192 |
|
|
r3_agent_comm_out => r3_wra_ag_comm,
|
193 |
|
|
r3_agent_data_out => r3_wra_ag_data,
|
194 |
|
|
r3_agent_addr_out => r3_wra_ag_addr,
|
195 |
|
|
r3_agent_full_out => r3_wra_ag_full,
|
196 |
|
|
r3_agent_one_p_out => open,
|
197 |
|
|
r3_agent_empty_out => r3_wra_ag_empty,
|
198 |
|
|
r3_agent_one_d_out => open,
|
199 |
|
|
r3_agent_msg_comm_in => r3_ag_wra_msg_comm,
|
200 |
|
|
r3_agent_msg_data_in => r3_ag_wra_msg_data,
|
201 |
|
|
r3_agent_msg_addr_in => r3_ag_wra_msg_addr,
|
202 |
|
|
r3_agent_msg_we_in => r3_ag_wra_msg_we,
|
203 |
|
|
r3_agent_msg_re_in => r3_ag_wra_msg_re,
|
204 |
|
|
r3_agent_msg_comm_out => r3_wra_ag_msg_comm,
|
205 |
|
|
r3_agent_msg_data_out => r3_wra_ag_msg_data,
|
206 |
|
|
r3_agent_msg_addr_out => r3_wra_ag_msg_addr,
|
207 |
|
|
r3_agent_msg_full_out => r3_wra_ag_msg_full,
|
208 |
|
|
r3_agent_msg_one_p_out => open,
|
209 |
|
|
r3_agent_msg_empty_out => r3_wra_ag_msg_empty,
|
210 |
|
|
r3_agent_msg_one_d_out => open);
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
sdram_toplevel_1: entity work.sdram_toplevel -- use the 16-bit (de2) version.
|
214 |
|
|
generic map (
|
215 |
|
|
hibi_data_width_g => 32,
|
216 |
|
|
mem_data_width_g => 16,
|
217 |
|
|
-- mem_addr_width_g => 22,
|
218 |
|
|
-- comm_width_g => 5,
|
219 |
|
|
-- input_fifo_depth_g => input_fifo_depth_g,
|
220 |
|
|
-- num_of_read_ports_g => num_of_read_ports_g,
|
221 |
|
|
-- num_of_write_ports_g => num_of_write_ports_g,
|
222 |
|
|
-- offset_width_g => offset_width_g,
|
223 |
|
|
-- rq_fifo_depth_g => rq_fifo_depth_g,
|
224 |
|
|
-- op_arb_type_g => op_arb_type_g,
|
225 |
|
|
-- port_arb_type_g => port_arb_type_g,
|
226 |
|
|
-- blk_rd_prior_g => blk_rd_prior_g,
|
227 |
|
|
-- blk_wr_prior_g => blk_wr_prior_g,
|
228 |
|
|
-- single_op_prior_g => single_op_prior_g,
|
229 |
|
|
-- block_overlap_g => block_overlap_g,
|
230 |
|
|
clk_freq_mhz_g => 50
|
231 |
|
|
-- block_read_length_g => block_read_length_g
|
232 |
|
|
)
|
233 |
|
|
port map (
|
234 |
|
|
clk => clk_cpu,
|
235 |
|
|
rst_n => rst_n,
|
236 |
|
|
hibi_addr_in => r3_wra_ag_addr(hibi_addr_w_c-1 downto 0),
|
237 |
|
|
hibi_data_in => r3_wra_ag_data(hibi_data_w_c-1 downto 0),
|
238 |
|
|
hibi_comm_in => r3_wra_ag_comm(hibi_comm_w_c-1 downto 0),
|
239 |
|
|
hibi_empty_in => r3_wra_ag_empty(0),
|
240 |
|
|
hibi_re_out => r3_ag_wra_re(0),
|
241 |
|
|
hibi_addr_out => r3_ag_wra_addr(hibi_addr_w_c-1 downto 0),
|
242 |
|
|
hibi_data_out => r3_ag_wra_data(hibi_data_w_c-1 downto 0),
|
243 |
|
|
hibi_comm_out => r3_ag_wra_comm(hibi_comm_w_c-1 downto 0),
|
244 |
|
|
hibi_full_in => r3_wra_ag_full(0),
|
245 |
|
|
hibi_we_out => r3_ag_wra_we(0),
|
246 |
|
|
hibi_msg_addr_in => r3_wra_ag_msg_addr(hibi_addr_w_c-1 downto 0),
|
247 |
|
|
hibi_msg_data_in => r3_wra_ag_msg_data(hibi_data_w_c-1 downto 0),
|
248 |
|
|
hibi_msg_comm_in => r3_wra_ag_msg_comm(hibi_comm_w_c-1 downto 0),
|
249 |
|
|
hibi_msg_empty_in => r3_wra_ag_msg_empty(0),
|
250 |
|
|
hibi_msg_re_out => r3_ag_wra_msg_re(0),
|
251 |
|
|
hibi_msg_data_out => r3_ag_wra_msg_data(hibi_data_w_c-1 downto 0),
|
252 |
|
|
hibi_msg_addr_out => r3_ag_wra_msg_addr(hibi_addr_w_c-1 downto 0),
|
253 |
|
|
hibi_msg_comm_out => r3_ag_wra_msg_comm(hibi_comm_w_c-1 downto 0),
|
254 |
|
|
hibi_msg_full_in => r3_wra_ag_msg_full(0),
|
255 |
|
|
hibi_msg_we_out => r3_ag_wra_msg_we(0),
|
256 |
|
|
sdram_data_inout => DRAM_DQ,
|
257 |
|
|
sdram_cke_out => DRAM_CKE,
|
258 |
|
|
sdram_cs_n_out => DRAM_CS_N,
|
259 |
|
|
sdram_we_n_out => DRAM_WE_N,
|
260 |
|
|
sdram_ras_n_out => DRAM_RAS_N,
|
261 |
|
|
sdram_cas_n_out => DRAM_CAS_N,
|
262 |
|
|
sdram_dqm_out => DRAM_DQM,
|
263 |
|
|
sdram_ba_out => DRAM_BA,
|
264 |
|
|
sdram_address_out => DRAM_ADDR);
|
265 |
|
|
|
266 |
|
|
eth_udpip_udp2hibi_top_1: entity work.eth_udpip_udp2hibi_top
|
267 |
|
|
generic map (
|
268 |
|
|
-- receiver_table_size_g => receiver_table_size_g,
|
269 |
|
|
-- ack_fifo_depth_g => ack_fifo_depth_g,
|
270 |
|
|
-- tx_multiclk_fifo_depth_g => tx_multiclk_fifo_depth_g,
|
271 |
|
|
-- rx_multiclk_fifo_depth_g => rx_multiclk_fifo_depth_g,
|
272 |
|
|
-- hibi_tx_fifo_depth_g => hibi_tx_fifo_depth_g,
|
273 |
|
|
hibi_data_width_g => 32,
|
274 |
|
|
hibi_addr_width_g => 32,
|
275 |
|
|
hibi_comm_width_g => 5,
|
276 |
|
|
frequency_g => 50000000)
|
277 |
|
|
port map (
|
278 |
|
|
clk => clk_cpu,
|
279 |
|
|
clk_udp => clk_eth,
|
280 |
|
|
rst_n => rst_n,
|
281 |
|
|
eth_clk_out => ENET_CLK,
|
282 |
|
|
eth_reset_out => ENET_RST_N,
|
283 |
|
|
eth_cmd_out => ENET_CMD,
|
284 |
|
|
eth_write_out => ENET_WR_N,
|
285 |
|
|
eth_read_out => ENET_RD_N,
|
286 |
|
|
eth_interrupt_in => ENET_INT,
|
287 |
|
|
eth_data_inout => ENET_DATA,
|
288 |
|
|
eth_chip_sel_out => ENET_CS_N,
|
289 |
|
|
ready_out => LEDG(8),
|
290 |
|
|
fatal_error_out => LEDR(17),
|
291 |
|
|
hibi_comm_in => r4_wra_ag_comm(2*hibi_comm_w_c-1 downto 1*hibi_comm_w_c),
|
292 |
|
|
hibi_data_in => r4_wra_ag_data(2*hibi_data_w_c-1 downto 1*hibi_data_w_c),
|
293 |
|
|
hibi_av_in => r4_wra_ag_av(1),
|
294 |
|
|
hibi_empty_in => r4_wra_ag_empty(1),
|
295 |
|
|
hibi_re_out => r4_ag_wra_re(1),
|
296 |
|
|
hibi_comm_out => r4_ag_wra_comm(2*hibi_comm_w_c-1 downto 1*hibi_comm_w_c),
|
297 |
|
|
hibi_data_out => r4_ag_wra_data(2*hibi_data_w_c-1 downto 1*hibi_data_w_c),
|
298 |
|
|
hibi_av_out => r4_ag_wra_av(1),
|
299 |
|
|
hibi_we_out => r4_ag_wra_we(1),
|
300 |
|
|
hibi_full_in => r4_wra_ag_full(1));
|
301 |
|
|
|
302 |
|
|
end structural;
|