-- Test pulse generator steered through -- the CAMAC dataway. Version 1. Started -- 16.05.04. Copyright I.Tsurin FLNR JINR. -- Module functions: -------------------------------------------- -- NA(I)F(0) - read group #1 registers; -- NA(J)F(1) - read group #2 registers; -- NA(I)F(9) - set group #1 defaults; -- NA(J)F(11) - set group #2 defaults; -- NA(I)F(16) - overwrite group #1 registers; -- NA(J)F(17) - overwrite group #2 registers; -- NA(K)F(24) - disable generator channels; -- NA(K)F(26) - enable generator channels; -- NA(K)F(27) - test generator channels; -------------------------------------------- -- Group #1 (I) registers: -------------------------------------------- -- Frequency (RW) A(0)F(0)/F(16) - event frequency; -- Scaling1 (RW) A(1)F(0)/F(16) - scaling factor for the left arm; -- Scaling2 (RW) A(2)F(0)/F(16) - scaling factor for the right arm; -- S1_MIN (RW) A(3)F(0)/F(16) - minimum delay of the left arm start; -- S1_MAX (RW) A(4)F(0)/F(16) - maximum delay of the left arm start; -- S2_MIN (RW) A(5)F(0)/F(16) - minimum delay of the right arm start; -- S2_MAX (RW) A(6)F(0)/F(16) - maximum delay of the right arm start; -- T1_MIN (RW) A(7)F(0)/F(16) - minimum TOF in the left arm; -- T1_MAX (RW) A(8)F(0)/F(16) - maximum TOF in the left arm; -- T2_MIN (RW) A(9)F(0)/F(16) - minimum TOF in the right arm; -- T2_MAX (RW) A(10)F(0)/F(16) - maximum TOF in the right arm; -- dE1_MIN (RW) A(11)F(0)/F(16) - minimum energy loss in the left arm; -- dE1_MAX (RW) A(12)F(0)/F(16) - maximum energy loss in the left arm; -- dE2_MIN (RW) A(13)F(0)/F(16) - minimum energy loss in the right arm; -- dE2_MAX (RW) A(14)F(0)/F(16) - maximum energy loss in the left arm; -------------------------------------------- -- Group #1 (J) registers: -------------------------------------------- -- X1_MIN (RW) A(0)F(1)/F(17) - minimum X-coordinate in the left arm; -- X1_MAX (RW) A(1)F(1)/F(17) - maximum X-coordinate in the left arm; -- X2_MIN (RW) A(2)F(1)/F(17) - minimum X-coordinate in the right arm; -- X2_MAX (RW) A(3)F(1)/F(17) - maximum X-coordinate in the right arm; -- Y1_MIN (RW) A(4)F(1)/F(17) - minimum Y-coordinate in the left arm; -- Y1_MAX (RW) A(5)F(1)/F(17) - maxumum Y-coordinate in the left arm; -- Y2_MIN (RW) A(6)F(1)/F(17) - minimum Y-coordinate in the right arm; -- Y2_MAX (RW) A(7)F(1)/F(17) - maxumum Y-coordinate in the right arm; -- D1_MIN (RW) A(8)F(1)/F(17) - minimum drift time in the left arm; -- D1_MAX (RW) A(9)F(1)/F(17) - maximum drift time in the left arm; -- D2_MIN (RW) A(10)F(1)/F(17) - minimum drift time in the right arm; -- D2_MAX (RW) A(11)F(1)/F(17) - maximum drift time in the right arm; -- ZE1_MIN (RW) A(12)F(1)/F(17) - minimum bragg signal in the left arm; -- ZE1_MAX (RW) A(13)F(1)/F(17) - maximum bragg signal in the left arm; -- ZE2_MIN (RW) A(14)F(1)/F(17) - minimum bragg signal in the right arm; -- ZE2_MAX (RW) A(15)F(1)/F(17) - maximum bragg signal in the left arm; -------------------------------------------- -- Control (K) registers: -------------------------------------------- -- ENA_CH1 (X) A(0)F(24)/F(26)/F(27) - left arm ON/OFF/Test; -- ENA_CH2 (X) A(1)F(24)/F(26)/F(27) - right arm ON/OFF/Test; -- DBL_PL1 (X) A(2)F(24)/F(26)/F(27) - double pulse in the left arm ON/OFF/Test; -- DBL_PL2 (X) A(3)F(24)/F(26)/F(27) - double pulse in the right arm ON/OFF/Test; -------------------------------------------- -- Prime numbers in use -------------------------------------------- -- S1 1787; -- S2 1801; -- T1 1823; -- T2 1847; -- X1 1861; -- X2 1873; -- Y1 1889; -- Y2 1907; -- dE1 1777; -- dE2 1759; -- D1 1747; -- D2 1733; -- ZE1 1721; -- ZE2 1699; -------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.numeric_std.all; -- OK. Here the entity starts... -------------------------------------------- entity TestGen is port( -- CAMAC signals -------------------------------------------- N_COM: in std_logic; B_COM: in std_logic; Z_COM: in std_logic; C_COM: in std_logic; I_COM: in std_logic; Strobe1: in std_logic; Strobe2: in std_logic; X_RES: out std_logic; Q_RES: out std_logic; L_RES: out std_logic; WRI_DAT: in std_logic_vector(23 downto 0); RDA_DAT: out std_logic_vector(23 downto 0); F_BUS: in std_logic_vector(4 downto 0); A_BUS: in std_logic_vector(3 downto 0); -------------------------------------------- -- Generated signals -------------------------------------------- S1: out std_logic; S2: out std_logic; T1: out std_logic; T2: out std_logic; X1: out std_logic; X2: out std_logic; Y1: out std_logic; Y2: out std_logic; dE1: out std_logic; dE2: out std_logic; ZE1: out std_logic_vector(3 downto 0); ZE2: out std_logic_vector(3 downto 0); EVT_STB: out std_logic; -------------------------------------------- -- Auxiliary signals -------------------------------------------- LED_REG: out std_logic_vector(3 downto 0); Clock: in std_logic ); attribute pinnum: string; attribute pinnum of N_COM: signal is "18"; attribute pinnum of B_COM: signal is "7"; attribute pinnum of Z_COM: signal is "27"; attribute pinnum of C_COM: signal is "16"; attribute pinnum of I_COM: signal is "14"; attribute pinnum of Strobe1: signal is "26"; attribute pinnum of Strobe2: signal is "28"; attribute pinnum of X_RES: signal is "12"; attribute pinnum of Q_RES: signal is "29"; attribute pinnum of L_RES: signal is "24"; attribute pinnum of WRI_DAT: signal is "30,31,36,37,38,39,40,41,44,45,46,47,53,54,55,56,57,58,60,61,62,63,64,65"; attribute pinnum of RDA_DAT: signal is "67,68,69,70,71,73,74,75,83,85,86,87,88,89,90,92,93,94,95,96,97,99,100,101"; attribute pinnum of F_BUS: signal is "8,9,10,11,13"; attribute pinnum of A_BUS: signal is "15,17,19,25"; attribute pinnum of Clock: signal is "208"; attribute pinnum of S1: signal is "164"; attribute pinnum of S2: signal is "162"; attribute pinnum of T1: signal is "160"; attribute pinnum of T2: signal is "158"; attribute pinnum of X1: signal is "150"; attribute pinnum of X2: signal is "148"; attribute pinnum of Y1: signal is "144"; attribute pinnum of Y2: signal is "142"; attribute pinnum of dE1: signal is "113"; attribute pinnum of dE2: signal is "112"; attribute pinnum of ZE1: signal is "125,122,121,120"; attribute pinnum of ZE2: signal is "119,116,115,114"; attribute pinnum of LED_REG: signal is "177,175,173,170"; attribute pinnum of EVT_STB: signal is "167"; end; architecture behavior of TestGen is -- Start-up variables -------------------------------------------- signal INI_CNT: natural range 0 to 524287; signal DUM_RES: std_logic; signal PWR_ON: std_logic; -------------------------------------------- -- CAMAC variables -------------------------------------------- signal COM_SET: std_logic; signal SEL_SET: std_logic; -------------------------- signal Frequency: natural range 0 to 3; signal Scaling1: natural range 0 to 15; signal Scaling2: natural range 0 to 15; signal S1_MIN: natural range 0 to 15; signal S1_MAX: natural range 0 to 15; signal S2_MIN: natural range 0 to 15; signal S2_MAX: natural range 0 to 15; signal T1_MIN: natural range 0 to 15; signal T1_MAX: natural range 0 to 15; signal T2_MIN: natural range 0 to 15; signal T2_MAX: natural range 0 to 15; signal dE1_MIN: natural range 0 to 15; signal dE1_MAX: natural range 0 to 15; signal dE2_MIN: natural range 0 to 15; signal dE2_MAX: natural range 0 to 15; -------------------------- signal X1_MIN: natural range 0 to 15; signal X1_MAX: natural range 0 to 15; signal X2_MIN: natural range 0 to 15; signal X2_MAX: natural range 0 to 15; signal Y1_MIN: natural range 0 to 15; signal Y1_MAX: natural range 0 to 15; signal Y2_MIN: natural range 0 to 15; signal Y2_MAX: natural range 0 to 15; signal D1_MIN: natural range 0 to 15; signal D1_MAX: natural range 0 to 15; signal D2_MIN: natural range 0 to 15; signal D2_MAX: natural range 0 to 15; signal ZE1_MIN: natural range 0 to 15; signal ZE1_MAX: natural range 0 to 15; signal ZE2_MIN: natural range 0 to 15; signal ZE2_MAX: natural range 0 to 15; -------------------------- signal ENA_CH1: std_logic; signal ENA_CH2: std_logic; signal DBL_PL1: std_logic; signal DBL_PL2: std_logic; -------------------------------------------- -- Global cycle variables -------------------------------------------- signal CYC_CNT: natural range 0 to 33554431; signal CYC_DEL: natural range 0 to 33554431; signal CYC_LIM: natural range 0 to 33554431; -------------------------- signal CYC_STB: std_logic; -------------------------------------------- -- random generator controls -------------------------------------------- signal PREP_GT: std_logic; signal COMP_GT: std_logic; -------------------------------------------- -- Random number generator variables -------------------------------------------- signal S1_CNT: natural range 0 to 8191; signal S2_CNT: natural range 0 to 8191; signal T1_CNT: natural range 0 to 8191; signal T2_CNT: natural range 0 to 8191; signal X1_CNT: natural range 0 to 8191; signal X2_CNT: natural range 0 to 8191; signal Y1_CNT: natural range 0 to 8191; signal Y2_CNT: natural range 0 to 8191; signal D1_CNT: natural range 0 to 8191; signal D2_CNT: natural range 0 to 8191; signal dE1_CNT: natural range 0 to 8191; signal dE2_CNT: natural range 0 to 8191; signal ZE1_CNT: natural range 0 to 8191; signal ZE2_CNT: natural range 0 to 8191; -------------------------- signal S1_DEL: natural range 0 to 8191; signal S2_DEL: natural range 0 to 8191; signal T1_DEL: natural range 0 to 8191; signal T2_DEL: natural range 0 to 8191; signal X1_DEL: natural range 0 to 8191; signal X2_DEL: natural range 0 to 8191; signal Y1_DEL: natural range 0 to 8191; signal Y2_DEL: natural range 0 to 8191; signal D1_DEL: natural range 0 to 8191; signal D2_DEL: natural range 0 to 8191; signal dE1_DEL: natural range 0 to 8191; signal dE2_DEL: natural range 0 to 8191; signal ZE1_DEL: natural range 0 to 8191; signal ZE2_DEL: natural range 0 to 8191; -------------------------------------------- -- variables for initial value and range -------------------------------------------- signal S1_INI: natural range 0 to 31; signal S2_INI: natural range 0 to 31; signal T1_INI: natural range 0 to 63; signal T2_INI: natural range 0 to 63; signal X1_INI: natural range 0 to 63; signal X2_INI: natural range 0 to 63; signal Y1_INI: natural range 0 to 63; signal Y2_INI: natural range 0 to 63; signal dE1_INI: natural range 0 to 255; signal dE2_INI: natural range 0 to 255; signal D1_INI: natural range 0 to 1023; signal D2_INI: natural range 0 to 1023; signal ZE1_INI: natural range 0 to 31; signal ZE2_INI: natural range 0 to 31; -------------------------- signal S1_RAN: natural range 0 to 31; signal S2_RAN: natural range 0 to 31; signal T1_RAN: natural range 0 to 31; signal T2_RAN: natural range 0 to 31; signal X1_RAN: natural range 0 to 31; signal X2_RAN: natural range 0 to 31; signal Y1_RAN: natural range 0 to 31; signal Y2_RAN: natural range 0 to 31; signal D1_RAN: natural range 0 to 31; signal D2_RAN: natural range 0 to 31; signal dE1_RAN: natural range 0 to 31; signal dE2_RAN: natural range 0 to 31; signal ZE1_RAN: natural range 0 to 31; signal ZE2_RAN: natural range 0 to 31; -------------------------------------------- -- auxiliary (memory) variables -------------------------------------------- signal S1_A: natural range 0 to 15; signal T1_A: natural range 0 to 15; signal X1_A: natural range 0 to 15; signal Y1_A: natural range 0 to 15; signal dE1_A: natural range 0 to 15; signal D1_A: natural range 0 to 15; signal ZE1_A: natural range 0 to 15; signal S1_B: natural range 0 to 15; signal T1_B: natural range 0 to 15; signal X1_B: natural range 0 to 15; signal Y1_B: natural range 0 to 15; signal dE1_B: natural range 0 to 15; signal D1_B: natural range 0 to 15; signal ZE1_B: natural range 0 to 15; signal S2_A: natural range 0 to 15; signal T2_A: natural range 0 to 15; signal X2_A: natural range 0 to 15; signal Y2_A: natural range 0 to 15; signal dE2_A: natural range 0 to 15; signal D2_A: natural range 0 to 15; signal ZE2_A: natural range 0 to 15; signal S2_B: natural range 0 to 15; signal T2_B: natural range 0 to 15; signal X2_B: natural range 0 to 15; signal Y2_B: natural range 0 to 15; signal dE2_B: natural range 0 to 15; signal D2_B: natural range 0 to 15; signal ZE2_B: natural range 0 to 15; -------------------------------------------- -- constrained random numbers -------------------------------------------- signal S1_TIM: natural range 0 to 31; signal S2_TIM: natural range 0 to 31; signal T1_TIM: natural range 0 to 31; signal T2_TIM: natural range 0 to 31; signal X1_TIM: natural range 0 to 31; signal X2_TIM: natural range 0 to 31; signal Y1_TIM: natural range 0 to 31; signal Y2_TIM: natural range 0 to 31; signal dE1_TIM: natural range 0 to 31; signal dE2_TIM: natural range 0 to 31; signal D1_TIM: natural range 0 to 31; signal D2_TIM: natural range 0 to 31; signal ZE1_TIM: natural range 0 to 31; signal ZE2_TIM: natural range 0 to 31; -------------------------- signal S1_CMP: natural range 0 to 31; signal S2_CMP: natural range 0 to 31; signal T1_CMP: natural range 0 to 31; signal T2_CMP: natural range 0 to 31; signal X1_CMP: natural range 0 to 31; signal X2_CMP: natural range 0 to 31; signal Y1_CMP: natural range 0 to 31; signal Y2_CMP: natural range 0 to 31; signal dE1_CMP: natural range 0 to 31; signal dE2_CMP: natural range 0 to 31; signal D1_CMP: natural range 0 to 31; signal D2_CMP: natural range 0 to 31; signal ZE1_CMP: natural range 0 to 31; signal ZE2_CMP: natural range 0 to 31; -------------------------------------------- -- scaling variables -------------------------------------------- signal MUL_CN1: natural range 0 to 15; signal MUL_CN2: natural range 0 to 15; signal MUL_DL1: natural range 0 to 15; signal MUL_DL2: natural range 0 to 15; signal EVT_GT1: std_logic; signal EVT_GT2: std_logic; -------------------------------------------- -- Output variables -------------------------------------------- signal S1_PUL: std_logic; signal S2_PUL: std_logic; signal T1_PUL: std_logic; signal T2_PUL: std_logic; signal X1_PUL: std_logic; signal X2_PUL: std_logic; signal Y1_PUL: std_logic; signal Y2_PUL: std_logic; signal dE1_PUL: std_logic; signal dE2_PUL: std_logic; signal ZE1_PUL: std_logic; signal ZE2_PUL: std_logic; -------------------------- signal T1_DBL: std_logic; signal T2_DBL: std_logic; signal X1_DBL: std_logic; signal X2_DBL: std_logic; signal Y1_DBL: std_logic; signal Y2_DBL: std_logic; -------------------------------------------- -- function declarations -------------------------- -- Data type conversion: -- binary#4 -> natural -------------------------------------------- function BIT4_inv_to_NUM(BIT_ARR: std_logic_vector(3 downto 0)) return natural is variable TEMP: natural range 0 to 15; begin TEMP:=0; for I in BIT_ARR'range loop TEMP:= TEMP * 2; if (BIT_ARR(I) = '0') then TEMP:= TEMP + 1; else null; end if; end loop; return TEMP; end BIT4_inv_to_NUM; -------------------------------------------- -- Data type conversion: -- binary#2 -> natural -------------------------------------------- function BIT2_inv_to_NUM(BIT_ARR: std_logic_vector(1 downto 0)) return natural is variable TEMP: natural range 0 to 3; begin TEMP:=0; for I in BIT_ARR'range loop TEMP:= TEMP * 2; if (BIT_ARR(I) = '0') then TEMP:= TEMP + 1; else null; end if; end loop; return TEMP; end BIT2_inv_to_NUM; -------------------------------------------- -- producing a normally distributed -- random number in a given range -------------------------------------------- function Make_rand_num(CON_NUM: natural range 0 to 15; RUN_NUM: natural range 0 to 8191) return natural is variable MASK: std_logic_vector(3 downto 0); variable TEMP: std_logic_vector(3 downto 0); variable RAND: natural range 0 to 15; begin -- finding the proper mask -------------------------- case CON_NUM is when 1 => MASK:= "0001"; when 2 to 3 => MASK:= "0011"; when 4 to 7 => MASK:= "0111"; when 8 to 15 => MASK:= "1111"; when others => MASK:= "0000"; end case; -- masking the raw number -------------------------- TEMP:= conv_std_logic_vector(RUN_NUM, 4); -- computing the number -------------------------- RAND:= 0; for I in MASK'range loop RAND:= RAND * 2; if ((MASK(I) = '1') and (TEMP(I) = '1')) then RAND:= RAND + 1; else null; end if; end loop; return RAND; end Make_rand_num; -------------------------------------------- begin -- Permanent statements -------------------------------------------- DUM_RES <= '0'; -------------------------- L_RES <= '1'; -------------------------- EVT_STB <= CYC_STB; -------------------------- LED_REG(3) <= ENA_CH1; LED_REG(2) <= ENA_CH2; LED_REG(1) <= DBL_PL1; LED_REG(0) <= DBL_PL2; -------------------------------------------- -- Start-up reset -------------------------------------------- process(DUM_RES, Clock, PWR_ON) begin if (DUM_RES = '1') then INI_CNT <= 0; elsif (Clock'event and Clock = '1') then if (PWR_ON = '1') then INI_CNT <= INI_CNT + 1; else null; end if; end if; end process; ------------------------- process(DUM_RES, Clock, INI_CNT) begin if (DUM_RES = '1') then PWR_ON <= '1'; elsif (Clock'event and Clock = '0') then if (INI_CNT <= 524286) then PWR_ON <= '1'; else PWR_ON <= '0'; end if; end if; end process; -------------------------------------------- -- Common CAMAC reset -- (init group #1 and #2 registers) -------------------------------------------- process(PWR_ON, Z_COM, Strobe2) begin if (PWR_ON = '1' or Z_COM = '1') then COM_SET <= '0'; elsif (Strobe2'event and Strobe2 = '0') then COM_SET <= '1'; end if; end process; -------------------------------------------- -- Selective CAMAC reset -- (init group #1 and #2 registers) -------------------------------------------- process(PWR_ON, C_COM, Strobe2) begin if (PWR_ON = '1' or C_COM = '1') then SEL_SET <= '0'; elsif (Strobe2'event and Strobe2 = '0') then SEL_SET <= '1'; end if; end process; -------------------------------------------- -- Write group #1 registers -- Registers are set to default values: -- selected by a command NA(I)F(9)S(1); -- all by a command ZS(2); -- all by a command CS(2); -- all after the power ON; -- Registers are overwritten -- by a command NA(I)F(16)S(1); -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Strobe1, N_COM, F_BUS, A_BUS, WRI_DAT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then Frequency <= 3; Scaling1 <= 0; Scaling2 <= 0; S1_MIN <= 0; S1_MAX <= 0; S2_MIN <= 0; S2_MAX <= 0; T1_MIN <= 4; T1_MAX <= 4; T2_MIN <= 4; T2_MAX <= 4; dE1_MIN <= 2; dE1_MAX <= 2; dE2_MIN <= 2; dE2_MAX <= 2; elsif (Strobe1'event and Strobe1 = '0') then if (N_COM = '0' and F_BUS = "10110") then if (A_BUS = "1111") then Frequency <= 3; elsif (A_BUS = "1110") then Scaling1 <= 0; elsif (A_BUS = "1101") then Scaling2 <= 0; elsif (A_BUS = "1100") then S1_MIN <= 0; elsif (A_BUS = "1011") then S1_MAX <= 0; elsif (A_BUS = "1010") then S2_MIN <= 0; elsif (A_BUS = "1001") then S2_MAX <= 0; elsif (A_BUS = "1000") then T1_MIN <= 4; elsif (A_BUS = "0111") then T1_MAX <= 4; elsif (A_BUS = "0110") then T2_MIN <= 4; elsif (A_BUS = "0101") then T2_MAX <= 4; elsif (A_BUS = "0100") then dE1_MIN <= 2; elsif (A_BUS = "0011") then dE1_MAX <= 2; elsif (A_BUS = "0010") then dE2_MIN <= 2; elsif (A_BUS = "0001") then dE2_MAX <= 2; else null; end if; elsif (N_COM = '0' and F_BUS = "01111") then if (A_BUS = "1111") then Frequency <= BIT2_inv_to_NUM(WRI_DAT(1 downto 0)); elsif (A_BUS = "1110") then Scaling1 <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1101") then Scaling2 <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1100") then S1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1011") then S1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1010") then S2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1001") then S2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1000") then T1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0111") then T1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0110") then T2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0101") then T2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0100") then dE1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0011") then dE1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0010") then dE2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0001") then dE2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); else null; end if; else null; end if; end if; end process; -------------------------------------------- -- Write group #2 registers -- Registers are set to default values: -- selected by a command NA(I)F(11)S(1); -- all by a command ZS(2); -- all by a command CS(2); -- all after the power ON; -- Registers are overwritten -- by a command NA(I)F(17)S(1); -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Strobe1, N_COM, F_BUS, A_BUS, WRI_DAT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then X1_MIN <= 4; X1_MAX <= 4; X2_MIN <= 4; X2_MAX <= 4; Y1_MIN <= 4; Y1_MAX <= 4; Y2_MIN <= 4; Y2_MAX <= 4; D1_MIN <= 6; D1_MAX <= 6; D2_MIN <= 6; D2_MAX <= 6; ZE1_MIN <= 6; ZE1_MAX <= 6; ZE2_MIN <= 6; ZE2_MAX <= 6; elsif (Strobe1'event and Strobe1 = '0') then if (N_COM = '0' and F_BUS = "10100") then if (A_BUS = "1111") then X1_MIN <= 4; elsif (A_BUS = "1110") then X1_MAX <= 4; elsif (A_BUS = "1101") then X2_MIN <= 4; elsif (A_BUS = "1100") then X2_MAX <= 4; elsif (A_BUS = "1011") then Y1_MIN <= 4; elsif (A_BUS = "1010") then Y1_MAX <= 4; elsif (A_BUS = "1001") then Y2_MIN <= 4; elsif (A_BUS = "1000") then Y2_MAX <= 4; elsif (A_BUS = "0111") then D1_MIN <= 6; elsif (A_BUS = "0110") then D1_MAX <= 6; elsif (A_BUS = "0101") then D2_MIN <= 6; elsif (A_BUS = "0100") then D2_MAX <= 6; elsif (A_BUS = "0011") then ZE1_MIN <= 2; elsif (A_BUS = "0010") then ZE1_MAX <= 2; elsif (A_BUS = "0001") then ZE2_MIN <= 6; elsif (A_BUS = "0000") then ZE2_MAX <= 6; else null; end if; elsif (N_COM = '0' and F_BUS = "01110") then if (A_BUS = "1111") then X1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1110") then X1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1101") then X2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1100") then X2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1011") then Y1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1010") then Y1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1001") then Y2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "1000") then Y2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0111") then D1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0110") then D1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0101") then D2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0100") then D2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0011") then ZE1_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0010") then ZE1_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0001") then ZE2_MIN <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); elsif (A_BUS = "0000") then ZE2_MAX <= BIT4_inv_to_NUM(WRI_DAT(3 downto 0)); else null; end if; else null; end if; end if; end process; -------------------------------------------- -- Write group #3 registers -- Registers are set to default values: -- all by a command ZS(2); -- all after the power ON; -- Registers are overwritten -- by commands NA(I)F(24)S(1) -- and NA(I)F(26)S(1); -------------------------------------------- process(PWR_ON, COM_SET, Strobe1, N_COM, F_BUS, A_BUS) begin if (PWR_ON = '1' or COM_SET = '1') then ENA_CH1 <= '1'; ENA_CH2 <= '1'; DBL_PL1 <= '0'; DBL_PL2 <= '0'; elsif (Strobe1'event and Strobe1 = '0') then if (N_COM = '0' and F_BUS = "00111") then if (A_BUS = "1111") then ENA_CH1 <= '0'; elsif (A_BUS = "1110") then ENA_CH2 <= '0'; elsif (A_BUS = "1101") then DBL_PL1 <= '0'; elsif (A_BUS = "1100") then DBL_PL2 <= '0'; else null; end if; elsif (N_COM = '0' and F_BUS = "00101") then if (A_BUS = "1111") then ENA_CH1 <= '1'; elsif (A_BUS = "1110") then ENA_CH2 <= '1'; elsif (A_BUS = "1101") then DBL_PL1 <= '1'; elsif (A_BUS = "1100") then DBL_PL2 <= '1'; else null; end if; else null; end if; end if; end process; -------------------------------------------- -- Read group #1 and #2 registers -------------------------------------------- process(PWR_ON, Z_COM, N_COM, F_BUS, A_BUS, Frequency, Scaling1, Scaling2, S1_MIN, S1_MAX, S2_MIN, S2_MAX, T1_MIN, T1_MAX, T2_MIN, T2_MAX, dE1_MIN, dE1_MAX, dE2_MIN, dE2_MAX, X1_MIN, X1_MAX, X1_MAX, X2_MIN, X2_MAX, Y1_MIN, Y1_MAX, Y2_MIN, Y2_MAX, D1_MIN, D1_MAX, D2_MIN, D2_MAX, ZE1_MIN, ZE1_MAX, ZE2_MIN, ZE2_MAX) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then RDA_DAT <= (others => 'Z'); -- group #1 registers -------------------------------------------- elsif (F_BUS = "11111") then if (A_BUS = "1111") then RDA_DAT(23 downto 2) <= "1111111111111111111111"; RDA_DAT(1 downto 0) <= conv_std_logic_vector((3 - Frequency), 2); elsif (A_BUS = "1110") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Scaling1), 4); elsif (A_BUS = "1101") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Scaling2), 4); elsif (A_BUS = "1100") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - S1_MIN), 4); elsif (A_BUS = "1011") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - S1_MAX), 4); elsif (A_BUS = "1010") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - S2_MIN), 4); elsif (A_BUS = "1001") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - S2_MAX), 4); elsif (A_BUS = "1000") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - T1_MIN), 4); elsif (A_BUS = "0111") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - T1_MAX), 4); elsif (A_BUS = "0110") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - T2_MIN), 4); elsif (A_BUS = "0101") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - T2_MAX), 4); elsif (A_BUS = "0100") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - dE1_MIN), 4); elsif (A_BUS = "0011") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - dE1_MAX), 4); elsif (A_BUS = "0010") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - dE2_MIN), 4); elsif (A_BUS = "0001") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - dE2_MAX), 4); else RDA_DAT <= (others => 'Z'); end if; -- group #2 registers -------------------------------------------- elsif (F_BUS = "11110") then if (A_BUS = "1111") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - X1_MIN), 4); elsif (A_BUS = "1110") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - X1_MAX), 4); elsif (A_BUS = "1101") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - X2_MIN), 4); elsif (A_BUS = "1100") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - X2_MAX), 4); elsif (A_BUS = "1011") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Y1_MIN), 4); elsif (A_BUS = "1010") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Y1_MAX), 4); elsif (A_BUS = "1001") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Y2_MIN), 4); elsif (A_BUS = "1000") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - Y2_MAX), 4); elsif (A_BUS = "0111") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - D1_MIN), 4); elsif (A_BUS = "0110") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - D1_MAX), 4); elsif (A_BUS = "0101") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - D2_MIN), 4); elsif (A_BUS = "0100") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - D2_MAX), 4); elsif (A_BUS = "0011") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - ZE1_MIN), 4); elsif (A_BUS = "0010") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - ZE1_MAX), 4); elsif (A_BUS = "0001") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - ZE2_MIN), 4); elsif (A_BUS = "0000") then RDA_DAT(23 downto 4) <= "11111111111111111111"; RDA_DAT(3 downto 0) <= conv_std_logic_vector((15 - ZE2_MAX), 4); else RDA_DAT <= (others => 'Z'); end if; else RDA_DAT <= (others => 'Z'); end if; end process; -------------------------------------------- -- Genarating X - command response -- NA(I)F(9) - set group #1 registers; -- NA(I)F(16) - overwrite group #1 registers; -- NA(I)F(0) - read group #1 registers; -- NA(J)F(11) - set group #2 registers; -- NA(J)F(17) - overwrite group #2 registers; -- NA(J)F(1) - read group #2 registers; -- NA(K)F(24) - disable detector channels; -- NA(K)F(26) - enable detector channels; -- NA(K)F(27) - test detector channels; -------------------------------------------- process(PWR_ON, Z_COM, N_COM, F_BUS, A_BUS) begin if (PWR_ON = '0' and Z_COM = '1' and N_COM = '0') then -- set, overwrite or read group #1 registers -------------------------------------------- if (F_BUS = "10110" or F_BUS = "01111" or F_BUS = "11111") then if (A_BUS = "0000") then X_RES <= 'X'; else X_RES <= '0'; end if; -- set, overwrite or read group #2 registers -------------------------------------------- elsif (F_BUS = "10100" or F_BUS = "01110" or F_BUS = "11110") then X_RES <= '0'; -- enable, disable or test group #3 registers -------------------------------------------- elsif (F_BUS = "00111" or F_BUS = "00101" or F_BUS = "00100") then if (A_BUS = "1111") then X_RES <= '0'; elsif (A_BUS = "1110") then X_RES <= '0'; elsif (A_BUS = "1101") then X_RES <= '0'; elsif (A_BUS = "1100") then X_RES <= '0'; else X_RES <= 'Z'; end if; else X_RES <= 'Z'; end if; else X_RES <= 'Z'; end if; end process; -------------------------------------------- -- Genarating Q - status response -------------------------------------------- process(PWR_ON, Z_COM, N_COM, F_BUS, A_BUS, ENA_CH1, ENA_CH2, DBL_PL1, DBL_PL2) begin if (PWR_ON = '0' and Z_COM = '1' and N_COM = '0') then if (F_BUS = "00100") then if (A_BUS = "1111") then Q_RES <= not ENA_CH1; elsif (A_BUS = "1110") then Q_RES <= not ENA_CH2; elsif (A_BUS = "1101") then Q_RES <= not DBL_PL1; elsif (A_BUS = "1100") then Q_RES <= not DBL_PL2; else Q_RES <= 'Z'; end if; else Q_RES <= 'Z'; end if; else Q_RES <= 'Z'; end if; end process; -------------------------------------------- -- S1 initial -------------------------------------------- process(S1_MIN, S1_MAX) begin if (S1_MIN <= S1_MAX) then S1_INI <= S1_MIN; else S1_INI <= S1_MAX; end if; end process; -------------------------------------------- -- S2 initial -------------------------------------------- process(S2_MIN, S2_MAX) begin if (S2_MIN <= S2_MAX) then S2_INI <= S2_MIN; else S2_INI <= S2_MAX; end if; end process; -------------------------------------------- -- T1 initial -------------------------------------------- process(T1_MIN, T1_MAX, S1_INI, S1_TIM) begin if (T1_MIN <= T1_MAX) then T1_INI <= T1_MIN + S1_INI + S1_TIM; else T1_INI <= T1_MAX + S1_INI + S1_TIM; end if; end process; -------------------------------------------- -- T2 initial -------------------------------------------- process(T2_MIN, T2_MAX, S2_INI, S2_TIM) begin if (T2_MIN <= T2_MAX) then T2_INI <= T2_MIN + S2_INI + S2_TIM; else T2_INI <= T2_MAX + S2_INI + S2_TIM; end if; end process; -------------------------------------------- -- X1 initial -------------------------------------------- process(X1_MIN, X1_MAX, T1_INI, T1_TIM) begin if (X1_MIN <= X1_MAX) then X1_INI <= X1_MIN + T1_INI + T1_TIM; else X1_INI <= X1_MAX + T1_INI + T1_TIM; end if; end process; -------------------------------------------- -- X2 initial -------------------------------------------- process(X2_MIN, X2_MAX, T2_INI, T2_TIM) begin if (X2_MIN <= X2_MAX) then X2_INI <= X2_MIN + T2_INI + T2_TIM; else X2_INI <= X2_MAX + T2_INI + T2_TIM; end if; end process; -------------------------------------------- -- Y1 initial -------------------------------------------- process(Y1_MIN, Y1_MAX, T1_INI, T1_TIM) begin if (Y1_MIN <= Y1_MAX) then Y1_INI <= Y1_MIN + T1_INI + T1_TIM; else Y1_INI <= Y1_MAX + T1_INI + T1_TIM; end if; end process; -------------------------------------------- -- Y2 initial -------------------------------------------- process(Y2_MIN, Y2_MAX, T2_INI, T2_TIM) begin if (Y2_MIN <= Y2_MAX) then Y2_INI <= Y2_MIN + T2_INI + T2_TIM; else Y2_INI <= Y2_MAX + T2_INI + T2_TIM; end if; end process; -------------------------------------------- -- dE1 initial -------------------------------------------- process(dE1_MIN, dE1_MAX, T1_INI, T1_TIM) begin if (dE1_MIN <= dE1_MAX) then dE1_INI <= 8 * dE1_MIN + T1_INI + T1_TIM; else dE1_INI <= 8 * dE1_MAX + T1_INI + T1_TIM; end if; end process; -------------------------------------------- -- dE2 initial -------------------------------------------- process(dE2_MIN, dE2_MAX, T2_INI, T2_TIM) begin if (dE2_MIN <= dE2_MAX) then dE2_INI <= 8 * dE2_MIN + T2_INI + T2_TIM; else dE2_INI <= 8 * dE2_MAX + T2_INI + T2_TIM; end if; end process; -------------------------------------------- -- D1 initial -------------------------------------------- process(D1_MIN, D1_MAX, T1_INI, T1_TIM) begin if (D1_MIN <= D1_MAX) then D1_INI <= 8 * D1_MIN + T1_INI + T1_TIM; else D1_INI <= 8 * D1_MAX + T1_INI + T1_TIM; end if; end process; -------------------------------------------- -- D2 initial -------------------------------------------- process(D2_MIN, D2_MAX, T2_INI, T2_TIM) begin if (D2_MIN <= D2_MAX) then D2_INI <= 8 * D2_MIN + T2_INI + T2_TIM; else D2_INI <= 8 * D2_MAX + T2_INI + T2_TIM; end if; end process; -------------------------------------------- -- ZE1 initial -------------------------------------------- process(ZE1_MIN, ZE1_MAX) begin if (ZE1_MIN <= ZE1_MAX) then ZE1_INI <= ZE1_MIN; else ZE1_INI <= ZE1_MAX; end if; end process; -------------------------------------------- -- ZE2 initial -------------------------------------------- process(ZE2_MIN, ZE2_MAX) begin if (ZE2_MIN <= ZE2_MAX) then ZE2_INI <= ZE2_MIN; else ZE2_INI <= ZE2_MAX; end if; end process; -------------------------------------------- -- S1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, S1_MIN, S1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then S1_A <= 0; S1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (S1_MIN <= S1_MAX) then S1_A <= S1_MAX; S1_B <= S1_MIN; else S1_A <= S1_MIN; S1_B <= S1_MAX; end if; else null; end if; end if; end process; -------------------------- S1_RAN <= S1_A - S1_B; -------------------------------------------- -- S2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, S2_MIN, S2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then S2_A <= 0; S2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (S2_MIN <= S2_MAX) then S2_A <= S2_MAX; S2_B <= S2_MIN; else S2_A <= S2_MIN; S2_B <= S2_MAX; end if; else null; end if; end if; end process; -------------------------- S2_RAN <= S2_A - S2_B; -------------------------------------------- -- T1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, T1_MIN, T1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then T1_A <= 0; T1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (T1_MIN <= T1_MAX) then T1_A <= T1_MAX; T1_B <= T1_MIN; else T1_A <= T1_MIN; T1_B <= T1_MAX; end if; else null; end if; end if; end process; -------------------------- T1_RAN <= T1_A - T1_B; -------------------------------------------- -- T2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, T2_MIN, T2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then T2_A <= 0; T2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (T2_MIN <= T2_MAX) then T2_A <= T2_MAX; T2_B <= T2_MIN; else T2_A <= T2_MIN; T2_B <= T2_MAX; end if; else null; end if; end if; end process; -------------------------- T2_RAN <= T2_A - T2_B; -------------------------------------------- -- X1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, X1_MIN, X1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then X1_A <= 0; X1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (X1_MIN <= X1_MAX) then X1_A <= X1_MAX; X1_B <= X1_MIN; else X1_A <= X1_MIN; X1_B <= X1_MAX; end if; else null; end if; end if; end process; -------------------------- X1_RAN <= X1_A - X1_B; -------------------------------------------- -- X2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, X2_MIN, X2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then X2_A <= 0; X2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (X2_MIN <= X2_MAX) then X2_A <= X2_MAX; X2_B <= X2_MIN; else X2_A <= X2_MIN; X2_B <= X2_MAX; end if; else null; end if; end if; end process; -------------------------- X2_RAN <= X2_A - X2_B; -------------------------------------------- -- Y1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, Y1_MIN, Y1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then Y1_A <= 0; Y1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (Y1_MIN <= Y1_MAX) then Y1_A <= Y1_MAX; Y1_B <= Y1_MIN; else Y1_A <= Y1_MIN; Y1_B <= Y1_MAX; end if; else null; end if; end if; end process; -------------------------- Y1_RAN <= Y1_A - Y1_B; -------------------------------------------- -- Y2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, Y2_MIN, Y2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then Y2_A <= 0; Y2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (Y2_MIN <= Y2_MAX) then Y2_A <= Y2_MAX; Y2_B <= Y2_MIN; else Y2_A <= Y2_MIN; Y2_B <= Y2_MAX; end if; else null; end if; end if; end process; -------------------------- Y2_RAN <= Y2_A - Y2_B; -------------------------------------------- -- dE1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, dE1_MIN, dE1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then dE1_A <= 0; dE1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (dE1_MIN <= dE1_MAX) then dE1_A <= dE1_MAX; dE1_B <= dE1_MIN; else dE1_A <= dE1_MIN; dE1_B <= dE1_MAX; end if; else null; end if; end if; end process; -------------------------- dE1_RAN <= dE1_A - dE1_B; -------------------------------------------- -- dE2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, dE2_MIN, dE2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then dE2_A <= 0; dE2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (dE2_MIN <= dE2_MAX) then dE2_A <= dE2_MAX; dE2_B <= dE2_MIN; else dE2_A <= dE2_MIN; dE2_B <= dE2_MAX; end if; else null; end if; end if; end process; -------------------------- dE2_RAN <= dE2_A - dE2_B; -------------------------------------------- -- D1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, D1_MIN, D1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then D1_A <= 0; D1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (D1_MIN <= D1_MAX) then D1_A <= D1_MAX; D1_B <= D1_MIN; else D1_A <= D1_MIN; D1_B <= D1_MAX; end if; else null; end if; end if; end process; -------------------------- D1_RAN <= D1_A - D1_B; -------------------------------------------- -- D2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, D2_MIN, D2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then D2_A <= 0; D2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (D2_MIN <= D2_MAX) then D2_A <= D2_MAX; D2_B <= D2_MIN; else D2_A <= D2_MIN; D2_B <= D2_MAX; end if; else null; end if; end if; end process; -------------------------- D2_RAN <= D2_A - D2_B; -------------------------------------------- -- ZE1 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, ZE1_MIN, ZE1_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then ZE1_A <= 0; ZE1_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (ZE1_MIN <= ZE1_MAX) then ZE1_A <= ZE1_MAX; ZE1_B <= ZE1_MIN; else ZE1_A <= ZE1_MIN; ZE1_B <= ZE1_MAX; end if; else null; end if; end if; end process; -------------------------- ZE1_RAN <= ZE1_A - ZE1_B; -------------------------------------------- -- ZE2 range -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, ZE2_MIN, ZE2_MAX) begin if (PWR_ON = '1' or COM_SET = '1') then ZE2_A <= 0; ZE2_B <= 0; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then if (ZE2_MIN <= ZE2_MAX) then ZE2_A <= ZE2_MAX; ZE2_B <= ZE2_MIN; else ZE2_A <= ZE2_MIN; ZE2_B <= ZE2_MAX; end if; else null; end if; end if; end process; -------------------------- ZE2_RAN <= ZE2_A - ZE2_B; -------------------------------------------- -- Computing the number of loops -------------------------------------------- process(Frequency) begin case Frequency is when 0 => CYC_LIM <= 20000000; when 1 => CYC_LIM <= 2000000; when 2 => CYC_LIM <= 200000; when others => CYC_LIM <= 20000; end case; end process; -------------------------------------------- -- Counter for one cycle -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_DEL, CYC_LIM) begin if (PWR_ON = '1' or COM_SET = '1') then CYC_CNT <= 0; elsif (Clock'event and Clock = '1') then if (CYC_DEL = CYC_LIM) then CYC_CNT <= 0; else CYC_CNT <= CYC_CNT + 1; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT) begin if (PWR_ON = '1' or COM_SET = '1') then CYC_DEL <= 0; elsif (Clock'event and Clock = '0') then CYC_DEL <= CYC_CNT; end if; end process; -------------------------------------------- -- Event strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_DEL, CYC_LIM) begin if (PWR_ON = '1' or COM_SET = '1') then CYC_STB <= '0'; elsif (Clock'event and Clock = '1') then if (CYC_DEL = CYC_LIM) then CYC_STB <= '1'; else CYC_STB <= '0'; end if; end if; end process; -------------------------------------------- -- Gates for preparing a cycle and -- computing the random number -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT) begin if (PWR_ON = '1' or COM_SET = '1') then PREP_GT <= '0'; COMP_GT <= '0'; elsif (Clock'event and Clock = '0') then case CYC_CNT is when 10000 => PREP_GT <= '1'; COMP_GT <= '0'; when 10001 to 20000 => PREP_GT <= '0'; COMP_GT <= '1'; when others => PREP_GT <= '0'; COMP_GT <= '0'; end case; end if; end process; -------------------------------------------- -- random S1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, S1_RAN, S1_CMP, S1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then S1_CNT <= 0; S1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then S1_TIM <= 16; elsif (COMP_GT = '1') then if (S1_RAN < S1_CMP) then if (5927 < S1_DEL) then S1_CNT <= S1_DEL - 5927; else S1_TIM <= Make_rand_num(S1_RAN, (S1_CNT + 1787)); S1_CNT <= S1_CNT + 1787; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, S1_CNT, S1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then S1_DEL <= 0; S1_CMP <= 16; elsif (Clock'event and Clock = '0') then S1_DEL <= S1_CNT; S1_CMP <= S1_TIM; end if; end process; -------------------------------------------- -- random S2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, S2_RAN, S2_CMP, S2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then S2_CNT <= 0; S2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then S2_TIM <= 16; elsif (COMP_GT = '1') then if (S2_RAN < S2_CMP) then if (5927 < S2_DEL) then S2_CNT <= S2_DEL - 5927; else S2_TIM <= Make_rand_num(S2_RAN, (S2_CNT + 1801)); S2_CNT <= S2_CNT + 1801; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, S2_CNT, S2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then S2_DEL <= 0; S2_CMP <= 16; elsif (Clock'event and Clock = '0') then S2_DEL <= S2_CNT; S2_CMP <= S2_TIM; end if; end process; -------------------------------------------- -- random T1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, T1_RAN, T1_CMP, T1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then T1_CNT <= 0; T1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then T1_TIM <= 16; elsif (COMP_GT = '1') then if (T1_RAN < T1_CMP) then if (5927 < T1_DEL) then T1_CNT <= T1_DEL - 5927; else T1_TIM <= Make_rand_num(T1_RAN, (T1_CNT + 1823)); T1_CNT <= T1_CNT + 1823; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, T1_CNT, T1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then T1_DEL <= 0; T1_CMP <= 16; elsif (Clock'event and Clock = '0') then T1_DEL <= T1_CNT; T1_CMP <= T1_TIM; end if; end process; -------------------------------------------- -- random T2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, T2_RAN, T2_CMP, T2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then T2_CNT <= 0; T2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then T2_TIM <= 16; elsif (COMP_GT = '1') then if (T2_RAN < T2_CMP) then if (5927 < T2_DEL) then T2_CNT <= T2_DEL - 5927; else T2_TIM <= Make_rand_num(T2_RAN, (T2_CNT + 1847)); T2_CNT <= T2_CNT + 1847; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, T2_CNT, T2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then T2_DEL <= 0; T2_CMP <= 16; elsif (Clock'event and Clock = '0') then T2_DEL <= T2_CNT; T2_CMP <= T2_TIM; end if; end process; -------------------------------------------- -- random X1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, X1_RAN, X1_CMP, X1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then X1_CNT <= 0; X1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then X1_TIM <= 16; elsif (COMP_GT = '1') then if (X1_RAN < X1_CMP) then if (5927 < X1_DEL) then X1_CNT <= X1_DEL - 5927; else X1_TIM <= Make_rand_num(X1_RAN, (X1_CNT + 1861)); X1_CNT <= X1_CNT + 1861; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, X1_CNT, X1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then X1_DEL <= 0; X1_CMP <= 16; elsif (Clock'event and Clock = '0') then X1_DEL <= X1_CNT; X1_CMP <= X1_TIM; end if; end process; -------------------------------------------- -- random X2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, X2_RAN, X2_CMP, X2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then X2_CNT <= 0; X2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then X2_TIM <= 16; elsif (COMP_GT = '1') then if (X2_RAN < X2_CMP) then if (5927 < X2_DEL) then X2_CNT <= X2_DEL - 5927; else X2_TIM <= Make_rand_num(X2_RAN, (X2_CNT + 1873)); X2_CNT <= X2_CNT + 1873; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, X2_CNT, X2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then X2_DEL <= 0; X2_CMP <= 16; elsif (Clock'event and Clock = '0') then X2_DEL <= X2_CNT; X2_CMP <= X2_TIM; end if; end process; -------------------------------------------- -- random Y1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, Y1_RAN, Y1_CMP, Y1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then Y1_CNT <= 0; Y1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then Y1_TIM <= 16; elsif (COMP_GT = '1') then if (Y1_RAN < Y1_CMP) then if (5927 < Y1_DEL) then Y1_CNT <= Y1_DEL - 5927; else Y1_TIM <= Make_rand_num(Y1_RAN, (Y1_CNT + 1889)); Y1_CNT <= Y1_CNT + 1889; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, Y1_CNT, Y1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then Y1_DEL <= 0; Y1_CMP <= 16; elsif (Clock'event and Clock = '0') then Y1_DEL <= Y1_CNT; Y1_CMP <= Y1_TIM; end if; end process; -------------------------------------------- -- random Y2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, Y2_RAN, Y2_CMP, Y2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then Y2_CNT <= 0; Y2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then Y2_TIM <= 16; elsif (COMP_GT = '1') then if (Y2_RAN < Y2_CMP) then if (5927 < Y2_DEL) then Y2_CNT <= Y2_DEL - 5927; else Y2_TIM <= Make_rand_num(Y2_RAN, (Y2_CNT + 1907)); Y2_CNT <= Y2_CNT + 1907; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, Y2_CNT, Y2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then Y2_DEL <= 0; Y2_CMP <= 16; elsif (Clock'event and Clock = '0') then Y2_DEL <= Y2_CNT; Y2_CMP <= Y2_TIM; end if; end process; -------------------------------------------- -- random dE1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, dE1_RAN, dE1_CMP, dE1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then dE1_CNT <= 0; dE1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then dE1_TIM <= 16; elsif (COMP_GT = '1') then if (dE1_RAN < dE1_CMP) then if (5927 < dE1_DEL) then dE1_CNT <= dE1_DEL - 5927; else dE1_TIM <= Make_rand_num(dE1_RAN, (dE1_CNT + 1777)); dE1_CNT <= dE1_CNT + 1777; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, dE1_CNT, dE1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then dE1_DEL <= 0; dE1_CMP <= 16; elsif (Clock'event and Clock = '0') then dE1_DEL <= dE1_CNT; dE1_CMP <= dE1_TIM; end if; end process; -------------------------------------------- -- random dE2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, dE2_RAN, dE2_CMP, dE2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then dE2_CNT <= 0; dE2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then dE2_TIM <= 16; elsif (COMP_GT = '1') then if (dE2_RAN < dE2_CMP) then if (5927 < dE2_DEL) then dE2_CNT <= dE2_DEL - 5927; else dE2_TIM <= Make_rand_num(dE2_RAN, (dE2_CNT + 1759)); dE2_CNT <= dE2_CNT + 1759; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, dE2_CNT, dE2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then dE2_DEL <= 0; dE2_CMP <= 16; elsif (Clock'event and Clock = '0') then dE2_DEL <= dE2_CNT; dE2_CMP <= dE2_TIM; end if; end process; -------------------------------------------- -- random D1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, D1_RAN, D1_CMP, D1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then D1_CNT <= 0; D1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then D1_TIM <= 16; elsif (COMP_GT = '1') then if (D1_RAN < D1_CMP) then if (5927 < D1_DEL) then D1_CNT <= D1_DEL - 5927; else D1_TIM <= Make_rand_num(D1_RAN, (D1_CNT + 1747)); D1_CNT <= D1_CNT + 1747; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, D1_CNT, D1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then D1_DEL <= 0; D1_CMP <= 16; elsif (Clock'event and Clock = '0') then D1_DEL <= D1_CNT; D1_CMP <= D1_TIM; end if; end process; -------------------------------------------- -- random D2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, D2_RAN, D2_CMP, D2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then D2_CNT <= 0; D2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then D2_TIM <= 16; elsif (COMP_GT = '1') then if (D2_RAN < D2_CMP) then if (5927 < D2_DEL) then D2_CNT <= D2_DEL - 5927; else D2_TIM <= Make_rand_num(D2_RAN, (D2_CNT + 1733)); D2_CNT <= D2_CNT + 1733; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, D2_CNT, D2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then D2_DEL <= 0; D2_CMP <= 16; elsif (Clock'event and Clock = '0') then D2_DEL <= D2_CNT; D2_CMP <= D2_TIM; end if; end process; -------------------------------------------- -- random ZE1 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, ZE1_RAN, ZE1_CMP, ZE1_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then ZE1_CNT <= 0; ZE1_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then ZE1_TIM <= 16; elsif (COMP_GT = '1') then if (ZE1_RAN < ZE1_CMP) then if (5927 < ZE1_DEL) then ZE1_CNT <= ZE1_DEL - 5927; else ZE1_TIM <= Make_rand_num(ZE1_RAN, (ZE1_CNT + 1721)); ZE1_CNT <= ZE1_CNT + 1721; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, ZE1_CNT, ZE1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then ZE1_DEL <= 0; ZE1_CMP <= 16; elsif (Clock'event and Clock = '0') then ZE1_DEL <= ZE1_CNT; ZE1_CMP <= ZE1_TIM; end if; end process; -------------------------------------------- -- random ZE2 -------------------------------------------- process(PWR_ON, COM_SET, Clock, PREP_GT, COMP_GT, ZE2_RAN, ZE2_CMP, ZE2_DEL) begin if (PWR_ON = '1' or COM_SET = '1') then ZE2_CNT <= 0; ZE2_TIM <= 16; elsif (Clock'event and Clock = '1') then if (PREP_GT = '1') then ZE2_TIM <= 16; elsif (COMP_GT = '1') then if (ZE2_RAN < ZE2_CMP) then if (5927 < ZE2_DEL) then ZE2_CNT <= ZE2_DEL - 5927; else ZE2_TIM <= Make_rand_num(ZE2_RAN, (ZE2_CNT + 1699)); ZE2_CNT <= ZE2_CNT + 1699; end if; else null; end if; else null; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, Clock, ZE2_CNT, ZE2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then ZE2_DEL <= 0; ZE2_CMP <= 16; elsif (Clock'event and Clock = '0') then ZE2_DEL <= ZE2_CNT; ZE2_CMP <= ZE2_TIM; end if; end process; -------------------------------------------- -- Generating the S1 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, S1_INI, S1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then S1_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (S1_INI + S1_TIM)) then S1_PUL <= '1'; else S1_PUL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the S2 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, S2_INI, S2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then S2_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (S2_INI + S2_TIM)) then S2_PUL <= '1'; else S2_PUL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the T1 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, T1_INI, T1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then T1_PUL <= '0'; T1_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (T1_INI + T1_TIM)) then T1_PUL <= '1'; T1_DBL <= '0'; elsif (CYC_CNT = (T1_INI + T1_TIM + 2)) then T1_PUL <= '0'; T1_DBL <= '1'; else T1_PUL <= '0'; T1_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the T2 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, T2_INI, T2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then T2_PUL <= '0'; T2_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (T2_INI + T2_TIM)) then T2_PUL <= '1'; T2_DBL <= '0'; elsif (CYC_CNT = (T2_INI + T2_TIM + 2)) then T2_PUL <= '0'; T2_DBL <= '1'; else T2_PUL <= '0'; T2_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the X1 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, X1_INI, X1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then X1_PUL <= '0'; X1_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (X1_INI + X1_TIM)) then X1_PUL <= '1'; X1_DBL <= '0'; elsif (CYC_CNT = (X1_INI + X1_TIM + 2)) then X1_PUL <= '0'; X1_DBL <= '1'; else X1_PUL <= '0'; X1_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the X2 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, X2_INI, X2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then X2_PUL <= '0'; X2_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (X2_INI + X2_TIM)) then X2_PUL <= '1'; X2_DBL <= '0'; elsif (CYC_CNT = (X2_INI + X2_TIM + 2)) then X2_PUL <= '0'; X2_DBL <= '1'; else X2_PUL <= '0'; X2_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the Y1 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, Y1_INI, Y1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then Y1_PUL <= '0'; Y1_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (Y1_INI + Y1_TIM)) then Y1_PUL <= '1'; Y1_DBL <= '0'; elsif (CYC_CNT = (Y1_INI + Y1_TIM + 2)) then Y1_PUL <= '0'; Y1_DBL <= '1'; else Y1_PUL <= '0'; Y1_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the Y2 strobe -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, Y2_INI, Y2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then Y2_PUL <= '0'; Y2_DBL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (Y2_INI + Y2_TIM)) then Y2_PUL <= '1'; Y2_DBL <= '0'; elsif (CYC_CNT = (Y2_INI + Y2_TIM + 2)) then Y2_PUL <= '0'; Y2_DBL <= '1'; else Y2_PUL <= '0'; Y2_DBL <= '0'; end if; end if; end process; -------------------------------------------- -- Generating the dE1 charge -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, T1_INI, T1_TIM, dE1_INI, dE1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then dE1_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (T1_INI + T1_TIM)) then dE1_PUL <= '1'; elsif ((dE1_INI + 8 * dE1_TIM) <= CYC_CNT) then dE1_PUL <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Generating the dE2 charge -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, T2_INI, T2_TIM, dE2_INI, dE2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then dE2_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = (T2_INI + T2_TIM)) then dE2_PUL <= '1'; elsif ((dE2_INI + 8 * dE2_TIM) <= CYC_CNT) then dE2_PUL <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Generating the ZE1 gate -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, D1_INI, D1_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then ZE1_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = D1_INI + 8 * D1_TIM) then ZE1_PUL <= '1'; elsif (CYC_CNT = (D1_INI + 8 * D1_TIM + 511)) then ZE1_PUL <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Generating the ZE2 gate -------------------------------------------- process(PWR_ON, COM_SET, Clock, CYC_CNT, D2_INI, D2_TIM) begin if (PWR_ON = '1' or COM_SET = '1') then ZE2_PUL <= '0'; elsif (Clock'event and Clock = '0') then if (CYC_CNT = D2_INI + 8 * D2_TIM) then ZE2_PUL <= '1'; elsif (CYC_CNT = (D2_INI + 8 * D2_TIM + 511)) then ZE2_PUL <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Scale counter in the left arm -------------------------------------------- process(PWR_ON, COM_SET, CYC_STB, MUL_DL1, Scaling1) begin if (PWR_ON = '1' or COM_SET = '1') then MUL_CN1 <= 0; elsif (CYC_STB'event and CYC_STB = '1') then if (MUL_DL1 = Scaling1) then MUL_CN1 <= 0; else MUL_CN1 <= MUL_CN1 + 1; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, CYC_STB, MUL_CN1) begin if (PWR_ON = '1' or COM_SET = '1') then MUL_DL1 <= 0; elsif (CYC_STB'event and CYC_STB = '0') then MUL_DL1 <= MUL_CN1; end if; end process; -------------------------------------------- -- Scale counter in the right arm -------------------------------------------- process(PWR_ON, COM_SET, CYC_STB, MUL_DL2, Scaling2) begin if (PWR_ON = '1' or COM_SET = '1') then MUL_CN2 <= 0; elsif (CYC_STB'event and CYC_STB = '1') then if (MUL_DL2 = Scaling2) then MUL_CN2 <= 0; else MUL_CN2 <= MUL_CN2 + 1; end if; end if; end process; -------------------------- process(PWR_ON, COM_SET, CYC_STB, MUL_CN2) begin if (PWR_ON = '1' or COM_SET = '1') then MUL_DL2 <= 0; elsif (CYC_STB'event and CYC_STB = '0') then MUL_DL2 <= MUL_CN2; end if; end process; -------------------------------------------- -- Scaling the event rate -------------------------------------------- process(MUL_CN1) begin if (MUL_CN1 = Scaling1) then EVT_GT1 <= '1'; else EVT_GT1 <= '0'; end if; end process; -------------------------- process(MUL_CN2) begin if (MUL_CN2 = Scaling2) then EVT_GT2 <= '1'; else EVT_GT2 <= '0'; end if; end process; -------------------------------------------- -- Output time-related signals -------------------------------------------- S1 <= not(I_COM and ENA_CH1 and EVT_GT1 and S1_PUL); S2 <= not(I_COM and ENA_CH2 and EVT_GT2 and S2_PUL); T1 <= not(I_COM and ENA_CH1 and EVT_GT1 and (T1_PUL or (DBL_PL1 and T1_DBL))); T2 <= not(I_COM and ENA_CH2 and EVT_GT2 and (T2_PUL or (DBL_PL2 and T2_DBL))); X1 <= not(I_COM and ENA_CH1 and EVT_GT1 and (X1_PUL or (DBL_PL1 and X1_DBL))); X2 <= not(I_COM and ENA_CH2 and EVT_GT2 and (X2_PUL or (DBL_PL2 and X2_DBL))); Y1 <= not(I_COM and ENA_CH1 and EVT_GT1 and (Y1_PUL or (DBL_PL1 and Y1_DBL))); Y2 <= not(I_COM and ENA_CH2 and EVT_GT2 and (Y2_PUL or (DBL_PL2 and Y2_DBL))); dE1 <= not(I_COM and ENA_CH1 and EVT_GT1 and dE1_PUL); dE2 <= not(I_COM and ENA_CH2 and EVT_GT2 and dE2_PUL); -------------------------------------------- -- Output amplitude-related signals -------------------------------------------- process(I_COM, ENA_CH1, EVT_GT1, ZE1_PUL, ZE1_INI, ZE1_TIM) begin if (I_COM = '1' and ENA_CH1 = '1' and EVT_GT1 = '1' and ZE1_PUL = '1') then ZE1 <= conv_std_logic_vector((ZE1_INI + ZE1_TIM), 4); else ZE1 <= (others => '0'); end if; end process; -------------------------- process(I_COM, ENA_CH2, EVT_GT2, ZE2_PUL, ZE2_INI, ZE2_TIM) begin if (I_COM = '1' and ENA_CH2 = '1' and EVT_GT2 = '1' and ZE2_PUL = '1') then ZE2 <= conv_std_logic_vector((ZE2_INI + ZE2_TIM), 4); else ZE2 <= (others => '0'); end if; end process; -------------------------------------------- end;