2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
5 use work.lx_dad_pkg.all;
12 reset_i : in std_logic;
16 phi_1 : out std_logic;
17 phi_2 : out std_logic;
18 phi_st : out std_logic;
19 ph_rst : out std_logic;
21 sck_o : out std_logic;
22 cnv_o : out std_logic;
25 mem_o : out std_logic_vector(31 downto 0);
27 --memory related outputs
28 addr_o : out std_logic_vector(10 downto 0);
29 bls_o : out std_logic_vector(3 downto 0);
34 addr_i : in std_logic_vector(1 downto 0);
35 data_i : in std_logic_vector(31 downto 0);
37 bls_i : in std_logic_vector(3 downto 0);
38 data_o : out std_logic_vector(31 downto 0)
43 architecture rtl of clockgen is
45 --constant CLK_MASTER_FREQ: unsigned := 50000000;
47 signal cntra : unsigned(15 downto 0) := (others => '0');
48 signal pixel : integer range 0 to 1024;
50 signal bank : std_logic;
52 signal run_readout : std_logic;
53 signal conv_start : std_logic;
54 signal adc_data_i : std_logic_vector(17 downto 0);
55 signal adc_drdy_i : std_logic;
57 type states_i is (i0, i1, i2, i3, i4, i5, i6, i7, i8);
58 signal state_i : states_i;
60 signal t1 : unsigned(15 downto 0);
61 signal t2 : unsigned(15 downto 0);
62 signal t3 : unsigned(15 downto 0);
63 signal t4 : unsigned(15 downto 0);
64 signal t5 : unsigned(15 downto 0);
65 signal t6 : unsigned(15 downto 0);
66 signal t7 : unsigned(15 downto 0);
68 signal t1_i : std_logic_vector(15 downto 0);
69 signal t2_i : std_logic_vector(15 downto 0);
70 signal t3_i : std_logic_vector(15 downto 0);
71 signal t4_i : std_logic_vector(15 downto 0);
72 signal t5_i : std_logic_vector(15 downto 0);
73 signal t6_i : std_logic_vector(15 downto 0);
74 signal t7_i : std_logic_vector(15 downto 0);
77 signal alive_cntr : integer range 0 to 24999999:=0;
78 signal LED_latch : std_logic:='1';
82 snsor_adc_interface:lx_adc_if
92 conv_start => conv_start,
103 wait until clk_i'event and clk_i = '1';
104 if reset_i = '1' then
109 if adc_drdy_i = '1' then
110 mem_o <= std_logic_vector(resize(unsigned(adc_data_i), mem_o'length));
111 addr_o <= bank & std_logic_vector(to_unsigned((pixel-1),10));
122 wait until clk_i'event and clk_i = '1';
123 if reset_i = '1' then -- set default timing
124 t1 <= "0000000000000010"; --2
125 t2 <= "0000000000001001"; --9
126 t3 <= "0000010001111101"; --1149
127 t4 <= "0000000000001110"; --14
128 t5 <= "0000000000000010"; --2
129 t6 <= "0000001001010111"; --599
130 t7 <= "0000001010010010"; --658
131 t1_i <= "0000000000000010"; --2
132 t2_i <= "0000000000001001"; --9
133 t3_i <= "0000010001111101"; --1149
134 t4_i <= "0000000000001110"; --14
135 t5_i <= "0000000000000010"; --2
136 t6_i <= "0000001001010111"; --599
137 t7_i <= "0000001010010010"; --658
138 data_o <= (others => '0');
140 elsif ce_i = '1' and bls_i /= "0000" then
141 if addr_i = "00" then
142 t1_i <= data_i(15 downto 0);
143 t2_i <= data_i(31 downto 16);
144 elsif addr_i = "01" then
145 t3_i <= data_i(15 downto 0);
146 t4_i <= data_i(31 downto 16);
147 elsif addr_i = "10" then
148 t5_i <= data_i(15 downto 0);
149 t6_i <= data_i(31 downto 16);
150 elsif addr_i = "11" then
151 run_readout <= data_i(30); --start/stop the readout
152 if data_i(31) = '1' then --update timing constnts
153 t1 <= unsigned(t1_i);
154 t2 <= unsigned(t2_i);
155 t3 <= unsigned(t3_i);
156 t4 <= unsigned(t4_i);
157 t5 <= unsigned(t5_i);
158 t6 <= unsigned(t6_i);
159 t7 <= unsigned(t7_i);
161 t7_i <= data_i(15 downto 0);
165 if addr_i = "11" then
166 data_o <= (others => '0');
167 data_o(0) <= not bank;
172 proc : process(clk_i, reset_i)
176 cntra <= (others => '0');
179 elsif rising_edge(clk_i) then
181 -- if start_readout = '1' then
214 -- start the readout from adc
216 if run_readout = '1' and pixel = 0 then
229 cntra <= (others => '0');
232 -- cntrb <= cntrb + 1;
240 alive : process(clk_i,reset_i)
242 if reset_i = '1' then
246 elsif rising_edge(clk_i) then
247 alive_cntr<=alive_cntr+1;
248 if alive_cntr = 24999999 then
249 LED_latch <= not LED_latch;