1 |
16 |
mcwaccent |
----------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- This file is a part of Technica Corporation Wizardry Project
|
4 |
|
|
--
|
5 |
|
|
-- Copyright (C) 2004-2009, Technica Corporation
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
----------------------------------------------------------------------------------
|
21 |
|
|
----------------------------------------------------------------------------------
|
22 |
|
|
-- Create Date: 12:44:51 03/31/2008
|
23 |
|
|
-- Design Name: Marlon Winder
|
24 |
|
|
-- Module Name: new_empac_uart_top - Behavioral
|
25 |
|
|
-- Project Name: Wizardry
|
26 |
|
|
-- Target Devices: Virtex 4 ML401
|
27 |
|
|
-- Tool versions:
|
28 |
|
|
-- Description: Top-level structural description for EmPAC Component.
|
29 |
|
|
--
|
30 |
|
|
-- Dependencies:
|
31 |
|
|
--
|
32 |
|
|
-- Revision:
|
33 |
|
|
-- Revision 0.01 - File Created
|
34 |
|
|
-- Additional Comments:
|
35 |
|
|
--
|
36 |
|
|
----------------------------------------------------------------------------------
|
37 |
|
|
library IEEE;
|
38 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
39 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
40 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
41 |
|
|
use work.port_block_constants.all;
|
42 |
|
|
|
43 |
|
|
entity new_empac_uart_top is
|
44 |
|
|
port(
|
45 |
|
|
clock : in std_logic; -- FPGA clock input (100 Mhz)
|
46 |
|
|
phy_clock : in std_logic; -- Used to syncoronize EmPAC with the PHY interface
|
47 |
|
|
reset12_5_out : out std_logic;
|
48 |
|
|
reset_n : in std_logic; -- Active low reset
|
49 |
|
|
phy_data_in : in std_logic_vector(3 downto 0); -- 4-bit phy interface
|
50 |
|
|
phy_data_valid_in : in std_logic;
|
51 |
|
|
phy_reset : out std_logic; -- ethernet must be reset before it "wakes up"
|
52 |
|
|
field_data : out std_logic_vector(31 downto 0); -- 32 bit parsed data from packet
|
53 |
|
|
field_type : out std_logic_vector(7 downto 0); -- Indicates which parsed portion of the packet is
|
54 |
|
|
data_ready : out std_logic; -- output from "field_data" when "data_ready" is asserted
|
55 |
|
|
empac_12_5_clock : out std_logic; -- 12.5 Mhz output
|
56 |
|
|
end_of_frame : out std_logic; -- Indicates the end of a packet
|
57 |
|
|
|
58 |
|
|
-- Wishbone compliant DDR SDRAM interface ports. These signals interface directly with
|
59 |
|
|
-- RDIC, the memory interface component. See Wishbone spec for details on signal
|
60 |
|
|
ack_i : in std_logic; -- acknowledge
|
61 |
|
|
dat_i : in std_logic_Vector(31 downto 0); -- data in
|
62 |
|
|
dat_o : out std_logic_Vector(31 downto 0); -- etc.
|
63 |
|
|
adr_o : out std_logic_Vector(21 downto 0);
|
64 |
|
|
we_o : out std_logic;
|
65 |
|
|
cyc_o : out std_logic;
|
66 |
|
|
stb_o : out std_logic;
|
67 |
|
|
lock_o : out std_logic;
|
68 |
|
|
priority_o : out std_logic_vector(7 downto 0); -- NOT PART OF SPEC!!!!
|
69 |
|
|
-- Indicates the access priority
|
70 |
|
|
|
71 |
|
|
id_o : out std_logic_Vector(4 downto 0); -- NOT PART OF SPEC!!!!
|
72 |
|
|
-- Enables other components to refer to EmPAC's
|
73 |
|
|
-- shared memory resources by ID.
|
74 |
|
|
-- End of memory interface ports
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
-- Debug Outputs --
|
78 |
|
|
-- These signals can be used to see how fast the FIFO is being
|
79 |
|
|
fifo_empty_out : out std_logic; -- Signals used for debugging
|
80 |
|
|
fifo_full_out : out std_logic; -- Signals used for debugging
|
81 |
|
|
fifo_push_count : out std_logic_vector(11 downto 0)); -- Signals used for debugging
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
end new_empac_uart_top;
|
85 |
|
|
|
86 |
|
|
architecture Behavioral of new_empac_uart_top is
|
87 |
|
|
|
88 |
|
|
-- Various signal for connecting the structural components of EmPAC
|
89 |
|
|
signal leds : std_logic_vector(8 downto 0);
|
90 |
|
|
|
91 |
|
|
signal field_data_s : std_logic_vector(31 downto 0);
|
92 |
|
|
signal field_type_s : std_logic_vector(7 downto 0);
|
93 |
|
|
signal data_ready_s : std_logic;
|
94 |
|
|
signal empac_load : std_logic;
|
95 |
|
|
signal empac_load_data : std_logic_vector(15 downto 0);
|
96 |
|
|
|
97 |
|
|
signal clk_div : std_logic;
|
98 |
|
|
signal phy_data : std_logic_Vector(7 downto 0);
|
99 |
|
|
signal phy_data_valid : std_logic;
|
100 |
|
|
signal reset : std_logic;
|
101 |
|
|
signal known_packet_count : std_logic_vector(31 downto 0);
|
102 |
|
|
signal unknown_packet_count : std_logic_vector(31 downto 0);
|
103 |
|
|
signal total_frame_count : std_logic_vector(31 downto 0);
|
104 |
|
|
signal tcp_frame_count : std_logic_vector(31 downto 0);
|
105 |
|
|
signal udp_frame_count : std_logic_vector(31 downto 0);
|
106 |
|
|
signal IPv4_frame_count : std_logic_vector(31 downto 0);
|
107 |
|
|
signal IPv6_frame_count : std_logic_vector(31 downto 0);
|
108 |
|
|
signal ARP_frame_count : std_logic_vector(31 downto 0);
|
109 |
|
|
signal src_port_found_count : std_logic_vector(31 downto 0);
|
110 |
|
|
signal dst_port_found_count : std_logic_vector(31 downto 0);
|
111 |
|
|
signal EmPAC_leds : std_logic_vector(8 downto 0);
|
112 |
|
|
signal Uart_leds : std_logic_vector(8 downto 0);
|
113 |
|
|
|
114 |
|
|
signal phy_clock_test : std_logic;
|
115 |
|
|
signal uart_data_ready : std_logic;
|
116 |
|
|
signal src_port_found : STD_LOGIC;
|
117 |
|
|
signal src_port_value : STD_LOGIC_VECTOR (15 downto 0);
|
118 |
|
|
signal dst_port_found : STD_LOGIC;
|
119 |
|
|
signal dst_port_value : STD_LOGIC_VECTOR (15 downto 0);
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
component reset_internal is -- Component used to generate reset signals for different clock domains
|
123 |
|
|
Port ( clock100 : in STD_LOGIC;
|
124 |
|
|
clock25 : in std_logic;
|
125 |
|
|
clock12_5 : in std_logic;
|
126 |
|
|
reset : in STD_LOGIC;
|
127 |
|
|
reset100 : out STD_LOGIC;
|
128 |
|
|
reset25 : out STD_LOGIC;
|
129 |
|
|
reset12_5 : out STD_LOGIC);
|
130 |
|
|
end component;
|
131 |
|
|
|
132 |
|
|
-- This component takes 4 bit nibbles received from the PHY interface concattonates every other nibble into a byte.
|
133 |
|
|
-- However, since a byte is only received every other clock cycle (at 25 Mhz), a new 12.5 Mhz clock is generate
|
134 |
|
|
-- to resynchronize the PHY data.
|
135 |
|
|
|
136 |
|
|
component clk_divide is
|
137 |
|
|
port(clock : in std_logic;
|
138 |
|
|
reset : in std_logic;
|
139 |
|
|
clk_div : out std_logic;
|
140 |
|
|
phy_data : out std_logic_Vector(7 downto 0);
|
141 |
|
|
phy_data_valid : out std_logic;
|
142 |
|
|
phy_data_in : in std_logic_vector(3 downto 0);
|
143 |
|
|
phy_data_valid_in : in std_logic);
|
144 |
|
|
end component;
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
-- Actual EmPAC component
|
148 |
|
|
component new_empac_top is
|
149 |
|
|
port(
|
150 |
|
|
sys_clock : in std_logic;
|
151 |
|
|
clock : in std_logic;
|
152 |
|
|
reset : in std_logic;
|
153 |
|
|
reset_100 : in std_logic;
|
154 |
|
|
EmPAC_leds : out std_logic_vector(8 downto 0);
|
155 |
|
|
phy_data : in std_logic_vector(7 downto 0);
|
156 |
|
|
phy_data_valid : in std_logic;
|
157 |
|
|
field_data : out std_logic_vector(31 downto 0);
|
158 |
|
|
field_type : out std_logic_vector(7 downto 0);
|
159 |
|
|
data_ready : out std_logic;
|
160 |
|
|
ack_i : in STD_LOGIC;
|
161 |
|
|
dat_i : in STD_LOGIC_vector(31 downto 0);
|
162 |
|
|
dat_o : out STD_LOGIC_VECTOR (31 downto 0);
|
163 |
|
|
adr_o : out STD_LOGIC_VECTOR (21 downto 0);
|
164 |
|
|
we_o : out STD_LOGIC;
|
165 |
|
|
cyc_o : out STD_LOGIC;
|
166 |
|
|
stb_o : out STD_LOGIC;
|
167 |
|
|
lock_o : out std_logic;
|
168 |
|
|
priority_o : out std_logic_vector(7 downto 0);
|
169 |
|
|
id_o : out std_logic_Vector(4 downto 0);
|
170 |
|
|
fifo_empty_out : out std_logic;
|
171 |
|
|
fifo_full_out : out std_logic;
|
172 |
|
|
fifo_push_count : out std_logic_vector(11 downto 0);
|
173 |
|
|
end_of_frame : out std_logic
|
174 |
|
|
);
|
175 |
|
|
end component;
|
176 |
|
|
|
177 |
|
|
signal reset100,reset25,reset12_5 : std_logic;
|
178 |
|
|
signal frame_counters : frame_counters_type;
|
179 |
|
|
|
180 |
|
|
begin
|
181 |
|
|
phy_reset <= not reset_n;
|
182 |
|
|
|
183 |
|
|
field_data <= field_data_s;
|
184 |
|
|
field_type <= field_type_s;
|
185 |
|
|
data_ready <= data_ready_s;
|
186 |
|
|
reset12_5_out <= reset12_5;
|
187 |
|
|
empac_12_5_clock <= clk_div;
|
188 |
|
|
|
189 |
|
|
rst_cmp: reset_internal
|
190 |
|
|
Port map( clock100 => clock,
|
191 |
|
|
clock25 => phy_clock,
|
192 |
|
|
clock12_5 => clk_div,
|
193 |
|
|
reset => reset_n,
|
194 |
|
|
reset100 => reset100,
|
195 |
|
|
reset25 => reset25,
|
196 |
|
|
reset12_5 => reset12_5);
|
197 |
|
|
|
198 |
|
|
clkdiv : clk_divide
|
199 |
|
|
port map(clock => phy_clock,
|
200 |
|
|
reset => reset,
|
201 |
|
|
clk_div => clk_div,
|
202 |
|
|
phy_data => phy_data,
|
203 |
|
|
phy_data_valid => phy_data_valid,
|
204 |
|
|
phy_data_in => phy_data_in,
|
205 |
|
|
phy_data_valid_in => phy_data_valid_in);
|
206 |
|
|
|
207 |
|
|
empac: new_empac_top
|
208 |
|
|
port map(
|
209 |
|
|
sys_clock => clock,
|
210 |
|
|
clock => clk_div,
|
211 |
|
|
reset => reset12_5,
|
212 |
|
|
reset_100 => reset100,
|
213 |
|
|
EmPAC_leds => EmPAC_leds,
|
214 |
|
|
phy_data => phy_data,
|
215 |
|
|
phy_data_valid => phy_data_valid,
|
216 |
|
|
field_data => field_data_s,
|
217 |
|
|
field_type => field_type_s,
|
218 |
|
|
data_ready => data_ready_s,
|
219 |
|
|
ack_i => ack_i,
|
220 |
|
|
dat_i => dat_i,
|
221 |
|
|
dat_o => dat_o,
|
222 |
|
|
adr_o => adr_o,
|
223 |
|
|
we_o => we_o,
|
224 |
|
|
cyc_o => cyc_o,
|
225 |
|
|
stb_o => stb_o,
|
226 |
|
|
lock_o => lock_o,
|
227 |
|
|
priority_o => priority_o,
|
228 |
|
|
id_o => id_o,
|
229 |
|
|
fifo_empty_out => fifo_empty_out,
|
230 |
|
|
fifo_full_out => fifo_full_out,
|
231 |
|
|
fifo_push_count => fifo_push_count,
|
232 |
|
|
end_of_frame => end_of_frame
|
233 |
|
|
);
|
234 |
|
|
|
235 |
|
|
end Behavioral;
|