source: FPGA/FTU/test_firmware/FTU_test4/FTU_test4.vhd@ 7724

Last change on this file since 7724 was 244, checked in by qweitzel, 14 years ago
FTU_test4 added to check tx line of RS485
File size: 4.7 KB
Line 
1----------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: P. Vogler, Q. Weitzel
4--
5-- Create Date: 08/07/2010
6-- Design Name:
7-- Module Name: FTU_test4 - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Test firmware for FTU board, enable tx and put 50kHz clock signal
12--
13-- Dependencies:
14--
15-- Revision:
16-- Revision 0.01 - File Created
17-- Additional Comments:
18--
19----------------------------------------------------------------------------------
20
21library IEEE;
22use IEEE.STD_LOGIC_1164.ALL;
23use IEEE.STD_LOGIC_ARITH.ALL;
24use IEEE.STD_LOGIC_UNSIGNED.ALL;
25
26---- Uncomment the following library declaration if instantiating
27---- any Xilinx primitives in this code.
28--library UNISIM;
29--use UNISIM.VComponents.all;
30
31entity FTU_test4 is
32 port(
33 -- global control
34 ext_clk : IN STD_LOGIC; -- external clock from FTU board
35 --reset : in STD_LOGIC; -- reset
36 brd_add : IN STD_LOGIC_VECTOR(5 downto 0); -- geographic board/slot address
37 brd_id : IN STD_LOGIC_VECTOR(7 downto 0); -- local solder-programmable board ID
38
39 -- rate counters LVDS inputs
40 -- use IBUFDS differential input buffer
41 patch_A_p : IN STD_LOGIC; -- logic signal from first trigger patch
42 patch_A_n : IN STD_LOGIC;
43 patch_B_p : IN STD_LOGIC; -- logic signal from second trigger patch
44 patch_B_n : IN STD_LOGIC;
45 patch_C_p : IN STD_LOGIC; -- logic signal from third trigger patch
46 patch_C_n : IN STD_LOGIC;
47 patch_D_p : IN STD_LOGIC; -- logic signal from fourth trigger patch
48 patch_D_n : IN STD_LOGIC;
49 trig_prim_p : IN STD_LOGIC; -- logic signal from n-out-of-4 circuit
50 trig_prim_n : IN STD_LOGIC;
51
52 -- DAC interface
53 -- miso : IN STD_LOGIC; -- master-in-slave-out
54 sck : OUT STD_LOGIC; -- serial clock to DAC
55 mosi : OUT STD_LOGIC; -- serial data to DAC, master-out-slave-in
56 clr : OUT STD_LOGIC; -- clear signal to DAC
57 cs_ld : OUT STD_LOGIC; -- chip select or load to DAC
58
59 -- RS-485 interface to FTM
60 rx : IN STD_LOGIC; -- serial data from FTM
61 tx : OUT STD_LOGIC; -- serial data to FTM
62 rx_en : OUT STD_LOGIC; -- enable RS-485 receiver
63 tx_en : OUT STD_LOGIC; -- enable RS-485 transmitter
64
65 -- analog buffer enable
66 enables_A : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
67 enables_B : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
68 enables_C : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
69 enables_D : OUT STD_LOGIC_VECTOR(8 downto 0); -- individual enables for analog inputs
70
71 -- testpoints
72 TP_A : out STD_LOGIC_VECTOR(11 downto 0) -- testpoints
73 );
74end FTU_test4;
75
76architecture Behavioral of FTU_test4 is
77
78 component FTU_test4_dcm
79 port(
80 CLKIN_IN : IN STD_LOGIC;
81 CLKFX_OUT : OUT STD_LOGIC;
82 CLKIN_IBUFG_OUT : OUT STD_LOGIC
83 );
84 end component;
85
86 component Clock_Divider
87 port(
88 clock_in : IN STD_LOGIC;
89 clock_out : OUT STD_LOGIC
90 );
91 end component;
92
93 signal clk_5M_sig : STD_LOGIC;
94 signal clk_50k_sig : STD_LOGIC;
95
96begin
97
98 Inst_FTU_test4_dcm : FTU_test4_dcm
99 port map(
100 CLKIN_IN => ext_clk,
101 CLKFX_OUT => clk_5M_sig,
102 CLKIN_IBUFG_OUT => open
103 );
104
105 Inst_Clock_Divider : Clock_Divider
106 port map (
107 clock_in => clk_5M_sig,
108 clock_out => clk_50k_sig
109 );
110
111 tx_en <= '1';
112 tx <= clk_50k_sig;
113
114end Behavioral;
115
116
117library IEEE;
118use IEEE.STD_LOGIC_1164.ALL;
119use IEEE.STD_LOGIC_ARITH.ALL;
120use IEEE.STD_LOGIC_UNSIGNED.ALL;
121
122entity Clock_Divider is
123 port(
124 clock_in : in std_logic;
125 clock_out : out std_logic
126 );
127end entity Clock_Divider;
128
129architecture RTL of Clock_Divider is
130
131 constant max_count : integer := 5000000/50000; -- for implementation
132
133begin
134
135 process(clock_in)
136 variable count : integer range 0 to max_count;
137 begin
138 if rising_edge(clock_in) then
139 if count < max_count/2 then
140 clock_out <= '0';
141 count := count + 1;
142 elsif count < max_count then
143 clock_out <= '1';
144 count := count + 1;
145 else
146 count := 0;
147 clock_out <= '0';
148 end if;
149 end if;
150 end process;
151
152end architecture RTL;
Note: See TracBrowser for help on using the repository browser.