source: firmware/FAD/FAD_svn_revision_number/FACT_FAD_lib/hdl/fad_definitions.vhd.bak@ 9914

Last change on this file since 9914 was 9914, checked in by neise, 16 years ago
initial commit of version with svn revision as event package type
File size: 8.4 KB
Line 
1-- Package File Template
2--
3-- Purpose: This package defines supplemental types, subtypes,
4-- constants, and functions
5
6
7library IEEE;
8use IEEE.STD_LOGIC_1164.all;
9use IEEE.STD_LOGIC_ARITH.ALL;
10use IEEE.STD_LOGIC_UNSIGNED.ALL;
11use std.textio.all;
12use work.txt_util.all;
13
14
15-- use IEEE.NUMERIC_STD.ALL;
16
17package fad_definitions is
18
19 function str_to_int( s : string )
20 return integer;
21-- Declare constants
22
23 type mac_type is array (0 to 2) of std_logic_vector (15 downto 0);
24 type ip_type is array (0 to 3) of integer;
25-- Network Settings
26
27 constant MAC_ADDRESS : mac_type := (X"0011", X"9561", X"97B4");
28
29 -- @ ETH zurich
30-- constant NETMASK : ip_type := (255, 255, 248, 0);
31-- constant IP_ADDRESS : ip_type := (192, 33, 99, 225);
32-- constant GATEWAY : ip_type := (192, 33, 96, 1);
33
34 -- @ TU Dortmund
35 constant NETMASK : ip_type := (255, 255, 255, 0);
36 constant IP_ADDRESS : ip_type := (129, 217, 160, 119);
37 constant GATEWAY : ip_type := (129, 217, 160, 1);
38
39 constant FIRST_PORT : integer := 5000;
40-- Network Settings End
41
42 constant SUBVERSION_LONGSTRING : string := "$Rev$:: $";
43 constant SUBVERSION_STRING : string := SUBVERSION_LONGSTRING(9 to 18); -- cut off starting "$Rev$:: " and trailing "$"
44 constant SUBVERSION_NUMBER : std_logic_vector (15 downto 0) := conv_std_logic_vector(str_to_int(SUBVERSION_STRING),16);
45 constant PACKAGE_VERSION : std_logic_vector(7 downto 0) := X"01";
46 constant PACKAGE_SUB_VERSION : std_logic_vector(7 downto 0) := X"02";
47 constant PACKAGE_HEADER_LENGTH : integer := 22;
48 constant PACKAGE_END_LENGTH : integer := 2; -- CRC and END-Flag
49
50 constant W5300_S_INC : std_logic_vector(6 downto 0) := "1000000"; -- socket address offset
51
52-- W5300 Registers
53 constant W5300_BASE_ADR : std_logic_vector (9 downto 0) := (others => '0');
54 constant W5300_MR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"0";
55 constant W5300_IR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"2";
56 constant W5300_IMR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"4";
57 constant W5300_SHAR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"8";
58 constant W5300_GAR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"10";
59 constant W5300_SUBR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"14";
60 constant W5300_SIPR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"18";
61 constant W5300_RTR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"1C";
62 constant W5300_RCR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"1E";
63 constant W5300_TMS01R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"20";
64 constant W5300_TMS23R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"22";
65 constant W5300_TMS45R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"24";
66 constant W5300_TMS67R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"26";
67 constant W5300_RMS01R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"28";
68 constant W5300_RMS23R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"2A";
69 constant W5300_RMS45R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"2C";
70 constant W5300_RMS67R : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"2E";
71 constant W5300_MTYPER : std_logic_vector (9 downto 0) := W5300_BASE_ADR + X"30";
72
73 constant W5300_S0_MR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"0";
74 constant W5300_S0_CR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"2";
75 constant W5300_S0_IMR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"4";
76 constant W5300_S0_IR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"6";
77 constant W5300_S0_SSR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"8";
78 constant W5300_S0_PORTR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"A";
79 constant W5300_S0_DPORTR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"12";
80 constant W5300_S0_DIPR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"14";
81 constant W5300_S0_TX_WRSR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"20";
82 constant W5300_S0_TX_FSR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"24";
83 constant W5300_S0_RX_RSR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"28";
84 constant W5300_S0_TX_FIFOR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"2E";
85 constant W5300_S0_RX_FIFOR : std_logic_vector (9 downto 0) := W5300_BASE_ADR + "1000000000" + X"30";
86-- End W5300 registers
87
88--
89 constant W5300_TX_FIFO_SIZE : integer := (15360 / 2); -- Socket TX FIFO-Size in 16 Bit Words
90
91 constant LOG2_OF_RAM_SIZE_64B : integer := 15;
92 --constant RAM_SIZE_64B : integer := 2**LOG2_OF_RAM_SIZE_64B;
93 constant RAM_SIZE_64B : integer := 24576;
94 constant RAM_SIZE_16B : integer := RAM_SIZE_64B * 4;
95
96-- TYPE definitions
97 type roi_max_type is array (0 to 8) of std_logic_vector (10 downto 0);
98 type roi_array_type is array (0 to 35) of integer range 0 to 1024;
99 type drs_s_cell_array_type is array (0 to 3) of std_logic_vector (9 downto 0);
100 type adc_data_array_type is array (0 to 3) of std_logic_vector (11 downto 0);
101
102 type dac_array_type is array (0 to 7) of integer range 0 to 2**16 - 1;
103 type sensor_array_type is array (0 to 3) of integer range 0 to 2**16 - 1;
104
105-- constant DEFAULT_ROI : roi_array_type := (115, 125, 100, 102, 155, 101, 0, 101, 106,
106-- 181, 121, 189, 101, 101, 187, 56, 187, 101,
107-- 2, 141, 101, 100, 10, 100, 178, 101, 174,
108-- 12, 181, 100, 102, 101, 102, 0, 101, 108);
109-- constant DEFAULT_ROI : roi_array_type := (others => 100);
110 constant DEFAULT_ROI : roi_array_type := (others => 210);
111
112 constant DEFAULT_DAC : dac_array_type := (20972, 34079, 20526, 0, 28836, 28836, 28836, 28836);
113 --constant DEFAULT_DAC : dac_array_type := (others => 0);
114
115 constant DEFAULT_DRSADDR : std_logic_vector (3 downto 0):= "0000";
116 constant DEFAULT_DRSADDR_MODE : std_logic := '0';
117
118
119
120-- Commands
121 constant CMD_START : std_logic_vector := X"C0";
122 constant CMD_STOP : std_logic_vector := X"30";
123 constant CMD_TRIGGER : std_logic_vector := X"A0";
124
125 constant CMD_TRIGGER_C : std_logic_vector := X"B0";
126 constant CMD_TRIGGER_S : std_logic_vector := X"20";
127 constant CMD_READ : std_logic_vector := X"0A";
128 constant CMD_WRITE : std_logic_vector := X"05";
129
130 constant CMD_DENABLE : std_logic_vector := X"06";
131 constant CMD_DDISABLE : std_logic_vector := X"07";
132 constant CMD_DWRITE_RUN : std_logic_vector := X"08";
133 constant CMD_DWRITE_STOP : std_logic_vector := X"09";
134 constant CMD_SCLK_ON : std_logic_vector := X"10";
135 constant CMD_SCLK_OFF : std_logic_vector := X"11";
136
137 constant CMD_PS_DIRINC : std_logic_vector := X"12";
138 constant CMD_PS_DIRDEC : std_logic_vector := X"13";
139 constant CMD_PS_DO : std_logic_vector := X"14";
140
141constant CMD_SRCLK_ON : std_logic_vector := X"15";
142constant CMD_SRCLK_OFF : std_logic_vector := X"16";
143
144constant CMD_PS_RESET : std_logic_vector := X"17";
145
146
147
148-- Declare functions and procedure
149
150
151
152end fad_definitions;
153
154package body fad_definitions is
155
156 function str_to_int( s : string )
157 return integer is
158 variable len : integer := s'length;
159 variable ivalue : integer := 0;
160 variable digit : integer;
161 begin
162 for i in 1 to len loop
163 case s(i) is
164 when '0' =>
165 digit := 0;
166 when '1' =>
167 digit := 1;
168 when '2' =>
169 digit := 2;
170 when '3' =>
171 digit := 3;
172 when '4' =>
173 digit := 4;
174 when '5' =>
175 digit := 5;
176 when '6' =>
177 digit := 6;
178 when '7' =>
179 digit := 7;
180 when '8' =>
181 digit := 8;
182 when '9' =>
183 digit := 9;
184 when ' ' =>
185 next; -- in subversion string number is followed by trailing white spaces
186 when others =>
187 ASSERT FALSE
188 REPORT "Illegal Character "& s(i) & "in string parameter! "
189 SEVERITY ERROR;
190 end case;
191 ivalue := ivalue * 10 + digit;
192 ASSERT FALSE
193 REPORT "ivalue: " & str(ivalue)& "inputstring: " &s&"digit:" & str(digit)
194 SEVERITY WARNING;
195
196
197
198 end loop;
199 -- debugging only
200 ASSERT FALSE
201 REPORT "ivalue: " & str(ivalue) &"inputstring: " & s & "digit:" & str(digit)
202 SEVERITY ERROR;
203
204 return ivalue;
205 end;
206
207end fad_definitions;
208
209
210
Note: See TracBrowser for help on using the repository browser.