1 |
20 |
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 |
|
|
-- Module Name: EmPAC_constants - Package file
|
23 |
|
|
-- Project Name: Wizardry
|
24 |
|
|
-- Target Devices: Virtex 4 ML401
|
25 |
|
|
-- Description:
|
26 |
|
|
-- Revision: 1.0
|
27 |
|
|
-- Additional Comments:
|
28 |
|
|
--
|
29 |
|
|
----------------------------------------------------------------------------------
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
library IEEE;
|
33 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
34 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
35 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
36 |
|
|
package EmPAC_constants is
|
37 |
|
|
|
38 |
|
|
type StateType is (ftreset,ft0,ft1,ft2,ft3, ft4, ft5, ft6, ft7, ft8, ft9, ftA, ftB, ft_C, ftD, ftE,
|
39 |
|
|
ftF, ft10, ft11, ft12, ft13, ft14, ft15, ft16, ft17, ft18,
|
40 |
|
|
ft19, ft1A, ft1B, ft1C, ft1D, ft1E, ft1F, ft20, ft21, ft22,
|
41 |
|
|
ft23, ft24, ft25, ft26, ft27, ft28, ft29, ft2A, ft2B, ft2C,
|
42 |
|
|
ft2D, ft2E, ft2F, ft30, ft31, ft32, ft33, ft34, ft35, ft36,
|
43 |
|
|
ft37, ft38, ft39, ft3A, ft3B, ft3C, ft3D, ft3E, ft3F, ft40,ft41,unknown_protocol,icmp_protocol);
|
44 |
|
|
|
45 |
|
|
constant init_00 : std_logic_vector(5 downto 0) := "000000";
|
46 |
|
|
constant init_02 : std_logic_vector(5 downto 0) := "000010";
|
47 |
|
|
constant init_04 : std_logic_vector(5 downto 0) := "000100";
|
48 |
|
|
constant init_0C : std_logic_vector(5 downto 0) := "001100";
|
49 |
|
|
constant init_10 : std_logic_vector(5 downto 0) := "010000";
|
50 |
|
|
constant init_12 : std_logic_vector(5 downto 0) := "010010";
|
51 |
|
|
constant init_1C : std_logic_vector(5 downto 0) := "011100";
|
52 |
|
|
constant init_30 : std_logic_vector(5 downto 0) := "110000";
|
53 |
|
|
constant init_38 : std_logic_vector(5 downto 0) := "111000";
|
54 |
|
|
constant init_x1 : std_logic_vector(5 downto 0) := "XX0001";
|
55 |
|
|
constant init_x9 : std_logic_vector(5 downto 0) := "XX1001";
|
56 |
|
|
constant init_x5 : std_logic_vector(5 downto 0) := "XX0101";
|
57 |
|
|
constant init_xD : std_logic_vector(5 downto 0) := "XX1101";
|
58 |
|
|
|
59 |
|
|
constant init_eth : std_logic_vector(11 downto 0) := "000000000000";
|
60 |
|
|
constant init_arp : std_logic_vector(11 downto 0) := "000000000111";
|
61 |
|
|
constant init_ip : std_logic_vector(11 downto 0) := "000000011000";
|
62 |
|
|
constant init_tcp : std_logic_vector(11 downto 0) := "000000100011";
|
63 |
|
|
constant init_udp : std_logic_vector(11 downto 0) := "000000101101";
|
64 |
|
|
constant zero : std_logic_vector(3 downto 0) := "0000";
|
65 |
|
|
constant one : std_logic_vector(3 downto 0) := "0001";
|
66 |
|
|
constant two : std_logic_vector(3 downto 0) := "0010";
|
67 |
|
|
constant three : std_logic_vector(3 downto 0) := "0011";
|
68 |
|
|
constant four : std_logic_vector(3 downto 0) := "0100";
|
69 |
|
|
constant five : std_logic_vector(3 downto 0) := "0101";
|
70 |
|
|
constant eight : std_logic_vector(3 downto 0) := "1000";
|
71 |
|
|
constant nine : std_logic_vector(3 downto 0) := "1001";
|
72 |
|
|
constant A : std_logic_vector(3 downto 0) := "1010";
|
73 |
|
|
constant B : std_logic_vector(3 downto 0) := "1011";
|
74 |
|
|
constant C : std_logic_vector(3 downto 0) := "1100";
|
75 |
|
|
constant D : std_logic_vector(3 downto 0) := "1101";
|
76 |
|
|
|
77 |
|
|
constant data_0 : std_logic_vector(3 downto 0) := zero;
|
78 |
|
|
constant data_1 : std_logic_vector(3 downto 0) := one;
|
79 |
|
|
constant data_2 : std_logic_vector(3 downto 0) := two;--when dram_data(3 downto 0) = two else
|
80 |
|
|
constant data_3 : std_logic_vector(3 downto 0) := three;
|
81 |
|
|
constant data_4 : std_logic_vector(3 downto 0) := four;
|
82 |
|
|
constant data_5 : std_logic_vector(3 downto 0) := five;
|
83 |
|
|
constant data_8 : std_logic_vector(3 downto 0) := eight;
|
84 |
|
|
constant data_9 : std_logic_vector(3 downto 0) := nine;
|
85 |
|
|
constant data_A : std_logic_vector(3 downto 0) := A;
|
86 |
|
|
constant data_B : std_logic_vector(3 downto 0) := B;
|
87 |
|
|
constant data_C : std_logic_vector(3 downto 0) := C;
|
88 |
|
|
constant data_D : std_logic_vector(3 downto 0) := D;
|
89 |
|
|
|
90 |
|
|
constant zero_u : std_logic_vector(2 downto 0) := "000";
|
91 |
|
|
constant one_u : std_logic_vector(2 downto 0) := "001";
|
92 |
|
|
constant two_u : std_logic_vector(2 downto 0) := "010";
|
93 |
|
|
constant three_u : std_logic_vector(2 downto 0) := "011";
|
94 |
|
|
constant four_u : std_logic_vector(2 downto 0) := "100";
|
95 |
|
|
|
96 |
|
|
constant ETH : std_logic_vector(15 downto 0) := X"0000";-- => jump_addr_s <= init_eth;--X"0000";--ETH
|
97 |
|
|
constant ARP : std_logic_vector(15 downto 0) := X"0806";
|
98 |
|
|
constant IPv4 : std_logic_vector(15 downto 0) := X"0800";
|
99 |
|
|
constant IPv6 : std_logic_vector(15 downto 0) := X"86DD";
|
100 |
|
|
constant TCP : std_logic_vector(15 downto 0) := X"0006";
|
101 |
|
|
constant UDP : std_logic_vector(15 downto 0) := X"0011";
|
102 |
|
|
constant reg_num : integer := 128;
|
103 |
|
|
constant port_0 : std_logic_vector(15 downto 0) := X"0000";--0--0000
|
104 |
|
|
constant port_1 : std_logic_vector(15 downto 0) := X"0001";--1--0001
|
105 |
|
|
constant port_2 : std_logic_vector(15 downto 0) := X"0005";--5--0005
|
106 |
|
|
constant port_3 : std_logic_vector(15 downto 0) := X"0007";--7--0007
|
107 |
|
|
constant port_4 : std_logic_vector(15 downto 0) := X"0009";--9--0009
|
108 |
|
|
constant port_5 : std_logic_vector(15 downto 0) := X"000B";--11--000B
|
109 |
|
|
constant port_6 : std_logic_vector(15 downto 0) := X"000D";--13--000D
|
110 |
|
|
constant port_7 : std_logic_vector(15 downto 0) := X"0013";--19--0013
|
111 |
|
|
constant port_8 : std_logic_vector(15 downto 0) := X"0014";--20--0014
|
112 |
|
|
constant port_9 : std_logic_vector(15 downto 0) := X"0015";--21--0015
|
113 |
|
|
constant port_10 : std_logic_vector(15 downto 0) := X"0016";--22--0016
|
114 |
|
|
constant port_11 : std_logic_vector(15 downto 0) := X"0017";--23--0017
|
115 |
|
|
constant port_12 : std_logic_vector(15 downto 0) := X"0019";--25--0019
|
116 |
|
|
constant port_13 : std_logic_vector(15 downto 0) := X"0025";--37--0025
|
117 |
|
|
constant port_14 : std_logic_vector(15 downto 0) := X"0029";--41--0029
|
118 |
|
|
constant port_15 : std_logic_vector(15 downto 0) := X"002A";--42--002A
|
119 |
|
|
constant port_16 : std_logic_vector(15 downto 0) := X"002B";--43--002B
|
120 |
|
|
constant port_17 : std_logic_vector(15 downto 0) := X"0031";--49--0031
|
121 |
|
|
constant port_18 : std_logic_vector(15 downto 0) := X"0035";--53--0035
|
122 |
|
|
constant port_19 : std_logic_vector(15 downto 0) := X"0039";--57--0039
|
123 |
|
|
constant port_20 : std_logic_vector(15 downto 0) := X"0043";--67--0043
|
124 |
|
|
constant port_21 : std_logic_vector(15 downto 0) := X"0044";--68--0044
|
125 |
|
|
constant port_22 : std_logic_vector(15 downto 0) := X"0045";--69--0045
|
126 |
|
|
constant port_23 : std_logic_vector(15 downto 0) := X"0046";--70--0046
|
127 |
|
|
constant port_24 : std_logic_vector(15 downto 0) := X"004F";--79--004F
|
128 |
|
|
constant port_25 : std_logic_vector(15 downto 0) := X"0050";--80--0050
|
129 |
|
|
constant port_26 : std_logic_vector(15 downto 0) := X"0058";--88--0058
|
130 |
|
|
constant port_27 : std_logic_vector(15 downto 0) := X"0065";--101--0065
|
131 |
|
|
constant port_28 : std_logic_vector(15 downto 0) := X"006B";--107--006B
|
132 |
|
|
constant port_29 : std_logic_vector(15 downto 0) := X"006D";--109--006D
|
133 |
|
|
constant port_30 : std_logic_vector(15 downto 0) := X"006E";--110--006E
|
134 |
|
|
constant port_31 : std_logic_vector(15 downto 0) := X"0076";--118--0076
|
135 |
|
|
constant port_32 : std_logic_vector(15 downto 0) := X"0077";--119--0077
|
136 |
|
|
constant port_33 : std_logic_vector(15 downto 0) := X"007B";--123--007B
|
137 |
|
|
constant port_34 : std_logic_vector(15 downto 0) := X"008F";--143--008F
|
138 |
|
|
constant port_35 : std_logic_vector(15 downto 0) := X"009C";--156--009C
|
139 |
|
|
constant port_36 : std_logic_vector(15 downto 0) := X"00A1";--161--00A1
|
140 |
|
|
constant port_37 : std_logic_vector(15 downto 0) := X"00A2";--162--00A2
|
141 |
|
|
constant port_38 : std_logic_vector(15 downto 0) := X"00B3";--179--00B3
|
142 |
|
|
constant port_39 : std_logic_vector(15 downto 0) := X"00C2";--194--00C2
|
143 |
|
|
constant port_40 : std_logic_vector(15 downto 0) := X"016E";--366--016E
|
144 |
|
|
constant port_41 : std_logic_vector(15 downto 0) := X"0171";--369--0171
|
145 |
|
|
constant port_42 : std_logic_vector(15 downto 0) := X"0185";--389--0185
|
146 |
|
|
constant port_43 : std_logic_vector(15 downto 0) := X"01AB";--427--01AB
|
147 |
|
|
constant port_44 : std_logic_vector(15 downto 0) := X"01BB";--443--01BB
|
148 |
|
|
constant port_45 : std_logic_vector(15 downto 0) := X"01BD";--445--01BD
|
149 |
|
|
constant port_46 : std_logic_vector(15 downto 0) := X"01D0";--464--01D0
|
150 |
|
|
constant port_47 : std_logic_vector(15 downto 0) := X"0201";--513--0201
|
151 |
|
|
constant port_48 : std_logic_vector(15 downto 0) := X"0202";--514--0202
|
152 |
|
|
constant port_49 : std_logic_vector(15 downto 0) := X"021C";--540--021C
|
153 |
|
|
constant port_50 : std_logic_vector(15 downto 0) := X"021F";--543--021F
|
154 |
|
|
constant port_51 : std_logic_vector(15 downto 0) := X"0220";--544--0220
|
155 |
|
|
constant port_52 : std_logic_vector(15 downto 0) := X"0222";--546--0222
|
156 |
|
|
constant port_53 : std_logic_vector(15 downto 0) := X"0223";--547--0223
|
157 |
|
|
constant port_54 : std_logic_vector(15 downto 0) := X"022A";--554--022A
|
158 |
|
|
constant port_55 : std_logic_vector(15 downto 0) := X"0251";--593--0251
|
159 |
|
|
constant port_56 : std_logic_vector(15 downto 0) := X"027C";--636--027C
|
160 |
|
|
constant port_57 : std_logic_vector(15 downto 0) := X"0286";--646--0286
|
161 |
|
|
constant port_58 : std_logic_vector(15 downto 0) := X"0287";--647--0287
|
162 |
|
|
constant port_59 : std_logic_vector(15 downto 0) := X"02B3";--691--02B3
|
163 |
|
|
constant port_60 : std_logic_vector(15 downto 0) := X"02ED";--749--02ED
|
164 |
|
|
constant port_61 : std_logic_vector(15 downto 0) := X"02EE";--750--02EE
|
165 |
|
|
constant port_62 : std_logic_vector(15 downto 0) := X"030E";--782--030E
|
166 |
|
|
constant port_63 : std_logic_vector(15 downto 0) := X"033D";--829--033D
|
167 |
|
|
constant port_64 : std_logic_vector(15 downto 0) := X"0369";--873--0369
|
168 |
|
|
constant port_65 : std_logic_vector(15 downto 0) := X"03DD";--989--03DD
|
169 |
|
|
constant port_66 : std_logic_vector(15 downto 0) := X"03DE";--990--03DE
|
170 |
|
|
constant port_67 : std_logic_vector(15 downto 0) := X"03E0";--992--03E0
|
171 |
|
|
constant port_68 : std_logic_vector(15 downto 0) := X"03E1";--993--03E1
|
172 |
|
|
constant port_69 : std_logic_vector(15 downto 0) := X"03E3";--995--03E3
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
function count (signal cnt : in std_logic_vector) return std_logic_vector;
|
176 |
|
|
function minus (signal a : in std_logic_vector; signal b: in std_logic_vector) return std_logic_vector;
|
177 |
|
|
function power (signal count : in integer range 0 to 30) return std_logic_vector;
|
178 |
|
|
function myxor (signal l : in std_logic_vector; signal r : in std_logic_vector)return std_logic;
|
179 |
|
|
|
180 |
|
|
-- procedure <procedure_name> (<type_declaration> <constant_name> : in <type_declaration>);
|
181 |
|
|
--
|
182 |
|
|
end EmPAC_constants;
|
183 |
|
|
--
|
184 |
|
|
--
|
185 |
|
|
package body EmPAC_constants is
|
186 |
|
|
--
|
187 |
|
|
---- Example 1
|
188 |
|
|
function count (signal cnt : in std_logic_vector ) return std_logic_vector is
|
189 |
|
|
variable counter : std_logic_vector(17 downto 0);
|
190 |
|
|
begin
|
191 |
|
|
counter := (unsigned(cnt) - '1');
|
192 |
|
|
return counter;
|
193 |
|
|
end count;
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
function minus (signal a : in std_logic_vector; signal b: in std_logic_vector) return std_logic_vector is
|
198 |
|
|
variable av : std_logic_vector(15 downto 0);
|
199 |
|
|
variable bv : std_logic_vector(15 downto 0);
|
200 |
|
|
variable result : std_logic_vector(15 downto 0);
|
201 |
|
|
begin
|
202 |
|
|
av := a;
|
203 |
|
|
bv := b;
|
204 |
|
|
result := av-bv;
|
205 |
|
|
return result;
|
206 |
|
|
end minus;
|
207 |
|
|
|
208 |
|
|
function power (signal count : in integer range 0 to 30) return std_logic_vector is
|
209 |
|
|
variable cnt : integer range 0 to 30;
|
210 |
|
|
variable value : integer;
|
211 |
|
|
begin
|
212 |
|
|
cnt := count;
|
213 |
|
|
value := 2 ** count;
|
214 |
|
|
return conv_STD_LOGIC_VECTOR(value,31);
|
215 |
|
|
end power;
|
216 |
|
|
|
217 |
|
|
function myxor (signal l : in std_logic_vector; signal r : in std_logic_vector) return std_logic is
|
218 |
|
|
variable result : std_logic_vector(15 downto 0);
|
219 |
|
|
variable out_s : std_logic;
|
220 |
|
|
variable lv : std_logic_vector(15 downto 0);
|
221 |
|
|
variable rv : std_logic_vector(15 downto 0);
|
222 |
|
|
begin -- "xor"
|
223 |
|
|
for i in 0 to 15 loop
|
224 |
|
|
result(i) := l(i) xor r(i);
|
225 |
|
|
end loop;
|
226 |
|
|
if (result = X"0000") then
|
227 |
|
|
out_s := '1';
|
228 |
|
|
else out_s := '0';
|
229 |
|
|
end if;
|
230 |
|
|
return out_s;
|
231 |
|
|
end myxor;
|
232 |
|
|
|
233 |
|
|
--
|
234 |
|
|
end EmPAC_constants;
|