source: firmware/FTM/test_firmware/FTM_test2/FTM_test2_backup.vhd@ 11111

Last change on this file since 11111 was 10046, checked in by vogler, 14 years ago
Test firmware for FTM hardware testing
  • Property svn:executable set to *
File size: 16.9 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: P. Vogler, Q. Weitzel
4--
5-- Create Date: 13 October 2010
6-- Design Name:
7-- Module Name: FTU_test2 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Test firmware for FTM board:
12-- NIM and LVDS output stages
13-- fast signal distribution (partially)
14-- crate resets
15--
16--
17--
18-- Dependencies:
19--
20-- Revision:
21-- Revision 0.01 - File Created
22-- Additional Comments:
23--
24----------------------------------------------------------------------------------
25
26library IEEE;
27use IEEE.STD_LOGIC_1164.ALL;
28use IEEE.STD_LOGIC_ARITH.ALL;
29use IEEE.STD_LOGIC_UNSIGNED.ALL;
30
31---- Uncomment the following library declaration if instantiating
32---- any Xilinx primitives in this code.
33library UNISIM;
34use UNISIM.VComponents.all;
35
36entity FTM_test2 is
37 port(
38
39
40-- Clock
41 clk : IN STD_LOGIC; -- external clock from
42 -- oscillator U47
43
44-- connection to the WIZnet W5300 ethernet controller
45-- on IO-Bank 1
46-------------------------------------------------------------------------------
47 -- W5300 data bus
48-- W_D : inout STD_LOGIC_VECTOR(15 downto 0); -- 16-bit data bus to W5300
49
50
51 -- W5300 address bus
52-- W_A : out STD_LOGIC_VECTOR(9 downto 1); -- there is NO net W_A0 because
53 -- the W5300 is operated in the
54 -- 16-bit mode
55
56 -- W5300 controll signals
57 -- the signals W_INT, W_RD, W_WR and W_RES also go to testpoints T17
58 -- W_CS is also routed to testpoint JP7
59-- W_CS : out STD_LOGIC; -- W5300 chip select
60-- W_INT : IN STD_LOGIC; -- interrupt
61-- W_RD : out STD_LOGIC; -- read
62-- W_WR : out STD_LOGIC; -- write
63-- W_RES : out STD_LOGIC; -- reset W5300 chip
64
65 -- W5300 buffer ready indicator
66-- W_BRDY : in STD_LOGIC_VECTOR(3 downto 0);
67
68 -- testpoints (T18) associated with the W5300 on IO-bank 1
69-- W_T : inout STD_LOGIC_VECTOR(3 downto 0);
70
71
72
73-- SPI Interface
74-- connection to the EEPROM U36 (AL25L016M) and
75-- temperature sensors U45, U46, U48 and U49 (all MAX6662)
76-- on IO-Bank 1
77-------------------------------------------------------------------------------
78-- S_CLK : out STD_LOGIC; -- SPI clock
79
80 -- EEPROM
81-- MOSI : out STD_LOGIC; -- master out slave in
82-- MISO : in STD_LOGIC; -- master in slave out
83-- EE_CS : out STD_LOGIC; -- EEPROM chip select
84
85 -- temperature sensors U45, U46, U48 and U49
86-- SIO : inout STD_LOGIC; -- serial IO
87-- TS_CS : out STD_LOGIC_VECTOR(3 downto 0); -- temperature sensors chip select
88
89
90
91-- Trigger primitives inputs
92-- on IO-Bank 2
93-------------------------------------------------------------------------------
94-- Trig_Prim_A : in STD_LOGIC_VECTOR(9 downto 0); -- crate 0
95-- Trig_Prim_B : in STD_LOGIC_VECTOR(9 downto 0); -- crate 1
96-- Trig_Prim_C : in STD_LOGIC_VECTOR(9 downto 0); -- crate 2
97-- Trig_Prim_D : in STD_LOGIC_VECTOR(9 downto 0); -- crate 3
98
99
100
101-- NIM inputs
102------------------------------------------------------------------------------
103 -- on IO-Bank 3
104-- ext_Trig : in STD_LOGIC_VECTOR(2 downto 1); -- external trigger input
105-- Veto : in STD_LOGIC; -- trigger veto input
106-- NIM_In : in STD_LOGIC_VECTOR(2 downto 0); -- auxiliary inputs
107
108 -- on IO-Bank 0
109-- NIM_In3_GCLK : in STD_LOGIC; -- input with global clock buffer available
110
111
112
113-- LEDs on IO-Banks 0 and 3
114-------------------------------------------------------------------------------
115-- LED_red : out STD_LOGIC_VECTOR(3 downto 0); -- red
116-- LED_ye : out STD_LOGIC_VECTOR(1 downto 0); -- yellow
117-- LED_gn : out STD_LOGIC_VECTOR(1 downto 0); -- green
118
119
120
121-- Clock conditioner LMK03000
122-- on IO-Bank 3
123-------------------------------------------------------------------------------
124-- CLK_Clk_Cond : out STD_LOGIC; -- clock conditioner MICROWIRE interface clock
125-- LE_Clk_Cond : out STD_LOGIC; -- clock conditioner MICROWIRE interface latch enable
126-- DATA_Clk_Cond : out STD_LOGIC; -- clock conditioner MICROWIRE interface data
127
128-- SYNC_Clk_Cond : out STD_LOGIC; -- clock conditioner global clock synchronization
129-- LD_Clk_Cond : in STD_LOGIC; -- clock conditioner lock detect
130
131
132
133
134-- various RS-485 Interfaces
135-- on IO-Bank 3
136-------------------------------------------------------------------------------
137 -- Bus 1: FTU slow control
138-- Bus1_Tx_En : out STD_LOGIC; -- bus 1: transmitter enable
139-- Bus1_Rx_En : out STD_LOGIC; -- bus 1: receiver enable
140
141-- Bus1_RxD_0 : in STD_LOGIC; -- crate 0
142-- Bus1_TxD_0 : out STD_LOGIC;
143
144-- Bus1_RxD_1 : in STD_LOGIC; -- crate 1
145-- Bus1_TxD_1 : out STD_LOGIC;
146
147-- Bus1_RxD_2 : in STD_LOGIC; -- crate 2
148-- Bus1_TxD_2 : out STD_LOGIC;
149
150-- Bus1_RxD_3 : in STD_LOGIC; -- crate 3
151-- Bus1_TxD_3 : out STD_LOGIC;
152
153
154 -- Bus 2: Trigger-ID to FAD boards
155-- Bus2_Tx_En : out STD_LOGIC; -- bus 2: transmitter enable
156-- Bus2_Rx_En : out STD_LOGIC; -- bus 2: receiver enable
157
158-- Bus2_RxD_0 : in STD_LOGIC; -- crate 0
159-- Bus2_TxD_0 : out STD_LOGIC;
160
161-- Bus2_RxD_1 : in STD_LOGIC; -- crate 1
162-- Bus2_TxD_1 : out STD_LOGIC;
163
164-- Bus2_RxD_2 : in STD_LOGIC; -- crate 2
165-- Bus2_TxD_2 : out STD_LOGIC;
166
167-- Bus2_RxD_3 : in STD_LOGIC; -- crate 3
168-- Bus2_TxD_3 : out STD_LOGIC;
169
170
171-- auxiliary access
172-- Aux_Rx_D : in STD_LOGIC; --
173-- Aux_Tx_D : out STD_LOGIC; --
174-- Aux_Rx_En : out STD_LOGIC; -- Rx- and Tx enable
175-- Aux_Tx_En : out STD_LOGIC; -- also for auxiliary Trigger-ID
176
177
178-- auxiliary Trigger-ID (i.e. to send the Trigger-ID to the counting hut/house/container)
179-- TrID_Rx_D : in STD_LOGIC; --
180-- TrID_Tx_D : out STD_LOGIC; --
181
182
183-- Crate-Resets
184-- on IO-Bank 3
185-------------------------------------------------------------------------------
186 Crate_Res0 : out STD_LOGIC; --
187 Crate_Res1 : out STD_LOGIC; --
188 Crate_Res2 : out STD_LOGIC; --
189 Crate_Res3 : out STD_LOGIC; --
190
191
192-- Busy signals from the FAD boards
193-- on IO-Bank 3
194-------------------------------------------------------------------------------
195-- Busy0 : in STD_LOGIC; --
196-- Busy1 : in STD_LOGIC; --
197-- Busy2 : in STD_LOGIC; --
198-- Busy3 : in STD_LOGIC; --
199
200
201
202-- NIM outputs
203-- on IO-Bank 0
204-- LVDS output at the FPGA followed by LVDS to NIM conversion stage
205-------------------------------------------------------------------------------
206-- calibration
207 Cal_NIM1_p : out STD_LOGIC; -- Cal_NIM1+
208 Cal_NIM1_n : out STD_LOGIC; -- Cal_NIM1-
209 Cal_NIM2_p : out STD_LOGIC; -- Cal_NIM2+
210 Cal_NIM2_n : out STD_LOGIC; -- Cal_NIM2-
211
212-- auxiliarry / spare NIM outputs
213 NIM_Out0_p : out STD_LOGIC; -- NIM_Out0+
214 NIM_Out0_n : out STD_LOGIC; -- NIM_Out0-
215 NIM_Out1_p : out STD_LOGIC; -- NIM_Out1+
216 NIM_Out1_n : out STD_LOGIC; -- NIM_Out1-
217
218
219
220-- fast control signal outputs
221-- LVDS output at the FPGA followed by LVDS to NIM conversion stage
222-- conversion stage
223-------------------------------------------------------------------------------
224 RES_p : out STD_LOGIC; -- RES+ Reset
225 RES_n : out STD_LOGIC; -- RES- IO-Bank 0
226
227 TRG_p : out STD_LOGIC; -- TRG+ Trigger
228 TRG_n : out STD_LOGIC; -- TRG- IO-Bank 0
229
230 TIM_Run_p : out STD_LOGIC; -- TIM_Run+ Time Marker
231 TIM_Run_n : out STD_LOGIC; -- TIM_Run- IO-Bank 2
232 TIM_Sel : out STD_LOGIC; -- Time Marker selector on
233 -- IO-Bank 2
234
235-- CLD_FPGA : out STD_LOGIC; -- DRS-Clock feedback into FPGA
236
237
238
239-- LVDS calibration outputs
240-- on IO-Bank 0
241-------------------------------------------------------------------------------
242-- to connector J13
243 Cal_0_p : out STD_LOGIC;
244 Cal_0_n : out STD_LOGIC;
245 Cal_1_p : out STD_LOGIC;
246 Cal_1_n : out STD_LOGIC;
247 Cal_2_p : out STD_LOGIC;
248 Cal_2_n : out STD_LOGIC;
249 Cal_3_p : out STD_LOGIC;
250 Cal_3_n : out STD_LOGIC;
251
252-- to connector J12
253 Cal_4_p : out STD_LOGIC;
254 Cal_4_n : out STD_LOGIC;
255 Cal_5_p : out STD_LOGIC;
256 Cal_5_n : out STD_LOGIC;
257 Cal_6_p : out STD_LOGIC;
258 Cal_6_n : out STD_LOGIC;
259 Cal_7_p : out STD_LOGIC;
260 Cal_7_n : out STD_LOGIC
261
262
263-- Testpoints
264-------------------------------------------------------------------------------
265-- TP : inout STD_LOGIC_VECTOR(32 downto 0)
266-- TP_in : in STD_LOGIC_VECTOR(34 downto 33); -- input only
267
268-- Board ID - inputs
269-- local board-ID "solder programmable"
270-- all on 'input only' pins
271-------------------------------------------------------------------------------
272-- brd_id : in STD_LOGIC_VECTOR(7 downto 0) -- input only
273 );
274end FTM_test2;
275
276
277
278
279
280architecture Behavioral of FTM_test2 is
281
282 component FTM_test2_dcm
283 port ( CLKIN_IN : in std_logic;
284 CLKFX_OUT : out std_logic;
285 CLKIN_IBUFG_OUT : out std_logic);
286 end component;
287
288 component Clock_Divider
289 port(
290 clock : IN STD_LOGIC;
291 enable_out : OUT STD_LOGIC
292 );
293 end component;
294
295 component Clock_Divider_2
296 port(
297 clock : IN STD_LOGIC;
298 enable_out_2 : OUT STD_LOGIC
299 );
300 end component;
301
302
303 signal clk_200M_sig : STD_LOGIC;
304 signal enable_sig : STD_LOGIC;
305 signal enable_sig2 : STD_LOGIC;
306
307
308begin
309
310
311
312
313
314
315
316 OBUFDS_inst_TRG : OBUFDS
317 generic map (
318 IOSTANDARD => "DEFAULT")
319 port map (
320 O => TRG_p, -- Diff_p output (connect directly to top-level port)
321 OB => TRG_n, -- Diff_n output (connect directly to top-level port)
322 I => enable_sig2 -- Buffer input
323 );
324
325
326
327 OBUFDS_inst_RES : OBUFDS
328 generic map (
329 IOSTANDARD => "DEFAULT")
330 port map (
331 O => RES_p, -- Diff_p output (connect directly to top-level port)
332 OB => RES_n, -- Diff_n output (connect directly to top-level port)
333 I => enable_sig2 -- Buffer input
334 );
335
336
337
338 OBUFDS_inst_TIM : OBUFDS
339 generic map (
340 IOSTANDARD => "DEFAULT")
341 port map (
342 O => TIM_Run_p, -- Diff_p output (connect directly to top-level port)
343 OB => TIM_Run_n, -- Diff_n output (connect directly to top-level port)
344 I => enable_sig2 -- Buffer input
345 );
346
347 TIM_Sel <= '0';
348
349 Crate_Res0 <= enable_sig;
350 Crate_Res1 <= enable_sig;
351 Crate_Res2 <= enable_sig;
352 Crate_Res3 <= enable_sig;
353
354
355
356
357
358 OBUFDS_inst_Cal_NIM1 : OBUFDS
359 generic map (
360 IOSTANDARD => "DEFAULT")
361 port map (
362 O => Cal_NIM1_p, -- Diff_p output (connect directly to top-level port)
363 OB => Cal_NIM1_n, -- Diff_n output (connect directly to top-level port)
364 I => enable_sig2 -- Buffer input
365 );
366
367
368 OBUFDS_inst_Cal_NIM2 : OBUFDS
369 generic map (
370 IOSTANDARD => "DEFAULT")
371 port map (
372 O => Cal_NIM2_p, -- Diff_p output (connect directly to top-level port)
373 OB => Cal_NIM2_n, -- Diff_n output (connect directly to top-level port)
374 I => not enable_sig2 -- Buffer input
375 );
376
377
378
379
380 OBUFDS_inst_NIM_Out0 : OBUFDS
381 generic map (
382 IOSTANDARD => "DEFAULT")
383 port map (
384 O => NIM_Out0_p, -- Diff_p output (connect directly to top-level port)
385 OB => NIM_Out0_n, -- Diff_n output (connect directly to top-level port)
386 I => enable_sig2 -- Buffer input
387 );
388
389
390 OBUFDS_inst_NIM_Out1 : OBUFDS
391 generic map (
392 IOSTANDARD => "DEFAULT")
393 port map ( O => NIM_Out1_p, -- Diff_p output (connect directly to top-level port)
394 OB => NIM_Out1_n, -- Diff_n output (connect directly to top-level port)
395 I => enable_sig2 -- Buffer input
396 );
397
398
399
400
401
402 OBUFDS_inst_Cal_0 : OBUFDS
403 generic map (
404 IOSTANDARD => "DEFAULT")
405 port map ( O => Cal_0_p , -- Diff_p output (connect directly to top-level port)
406 OB => Cal_0_n , -- Diff_n output (connect directly to top-level port)
407 I => enable_sig2 -- Buffer input
408 );
409
410 OBUFDS_inst_Cal_1 : OBUFDS
411 generic map (
412 IOSTANDARD => "DEFAULT")
413 port map ( O => Cal_1_p , -- Diff_p output (connect directly to top-level port)
414 OB => Cal_1_n , -- Diff_n output (connect directly to top-level port)
415 I => enable_sig2 -- Buffer input
416 );
417
418 OBUFDS_inst_Cal_2 : OBUFDS
419 generic map (
420 IOSTANDARD => "DEFAULT")
421 port map ( O => Cal_2_p , -- Diff_p output (connect directly to top-level port)
422 OB => Cal_2_n , -- Diff_n output (connect directly to top-level port)
423 I => enable_sig2 -- Buffer input
424 );
425
426 OBUFDS_inst_Cal_3 : OBUFDS
427 generic map (
428 IOSTANDARD => "DEFAULT")
429 port map ( O => Cal_3_p , -- Diff_p output (connect directly to top-level port)
430 OB => Cal_3_n , -- Diff_n output (connect directly to top-level port)
431 I => enable_sig2 -- Buffer input
432 );
433
434 OBUFDS_inst_Cal_4 : OBUFDS
435 generic map (
436 IOSTANDARD => "DEFAULT")
437 port map ( O => Cal_4_p , -- Diff_p output (connect directly to top-level port)
438 OB => Cal_4_n , -- Diff_n output (connect directly to top-level port)
439 I => enable_sig2 -- Buffer input
440 );
441
442 OBUFDS_inst_Cal_5 : OBUFDS
443 generic map (
444 IOSTANDARD => "DEFAULT")
445 port map ( O => Cal_5_p , -- Diff_p output (connect directly to top-level port)
446 OB => Cal_5_n , -- Diff_n output (connect directly to top-level port)
447 I => enable_sig2 -- Buffer input
448 );
449
450 OBUFDS_inst_Cal_6 : OBUFDS
451 generic map (
452 IOSTANDARD => "DEFAULT")
453 port map ( O => Cal_6_p , -- Diff_p output (connect directly to top-level port)
454 OB => Cal_6_n , -- Diff_n output (connect directly to top-level port)
455 I => enable_sig2 -- Buffer input
456 );
457
458 OBUFDS_inst_Cal_7 : OBUFDS
459 generic map (
460 IOSTANDARD => "DEFAULT")
461 port map ( O => Cal_7_p , -- Diff_p output (connect directly to top-level port)
462 OB => Cal_7_n , -- Diff_n output (connect directly to top-level port)
463 I => enable_sig2 -- Buffer input
464 );
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482 Inst_FTU_test2_dcm : FTM_test2_dcm
483 port map(
484 CLKIN_IN => clk,
485 CLKFX_OUT => clk_200M_sig,
486 CLKIN_IBUFG_OUT => open
487 );
488
489
490 Inst_Clock_Divider : Clock_Divider
491 port map (
492 clock => clk_200M_sig,
493 enable_out => enable_sig
494 );
495
496
497 Inst_Clock_Divider_2 : Clock_Divider_2
498 port map (
499 clock => clk_200M_sig,
500 enable_out_2 => enable_sig2
501 );
502
503
504
505
506end Behavioral;
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536library IEEE;
537use IEEE.STD_LOGIC_1164.ALL;
538use IEEE.STD_LOGIC_ARITH.ALL;
539use IEEE.STD_LOGIC_UNSIGNED.ALL;
540
541entity Clock_Divider is
542 port(
543 clock : in std_logic;
544 enable_out: out std_logic
545 );
546end entity Clock_Divider;
547
548architecture RTL of Clock_Divider is
549
550 --constant max_count : integer := 5000000/1000000; -- for simulation
551 constant max_count : integer := 250000/1; -- for implementation
552-- constant final_count : integer := 100;
553
554begin
555
556 process(clock)
557 variable count : integer range 0 to max_count;
558-- variable count2 : integer range 0 to final_count;
559 begin
560 if rising_edge(clock) then
561 --enable_out <= '0';
562-- if count2 = final_count then
563-- enable_out <= '0';
564-- else
565 if count < max_count/2 then
566 enable_out <= '0';
567 count := count + 1;
568 elsif count < max_count then
569 enable_out <= '1';
570 count := count + 1;
571 else
572 count := 0;
573 enable_out <= '0';
574-- count2 := count2 + 1;
575 end if;
576-- end if;
577 end if;
578 end process;
579
580end architecture RTL;
581
582
583
584
585
586entity Clock_Divider_2 is
587 port(
588 clock : in std_logic;
589 enable_out_2 : out std_logic
590 );
591end entity Clock_Divider_2;
592
593architecture RTL of Clock_Divider_2 is
594
595constant max_count_2 : integer := 200/1; -- for implementation
596
597begin
598
599 process(clock)
600 variable count_2 : integer range 0 to max_count_2;
601
602 begin
603 if rising_edge(clock) then
604 if count_2 < max_count_2/2 then
605 enable_out_2 <= '0';
606 count_2 := count + 1;
607 elsif count_2 < max_count then
608 enable_out_2 <= '1';
609 count_2 := count_2 + 1;
610 else
611 count_2 := 0;
612 enable_out_2 <= '0';
613 end if;
614 end if;
615 end process;
616
617end architecture RTL;
Note: See TracBrowser for help on using the repository browser.