2 use ieee.std_logic_1164.
all;
3 use ieee.std_logic_unsigned.
all;
4 use ieee.numeric_std.
all;
6 use unisim.vcomponents.
all;
27 -- 1) generating SSTin using clock-counter probably not ideal. Should consider 28 -- using a divided clock from the pll_base. 30 ------------------------------------------------------------------------------- 35 clk : in ;
--expect input clock to be 8xSST = 62.5 MHz (now it is 127 MHz) 36 reset : in := '0';
-- reset chip counters, it will reset the main counter and tells the TX chip to do so 38 ana_wr_ena_mask : in TARGETX_analong_wr_ena_mask_t;
-- ena & sel & win_start(8:0) & N_win(2:0) 40 cur_win : out (8 downto 0) := (others=>'0');
--COL & ROW write address- we just need this to keep track of the last sample taken 41 BUSA_WR_ADDRCLR : out := '0';
-- write address clear -- when asserted, it will reset the row and col on the TX chip 42 BUSB_WR_ADDRCLR : out := '0';
-- write address clear -- when asserted, it will reset the row and col on the TX chip 43 WR1_ENA : out (9 downto 0) := (others=>'1');
-- Enable Write 1 procedure 44 WR2_ENA : out (9 downto 0) := (others=>'1');
-- Enable Write 2 procedure 46 SSTIN_N : out (9 downto 0) := (others=>'0');
--SCA control signals 47 SSTIN_p : out (9 downto 0) := (others=>'1') --SCA control signals 54 --state machine drives SAMPLING logic signals directly 59 signal analog_store_state : state_type := RESETTING;
61 -- current write address 62 signal cur_win_i : (8 downto 0) := "000000000";
65 signal SSTIN_i : := '0';
--SCA control signals 66 signal wr_addrclr_i : := '0';
--Clear Write Address Counter 67 -- signal wr_ena : std_logic := '1'; --Enable Write procedure 68 signal wr_ena : (9 downto 0) := (others => '1');
70 signal clk_cntr : (2 downto 0) := (others=>'0');
72 signal wr_ena_mask : (511 downto 0) := (others=>'1');
74 signal i_reset : := '0';
77 -------------------------------------------------------------------------------- 81 process(clk, cur_win_i)
83 if rising_edge(clk) then 84 cur_win <= (cur_win_i(8 downto 0));
--output only row + colum sections 92 ena => ana_wr_ena_mask.ena,
93 new_bit => ana_wr_ena_mask.mask_bit,
94 win_start => ana_wr_ena_mask.win_start,
95 N_win => ana_wr_ena_mask.n_win,
96 wr_ena_mask => wr_ena_mask
100 -- latch reset to local domain 103 if rising_edge(clk) then 110 SSTIN_PROC :
process(clk, clk_cntr)
112 if rising_edge(clk) then 113 clk_cntr <= clk_cntr + "001";
114 SSTIN_i <= clk_cntr(2);
-- clk is 127 MHz now, SSTIN period is clk*4 116 end process SSTIN_PROC;
120 -- Assert mask on write-enable pins 121 process(clk, wr_ena_mask, cur_win_i)
123 if (rising_edge(clk)) then 125 wr_ena(i) <= wr_ena_mask(to_integer(cur_win_i));
134 process(clk, cur_win_i, i_reset, SSTIN_i, clk_cntr)
136 if (rising_edge(clk)) then 137 if (i_reset='1') then 139 cur_win_i <= (others=>'0');
140 analog_store_state <= RESETTING;
-- do a one time thing to bring the counter up at the correct phase 142 case analog_store_state is 145 cur_win_i <= (others=>'0');
146 -- if ( clk_cntr(1 downto 0) = cfg_i(1 downto 0) ) then 147 if (SSTIN_i = '0' and clk_cntr(2) = '1') then -- rising edge of sstin 149 analog_store_state <= SAMPLING;
151 --keep wr_addrclr high for afew clock cycles. 153 analog_store_state <= RESETTING;
158 -- if (clk_cntr(1 downto 0) = "01" or clk_cntr(1 downto 0) = "11") then 159 if ( SSTIN_i = '0' and clk_cntr(2) = '1') or (SSTIN_i = '1' and clk_cntr(2) = '0') then -- rising or falling 160 cur_win_i <= cur_win_i + 1;
162 cur_win_i <= cur_win_i;
164 analog_store_state <= SAMPLING;
167 cur_win_i <= (others => '-');
168 analog_store_state <= SAMPLING;
174 BUSA_WR_ADDRCLR <= wr_addrclr_i;
175 BUSB_WR_ADDRCLR <= wr_addrclr_i;
177 GEN_SSTIN : for i in 0 to 9 generate 178 obuf_ds_sstin_i : OBUFDS
port map ( i => SSTIN_i, o => SSTIN_P
(i
), ob => SSTIN_N
(i
));