-- The new version of the Pad slow control processor -- in BST-2003 design after the radiation damage rapair. -- It includes now the serial interface instead of the -- former CAN system and the ASICs power supply manager -- with the reset option. The thresholds are generated -- by the charge pump driven through the ALTERA chip -- which generates 100ns pulses with a duty cycle 1/2 -- to 1/256. The values (-1 mV / count) become active -- immediately after assignment (no need for extra -- load command). -- The register x55 access with a write permission -- re-activates the default "power-on" settings. -- Functions of the state machine are defined via the -- control register (x56). Writing data to it launches -- the commands encoded by the combination bits. -- Address allocation: -------------------------------------------- -- System pre-set -------------------------- -- x55 - activate default (power-on) settings; -- Control register -------------------------- -- x56 - control register which defines a -- sequence of commands, load PRO/A; -- Readout steering -------------------------- -- x5A - T0 for the APEX; -- Indicators -------------------------- -- x01 - supply watchdogs (read only); -- x02 - PRO/A load status (read only); -- Thresholds: -------------------------- -- x03 - Threshold 00; -- x04 - Threshold 01; -- x05 - Threshold 02; -- x06 - Threshold 03; -- x07 - Threshold 10; -- x08 - Threshold 11; -- x09 - Threshold 12; -- x0A - Threshold 13; -- PRO/A settings: -------------------------- -- x0C - test enable pad 03; -- x0D - test enable pad 02; -- x0E - test enable pad 01; -- x0F - test enable pad 00; -- x10 - test enable pad 23; -- x11 - test enable pad 22; -- x12 - test enable pad 21; -- x13 - test enable pad 20; -- x14 - test enable pad 43; -- x15 - test enable pad 42; -- x16 - test enable pad 41; -- x17 - test enable pad 40; -- x18 - test enable pad 63; -- x19 - test enable pad 62; -- x1A - test enable pad 61; -- x1B - test enable pad 60; -- x1C - test enable pad 70; -- x1D - test enable pad 71; -- x1E - test enable pad 72; -- x1F - test enable pad 73; -- x20 - test enable pad 50; -- x21 - test enable pad 51; -- x22 - test enable pad 52; -- x23 - test enable pad 53; -- x24 - test enable pad 30; -- x25 - test enable pad 31; -- x26 - test enable pad 32; -- x27 - test enable pad 33; -- x28 - test enable pad 10; -- x29 - test enable pad 11; -- x2A - test enable pad 12; -- x2B - test enable pad 13; -- -- x2C - output disable pad 03; -- x2D - output disable pad 02; -- x2E - output disable pad 01; -- x2F - output disable pad 00; -- x30 - output disable pad 23; -- x31 - output disable pad 22; -- x32 - output disable pad 21; -- x33 - output disable pad 20; -- x34 - output disable pad 43; -- x35 - output disable pad 42; -- x36 - output disable pad 41; -- x37 - output disable pad 40; -- x38 - output disable pad 63; -- x39 - output disable pad 62; -- x3A - output disable pad 61; -- x3B - output disable pad 60; -- x3C - output disable pad 70; -- x3D - output disable pad 71; -- x3E - output disable pad 72; -- x3F - output disable pad 73; -- x40 - output disable pad 50; -- x41 - output disable pad 51; -- x42 - output disable pad 52; -- x43 - output disable pad 53; -- x44 - output disable pad 30; -- x45 - output disable pad 31; -- x46 - output disable pad 32; -- x47 - output disable pad 33; -- x48 - output disable pad 10; -- x49 - output disable pad 11; -- x4A - output disable pad 12; -- x4B - output disable pad 13; -- x4C - enable calibration mode; -- x4D - enable current compensation; -- x4E - gain selection bit_0; -- x4F - gain selection bit_1; -- x50 - enable analog output; -- x51 - enable individual mode; -- x52 - negative signal; -- x53 - time-over-threshold; -------------------------------------------- -- Gain encoding: -------------------------------------------- -- GS0 GS1 C_fb -- 0 0 1.0 pF Default -- 0 1 0.3 pF High -- 1 0 1.3 pF Low -- 1 1 0.7 pF Medium -------------------------------------------- -- Data format: -------------------------------------------- -- Control register -------------------------- -- Bit_0 - reset PRO/A power; -- Bit_1 - load PRO/A; -- Bit_2 - read PRO/A; -- Power supply watchdogs: -------------------------- -- Bit_7 - +5.0 V. serial interface buffer; -- Bit_6 - +3.3 V. ACEX / APEX shell; -- Bit_5 - +2.5 V. ACEX core; -- Bit_4 - +1.8 V. APEX core; -- Bit_3 - -2.0 V. PRO/A digital; -- Bit_2 - +2.0 V. PRO/A digital; -- Bit_1 - -2.0 V. PRO/A analog; -- Bit_0 - +2.0 V. PRO/A analog; -- PRO/A settings and status -------------------------- -- Bit_7 - Pro/A 13 = Sector_1, Plane 3; -- Bit_6 - Pro/A 12 = Sector_1, Plane 2; -- Bit_5 - Pro/A 11 = Sector_1, Plane 1; -- Bit_4 - Pro/A 10 = Sector_1, Plane 0; -- Bit_3 - Pro/A 03 = Sector_0, Plane 3; -- Bit_2 - Pro/A 02 = Sector_0, Plane 2; -- Bit_1 - Pro/A 01 = Sector_0, Plane 1; -- Bit_0 - Pro/A 00 = Sector_0, Plane 0; -------------------------------------------- -- The serial protocol is based on 18-bit messages, -- each bit lasts 1.25 us as the maximum CAN frequency -- is limited by 1 MHz. For the 16 MHz VME-transmitter -- (62.5 ns) the message length is equal to 360 clock -- periods, for the 10 MHz front-end receiver (96.0 ns) -- this corresponds to 234 clock periods (13 per bit). -- Messages may closely follow each other (no pause is -- required in between). The internal counters are reset -- after each word transmission, thus the errors due to -- the frequency mismatch do not accumulate. -- -- Bit_0 in the data package is a wake-up signal. -- The single event upsets can falsificate the beginning -- of the new frame, but nothing should happen if their -- frequency is less than 50 kHz / 1 mm^2 (approximate -- area of the CAN receiver chip) that corresponds already -- to a very high radiation background - this is a HERA -- limit for the 20 cm^2 radiation monitor. The key-code -- could be used - to be investigated... -- -- Bit_1 - Write command -- Bit_2 ... Bit_8 - RAM address; -- Bit_9 ... Bit_16 - Data. -- Bit_17 - end of package, sleep-down. -------------------------------------------- -- Copyright I.Tsurin, University of Antwerpen, -- on behalf of DESY. -------------------------------------------- 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 Newctr is port( P50_Ok: in std_logic; -- Power watchdog On/Off = 1/0; P33_Ok: in std_logic; -- Power watchdog On/Off = 1/0; P25_Ok: in std_logic; -- Power watchdog On/Off = 1/0; P18_Ok: in std_logic; -- Power watchdog On/Off = 1/0; DS_Ok: in std_logic; -- Power watchdog On/Off = 1/0; DD_Ok: in std_logic; -- Power watchdog On/Off = 1/0; AS_Ok: in std_logic; -- Power watchdog On/Off = 1/0; AD_Ok: in std_logic; -- Power watchdog On/Off = 1/0; TCLK: in std_logic; -- HERA clock frequency (main clock); TXD: out std_logic; -- Serial interface output; RXD: in std_logic; -- serial interface input; LAM_PDS: out std_logic; -- "Look at mee request" after download; LAM_APX: out std_logic; -- gate for the trigger signals; DAT_STB: out std_logic; -- ASICs write strobe (common for all); STB_RES: out std_logic; -- ASICs write strobe (spare signal); Dig_PR: out std_logic; -- Digital power control (spare signal); Dig_NR: out std_logic; -- Digital power control (spare signal); Ana_PR: out std_logic; -- Analog power control (spare signal); Ana_NR: out std_logic; -- Analog power control (spare signal); RegIn03: out std_logic; -- | RegIn13: out std_logic; -- | RegIn02: out std_logic; -- | RegIn12: out std_logic; -- | Data sent to ASICs; RegIn01: out std_logic; -- | RegIn11: out std_logic; -- | RegIn00: out std_logic; -- | RegIn10: out std_logic; -- | CH_PUMP0: out std_logic; -- | CH_PUMP1: out std_logic; -- | CH_PUMP2: out std_logic; -- | CH_PUMP3: out std_logic; -- | charge pumps CH_PUMP4: out std_logic; -- | for thresholds; CH_PUMP5: out std_logic; -- | CH_PUMP6: out std_logic; -- | CH_PUMP7: out std_logic; -- | RgOut00: in std_logic; -- | RgOut10: in std_logic; -- | RgOut01: in std_logic; -- | RgOut11: in std_logic; -- | Data reading from ASICs; RgOut02: in std_logic; -- | RgOut12: in std_logic; -- | RgOut03: in std_logic; -- | RgOut13: in std_logic; -- | Ana_NON: out std_logic; -- Analog power control (negative); Ana_PON: out std_logic; -- Analog power control (positive); Dig_NON: out std_logic; -- Digital power control (negative); Dig_PON: out std_logic; -- Digital power control (positive); CalEn: out std_logic; -- Cal. pulse Enable/Disable = 1/0; HYB_STA: out std_logic_vector(7 downto 0); APEX_T0: out std_logic_vector(4 downto 0); ACX_APX: in std_logic_vector(3 downto 0); Cglobal: in std_logic ); attribute pinnum: string; attribute pinnum of P50_Ok: signal is "9"; attribute pinnum of P33_Ok: signal is "10"; attribute pinnum of P25_Ok: signal is "12"; attribute pinnum of P18_Ok: signal is "13"; attribute pinnum of DS_Ok: signal is "17"; attribute pinnum of DD_Ok: signal is "18"; attribute pinnum of AS_Ok: signal is "19"; attribute pinnum of AD_Ok: signal is "20"; attribute pinnum of TCLK: signal is "21"; attribute pinnum of TXD: signal is "22"; attribute pinnum of RXD: signal is "26"; attribute pinnum of LAM_PDS: signal is "38"; attribute pinnum of LAM_APX: signal is "72"; attribute pinnum of DAT_STB: signal is "39"; attribute pinnum of STB_RES: signal is "41"; attribute pinnum of Dig_PR: signal is "49"; attribute pinnum of Dig_NR: signal is "51"; attribute pinnum of Ana_PR: signal is "59"; attribute pinnum of Ana_NR: signal is "60"; attribute pinnum of RegIn03: signal is "62"; attribute pinnum of RegIn13: signal is "63"; attribute pinnum of RegIn02: signal is "64"; attribute pinnum of RegIn12: signal is "65"; attribute pinnum of RegIn01: signal is "67"; attribute pinnum of RegIn11: signal is "68"; attribute pinnum of RegIn00: signal is "69"; attribute pinnum of RegIn10: signal is "70"; attribute pinnum of CH_PUMP7: signal is "92"; attribute pinnum of CH_PUMP6: signal is "95"; attribute pinnum of CH_PUMP5: signal is "96"; attribute pinnum of CH_PUMP4: signal is "97"; attribute pinnum of CH_PUMP3: signal is "91"; attribute pinnum of CH_PUMP2: signal is "90"; attribute pinnum of CH_PUMP1: signal is "89"; attribute pinnum of CH_PUMP0: signal is "88"; attribute pinnum of RgOut00: signal is "130"; attribute pinnum of RgOut10: signal is "131"; attribute pinnum of RgOut01: signal is "132"; attribute pinnum of RgOut11: signal is "133"; attribute pinnum of RgOut02: signal is "135"; attribute pinnum of RgOut12: signal is "136"; attribute pinnum of RgOut03: signal is "137"; attribute pinnum of RgOut13: signal is "138"; attribute pinnum of Ana_NON: signal is "109"; attribute pinnum of Ana_PON: signal is "110"; attribute pinnum of Dig_NON: signal is "111"; attribute pinnum of Dig_PON: signal is "112"; attribute pinnum of CalEn: signal is "140"; attribute pinnum of HYB_STA: signal is "36,33,32,31,30,29,28,23"; attribute pinnum of APEX_T0: signal is "117,102,101,100,99"; attribute pinnum of ACX_APX: signal is "98,81,80,73"; attribute pinnum of Cglobal: signal is "27"; end; architecture behavior of Newctr is -- internal frequency and strobe pulse -------------------------------------------- signal STB_CNT: natural range 0 to 8191; -- frequency division signal; signal Clock: std_logic; -- Synchronizes RAM readout; signal Strobe: std_logic; -- Latches data in DAC and ASICs; -------------------------------------------- -- Initialization -------------------------------------------- signal DUM_RES: std_logic; signal RES_PUL: std_logic; signal RES_DEL: std_logic; signal INI_CNT: natural range 0 to 511; -- for 0.5 seconds period with -- the 1 kHz internal frequency; -------------------------------------------- -- Power variables -------------------------------------------- signal PWR_REG: std_logic_vector(7 downto 0); -- Power supply failure latch; signal WDG_RES: std_logic; -- Reset power watchdogs; signal Power: std_logic; -- Vital power supply check; -------------------------------------------- -- Communication tools -------------------------------------------- signal FED_CNT: natural range 0 to 255; signal IAM_BSY: std_logic; signal FED_END: std_logic; signal Write: std_logic; signal INP_ADR: std_logic_vector(6 downto 0); signal INP_DAT: std_logic_vector(7 downto 0); -------------------------------------------- -- Memory access variables -------------------------------------------- signal REG_ADR: natural range 0 to 127; signal RDA_BUF: std_logic_vector(6 downto 0); -- Multiplexed addr buffer; signal REG_DAT: std_logic_vector(7 downto 0); -- Multiplexed data buffer; -------------------------------------------- -- State machine variables -------------------------------------------- signal CTR_REG: std_logic_vector(7 downto 0); signal COM_INI: natural range 0 to 2047; -- Start address for subroutine; signal COM_LIM: natural range 0 to 2047; -- Stop address for subroutine; signal PRE_SET: std_logic; signal SET_DEF: std_logic; signal ACT_PUL: std_logic; signal COM_GTE: std_logic; -- Counter increment enable; signal COM_LDE: std_logic; -- Counter load enable; signal COM_CNT: natural range 0 to 2047; -- COM_CNT = 2 - turn off an. and dig.; -- COM_CNT = 511 - turn on analog supply; -- COM_CNT = 1279 - turn on digital supply; -- COM_CNT = 1824 - reset power watchdogs, -- open gate for strobes; -- COM_CNT = 1896 - close gate for strobes; -- COM_CNT = 1897 - stop command counter; -------------------------- -- COM_CNT = 1898 - start command counter -- COM_CNT = 1899 - first PRO/A data, open gate for strobes; -- ... -- COM_CNT = 1963 - enable calibration regime; -- ... -- COM_CNT = 1970 - last PRO/A data; -- COM_CNT = 1971 - close gate for strobes; -- COM_CNT = 1972 - stop command counter; -------------------------- -- COM_CNT = 1973 - clear Status register; -- COM_CNT = 1974 - first PRO/A data, open gate for strobes; -- ... -- COM_CNT = 2045 - last PRO/A data; -- COM_CNT = 2046 - close gate for strobes; -- COM_CNT = 2047 - stop command counter; -------------------------------------------- -- Executable module variables -------------------------------------------- signal HYB_GTE: std_logic; -- Gate for the ASICs strobe; signal CMP_REG: std_logic_vector(7 downto 0); -- Register for the online data check; signal SET_H7: std_logic; -- | signal SET_H6: std_logic; -- | signal SET_H5: std_logic; -- | signal SET_H4: std_logic; -- | Current data for every hybrid; signal SET_H3: std_logic; -- | signal SET_H2: std_logic; -- | signal SET_H1: std_logic; -- | signal SET_H0: std_logic; -- | signal GET_H7: std_logic; -- | signal GET_H6: std_logic; -- | signal GET_H5: std_logic; -- | signal GET_H4: std_logic; -- | Buffered readout data; signal GET_H3: std_logic; -- | signal GET_H2: std_logic; -- | signal GET_H1: std_logic; -- | signal GET_H0: std_logic; -- | -------------------------------------------- -- Charge pump variables for thresholds -------------------------------------------- signal THR_R00: std_logic_vector(7 downto 0); signal THR_R01: std_logic_vector(7 downto 0); signal THR_R02: std_logic_vector(7 downto 0); signal THR_R03: std_logic_vector(7 downto 0); signal THR_R10: std_logic_vector(7 downto 0); signal THR_R11: std_logic_vector(7 downto 0); signal THR_R12: std_logic_vector(7 downto 0); signal THR_R13: std_logic_vector(7 downto 0); signal THR_CNT: natural range 0 to 255; signal THR_REG: std_logic_vector(7 downto 0); -------------------------------------------- -- PRO/A data -------------------------------------------- signal TestEna03: std_logic_vector(7 downto 0); signal TestEna02: std_logic_vector(7 downto 0); signal TestEna01: std_logic_vector(7 downto 0); signal TestEna00: std_logic_vector(7 downto 0); signal TestEna23: std_logic_vector(7 downto 0); signal TestEna22: std_logic_vector(7 downto 0); signal TestEna21: std_logic_vector(7 downto 0); signal TestEna20: std_logic_vector(7 downto 0); signal TestEna43: std_logic_vector(7 downto 0); signal TestEna42: std_logic_vector(7 downto 0); signal TestEna41: std_logic_vector(7 downto 0); signal TestEna40: std_logic_vector(7 downto 0); signal TestEna63: std_logic_vector(7 downto 0); signal TestEna62: std_logic_vector(7 downto 0); signal TestEna61: std_logic_vector(7 downto 0); signal TestEna60: std_logic_vector(7 downto 0); signal TestEna70: std_logic_vector(7 downto 0); signal TestEna71: std_logic_vector(7 downto 0); signal TestEna72: std_logic_vector(7 downto 0); signal TestEna73: std_logic_vector(7 downto 0); signal TestEna50: std_logic_vector(7 downto 0); signal TestEna51: std_logic_vector(7 downto 0); signal TestEna52: std_logic_vector(7 downto 0); signal TestEna53: std_logic_vector(7 downto 0); signal TestEna30: std_logic_vector(7 downto 0); signal TestEna31: std_logic_vector(7 downto 0); signal TestEna32: std_logic_vector(7 downto 0); signal TestEna33: std_logic_vector(7 downto 0); signal TestEna10: std_logic_vector(7 downto 0); signal TestEna11: std_logic_vector(7 downto 0); signal TestEna12: std_logic_vector(7 downto 0); signal TestEna13: std_logic_vector(7 downto 0); signal OutDis03: std_logic_vector(7 downto 0); signal OutDis02: std_logic_vector(7 downto 0); signal OutDis01: std_logic_vector(7 downto 0); signal OutDis00: std_logic_vector(7 downto 0); signal OutDis23: std_logic_vector(7 downto 0); signal OutDis22: std_logic_vector(7 downto 0); signal OutDis21: std_logic_vector(7 downto 0); signal OutDis20: std_logic_vector(7 downto 0); signal OutDis43: std_logic_vector(7 downto 0); signal OutDis42: std_logic_vector(7 downto 0); signal OutDis41: std_logic_vector(7 downto 0); signal OutDis40: std_logic_vector(7 downto 0); signal OutDis63: std_logic_vector(7 downto 0); signal OutDis62: std_logic_vector(7 downto 0); signal OutDis61: std_logic_vector(7 downto 0); signal OutDis60: std_logic_vector(7 downto 0); signal OutDis70: std_logic_vector(7 downto 0); signal OutDis71: std_logic_vector(7 downto 0); signal OutDis72: std_logic_vector(7 downto 0); signal OutDis73: std_logic_vector(7 downto 0); signal OutDis50: std_logic_vector(7 downto 0); signal OutDis51: std_logic_vector(7 downto 0); signal OutDis52: std_logic_vector(7 downto 0); signal OutDis53: std_logic_vector(7 downto 0); signal OutDis30: std_logic_vector(7 downto 0); signal OutDis31: std_logic_vector(7 downto 0); signal OutDis32: std_logic_vector(7 downto 0); signal OutDis33: std_logic_vector(7 downto 0); signal OutDis10: std_logic_vector(7 downto 0); signal OutDis11: std_logic_vector(7 downto 0); signal OutDis12: std_logic_vector(7 downto 0); signal OutDis13: std_logic_vector(7 downto 0); signal CAL_ENA: std_logic_vector(7 downto 0); signal CUR_COM: std_logic_vector(7 downto 0); signal GAIN_S0: std_logic_vector(7 downto 0); signal GAIN_S1: std_logic_vector(7 downto 0); signal ANS_ENA: std_logic_vector(7 downto 0); signal IND_MOD: std_logic_vector(7 downto 0); signal NEG_POL: std_logic_vector(7 downto 0); signal TOT_MOD: std_logic_vector(7 downto 0); -------------------------------------------- -- Readout steering -------------------------------------------- signal PIP_SEL: std_logic_vector(4 downto 0); -------------------------------------------- -- Data type conversion: -- binary#7 -> natural -------------------------------------------- function BIT7_to_NUM(BIT_ARR: std_logic_vector(6 downto 0)) return natural is variable TEMP: natural range 0 to 127; begin TEMP:=0; for I in BIT_ARR'range loop TEMP:= TEMP * 2; if (BIT_ARR(I) = '1') then TEMP:= TEMP + 1; else null; end if; end loop; return TEMP; end BIT7_to_NUM; -------------------------------------------- begin -- Permanent statements -------------------------------------------- DUM_RES <= '0'; ------------------------- Dig_PR <= '0'; Dig_NR <= '0'; Ana_PR <= '0'; Ana_NR <= '0'; STB_RES <= '0'; ------------------------- SET_H7 <= REG_DAT(7); SET_H6 <= REG_DAT(6); SET_H5 <= REG_DAT(5); SET_H4 <= REG_DAT(4); SET_H3 <= REG_DAT(3); SET_H2 <= REG_DAT(2); SET_H1 <= REG_DAT(1); SET_H0 <= REG_DAT(0); ------------------------- HYB_STA <= CMP_REG; APEX_T0 <= PIP_SEL; -------------------------------------------- -- HERA clock frequency division (TCLK ->) -------------------------------------------- process(TCLK) begin if (TCLK'event and TCLK = '1') then STB_CNT <= STB_CNT + 1; end if; end process; -------------------------------------------- -- Generating internal frequency -- and PRO/A data strobe (TCLK <-) -------------------------------------------- process(TCLK, STB_CNT) begin if (TCLK'event and TCLK = '0') then if (STB_CNT = 0) then Clock <= '1'; Strobe <= '0'; elsif (STB_CNT = 1638) then Clock <= '1'; Strobe <= '1'; elsif (STB_CNT = 3276) then Clock <= '1'; Strobe <= '0'; elsif (STB_CNT = 4914) then Clock <= '0'; Strobe <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Start-up counter (Clock ->), (TCLK <-) -------------------------------------------- process(DUM_RES, Clock, RES_PUL) begin if (DUM_RES = '1') then INI_CNT <= 0; elsif (Clock'event and Clock = '1') then if (RES_PUL = '1') then INI_CNT <= INI_CNT + 1; else null; end if; end if; end process; -------------------------------------------- -- Start-up reset pulse -- (Clock <-), (TCLK <-) -------------------------------------------- process(DUM_RES, Clock, INI_CNT) begin if (DUM_RES = '1') then RES_PUL <= '1'; elsif (Clock'event and Clock = '0') then if (INI_CNT = 511) then RES_PUL <= '0'; else RES_PUL <= '1'; end if; end if; end process; -------------------------- process(TCLK, RES_PUL) begin if (TCLK'event and TCLK = '1') then RES_DEL <= RES_PUL; end if; end process; -------------------------------------------- -- Wake up - set busy, blocked by -- the state machine when running -------------------------------------------- process(RES_DEL, FED_END, RXD, COM_GTE) begin if (RES_DEL = '1' or FED_END = '1') then IAM_BSY <= '0'; elsif (RXD'event and RXD = '0') then if (COM_GTE = '0') then IAM_BSY <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Frame counter -------------------------------------------- process(TCLK, IAM_BSY) begin if (TCLK'event and TCLK = '0') then if (IAM_BSY = '1') then FED_CNT <= FED_CNT + 1; else FED_CNT <= 0; end if; end if; end process; -------------------------------------------- -- End of frame signal (TCLK ->) -------------------------------------------- process(TCLK, FED_CNT) begin if (TCLK'event and TCLK = '1') then if (FED_CNT = 221) then FED_END <= '1'; else FED_END <= '0'; end if; end if; end process; -------------------------------------------- -- Latching serial address (TCLK ->) -------------------------------------------- process(TCLK, FED_CNT, RXD) begin if (TCLK'event and TCLK = '1') then case FED_CNT is when 20 => Write <= not RXD; when 33 => INP_ADR(6) <= not RXD; when 46 => INP_ADR(5) <= not RXD; when 59 => INP_ADR(4) <= not RXD; when 72 => INP_ADR(3) <= not RXD; when 85 => INP_ADR(2) <= not RXD; when 98 => INP_ADR(1) <= not RXD; when 111 => INP_ADR(0) <= not RXD; when others => null; end case; end if; end process; -------------------------------------------- -- Latching serial data (TCLK ->) -------------------------------------------- process(TCLK, Write, FED_CNT, RXD) begin if (TCLK'event and TCLK = '1') then if (Write = '1') then case FED_CNT is when 124 => INP_DAT(7) <= not RXD; when 137 => INP_DAT(6) <= not RXD; when 150 => INP_DAT(5) <= not RXD; when 163 => INP_DAT(4) <= not RXD; when 176 => INP_DAT(3) <= not RXD; when 189 => INP_DAT(2) <= not RXD; when 202 => INP_DAT(1) <= not RXD; when 215 => INP_DAT(0) <= not RXD; when others => null; end case; else null; end if; end if; end process; -------------------------------------------- -- Pushing out serial data (TCLK ->) -------------------------------------------- process(Write, FED_CNT, TCLK, REG_DAT) begin if (Write = '1' or FED_CNT <= 117) then TXD <= '1'; elsif (TCLK'event and TCLK = '1') then case FED_CNT is when 118 => TXD <= not REG_DAT(7); when 131 => TXD <= not REG_DAT(6); when 144 => TXD <= not REG_DAT(5); when 157 => TXD <= not REG_DAT(4); when 170 => TXD <= not REG_DAT(3); when 183 => TXD <= not REG_DAT(2); when 196 => TXD <= not REG_DAT(1); when 209 => TXD <= not REG_DAT(0); when 221 => TXD <= '1'; when others => null; end case; end if; end process; -------------------------------------------- -- Assign registers (TCLK ->) -------------------------------------------- process(RES_PUL, SET_DEF, TCLK, Write, FED_CNT, REG_ADR, INP_DAT) begin if (RES_PUL = '1' or SET_DEF = '1') then CTR_REG <= "00000111"; -- Reset power, load & check; THR_R00 <= "11001000"; -- -200 mV default threshold; THR_R01 <= "11001000"; -- -200 mV default threshold; THR_R02 <= "11001000"; -- -200 mV default threshold; THR_R03 <= "11001000"; -- -200 mV default threshold; THR_R10 <= "11001000"; -- -200 mV default threshold; THR_R11 <= "11001000"; -- -200 mV default threshold; THR_R12 <= "11001000"; -- -200 mV default threshold; THR_R13 <= "11001000"; -- -200 mV default threshold; TestEna03 <= (others => '0'); TestEna02 <= (others => '0'); TestEna01 <= (others => '0'); TestEna00 <= (others => '0'); TestEna23 <= (others => '0'); TestEna22 <= (others => '0'); TestEna21 <= (others => '0'); TestEna20 <= (others => '0'); TestEna43 <= (others => '0'); TestEna42 <= (others => '0'); TestEna41 <= (others => '0'); TestEna40 <= (others => '0'); TestEna63 <= (others => '0'); TestEna62 <= (others => '0'); TestEna61 <= (others => '0'); TestEna60 <= (others => '0'); TestEna70 <= (others => '0'); TestEna71 <= (others => '0'); TestEna72 <= (others => '0'); TestEna73 <= (others => '0'); TestEna50 <= (others => '0'); TestEna51 <= (others => '0'); TestEna52 <= (others => '0'); TestEna53 <= (others => '0'); TestEna30 <= (others => '0'); TestEna31 <= (others => '0'); TestEna32 <= (others => '0'); TestEna33 <= (others => '0'); TestEna10 <= (others => '0'); TestEna11 <= (others => '0'); TestEna12 <= (others => '0'); TestEna13 <= (others => '0'); OutDis03 <= (others => '0'); OutDis02 <= (others => '0'); OutDis01 <= (others => '0'); OutDis00 <= (others => '0'); OutDis23 <= (others => '0'); OutDis22 <= (others => '0'); OutDis21 <= (others => '0'); OutDis20 <= (others => '0'); OutDis43 <= (others => '0'); OutDis42 <= (others => '0'); OutDis41 <= (others => '0'); OutDis40 <= (others => '0'); OutDis63 <= (others => '0'); OutDis62 <= (others => '0'); OutDis61 <= (others => '0'); OutDis60 <= (others => '0'); OutDis70 <= (others => '0'); OutDis71 <= (others => '0'); OutDis72 <= (others => '0'); OutDis73 <= (others => '0'); OutDis50 <= (others => '0'); OutDis51 <= (others => '0'); OutDis52 <= (others => '0'); OutDis53 <= (others => '0'); OutDis30 <= (others => '0'); OutDis31 <= (others => '0'); OutDis32 <= (others => '0'); OutDis33 <= (others => '0'); OutDis10 <= (others => '0'); OutDis11 <= (others => '0'); OutDis12 <= (others => '0'); OutDis13 <= (others => '0'); CAL_ENA <= (others => '0'); CUR_COM <= (others => '0'); GAIN_S0 <= (others => '0'); GAIN_S1 <= (others => '0'); ANS_ENA <= (others => '0'); IND_MOD <= (others => '0'); NEG_POL <= (others => '0'); TOT_MOD <= (others => '0'); PIP_SEL <= "11011"; -- 27 dec; elsif (TCLK'event and TCLK = '1') then if (Write = '1' and FED_CNT = 220) then case REG_ADR is when 90 => PIP_SEL(4 downto 0) <= INP_DAT(4 downto 0); when 86 => CTR_REG <= INP_DAT; when 3 => THR_R00 <= INP_DAT; when 4 => THR_R01 <= INP_DAT; when 5 => THR_R02 <= INP_DAT; when 6 => THR_R03 <= INP_DAT; when 7 => THR_R10 <= INP_DAT; when 8 => THR_R11 <= INP_DAT; when 9 => THR_R12 <= INP_DAT; when 10 => THR_R13 <= INP_DAT; when 12 => TestEna03 <= INP_DAT; when 13 => TestEna02 <= INP_DAT; when 14 => TestEna01 <= INP_DAT; when 15 => TestEna00 <= INP_DAT; when 16 => TestEna23 <= INP_DAT; when 17 => TestEna22 <= INP_DAT; when 18 => TestEna21 <= INP_DAT; when 19 => TestEna20 <= INP_DAT; when 20 => TestEna43 <= INP_DAT; when 21 => TestEna42 <= INP_DAT; when 22 => TestEna41 <= INP_DAT; when 23 => TestEna40 <= INP_DAT; when 24 => TestEna63 <= INP_DAT; when 25 => TestEna62 <= INP_DAT; when 26 => TestEna61 <= INP_DAT; when 27 => TestEna60 <= INP_DAT; when 28 => TestEna70 <= INP_DAT; when 29 => TestEna71 <= INP_DAT; when 30 => TestEna72 <= INP_DAT; when 31 => TestEna73 <= INP_DAT; when 32 => TestEna50 <= INP_DAT; when 33 => TestEna51 <= INP_DAT; when 34 => TestEna52 <= INP_DAT; when 35 => TestEna53 <= INP_DAT; when 36 => TestEna30 <= INP_DAT; when 37 => TestEna31 <= INP_DAT; when 38 => TestEna32 <= INP_DAT; when 39 => TestEna33 <= INP_DAT; when 40 => TestEna10 <= INP_DAT; when 41 => TestEna11 <= INP_DAT; when 42 => TestEna12 <= INP_DAT; when 43 => TestEna13 <= INP_DAT; when 44 => OutDis03 <= INP_DAT; when 45 => OutDis02 <= INP_DAT; when 46 => OutDis01 <= INP_DAT; when 47 => OutDis00 <= INP_DAT; when 48 => OutDis23 <= INP_DAT; when 49 => OutDis22 <= INP_DAT; when 50 => OutDis21 <= INP_DAT; when 51 => OutDis20 <= INP_DAT; when 52 => OutDis43 <= INP_DAT; when 53 => OutDis42 <= INP_DAT; when 54 => OutDis41 <= INP_DAT; when 55 => OutDis40 <= INP_DAT; when 56 => OutDis63 <= INP_DAT; when 57 => OutDis62 <= INP_DAT; when 58 => OutDis61 <= INP_DAT; when 59 => OutDis60 <= INP_DAT; when 60 => OutDis70 <= INP_DAT; when 61 => OutDis71 <= INP_DAT; when 62 => OutDis72 <= INP_DAT; when 63 => OutDis73 <= INP_DAT; when 64 => OutDis50 <= INP_DAT; when 65 => OutDis51 <= INP_DAT; when 66 => OutDis52 <= INP_DAT; when 67 => OutDis53 <= INP_DAT; when 68 => OutDis30 <= INP_DAT; when 69 => OutDis31 <= INP_DAT; when 70 => OutDis32 <= INP_DAT; when 71 => OutDis33 <= INP_DAT; when 72 => OutDis10 <= INP_DAT; when 73 => OutDis11 <= INP_DAT; when 74 => OutDis12 <= INP_DAT; when 75 => OutDis13 <= INP_DAT; when 76 => CAL_ENA <= INP_DAT; when 77 => CUR_COM <= INP_DAT; when 78 => GAIN_S0 <= INP_DAT; when 79 => GAIN_S1 <= INP_DAT; when 80 => ANS_ENA <= INP_DAT; when 81 => IND_MOD <= INP_DAT; when 82 => NEG_POL <= INP_DAT; when 83 => TOT_MOD <= INP_DAT; when others => null; end case; else null; end if; end if; end process; -------------------------------------------- -- Select registers (Clock <-) (TCLK <-) -------------------------------------------- process(REG_ADR, PIP_SEL, CTR_REG, PWR_REG, CMP_REG, THR_R00, THR_R01, THR_R02, THR_R03, THR_R10, THR_R11, THR_R12, THR_R13, TestEna03, TestEna02, TestEna01, TestEna00, TestEna23, TestEna22, TestEna21, TestEna20, TestEna43, TestEna42, TestEna41, TestEna40, TestEna63, TestEna62, TestEna61, TestEna60, TestEna70, TestEna71, TestEna72, TestEna73, TestEna50, TestEna51, TestEna52, TestEna53, TestEna30, TestEna31, TestEna32, TestEna33, TestEna10, TestEna11, TestEna12, TestEna13, OutDis03, OutDis02, OutDis01, OutDis00, OutDis23, OutDis22, OutDis21, OutDis20, OutDis43, OutDis42, OutDis41, OutDis40, OutDis63, OutDis62, OutDis61, OutDis60, OutDis70, OutDis71, OutDis72, OutDis73, OutDis50, OutDis51, OutDis52, OutDis53, OutDis30, OutDis31, OutDis32, OutDis33, OutDis10, OutDis11, OutDis12, OutDis13, CAL_ENA, CUR_COM, GAIN_S0, GAIN_S1, ANS_ENA, IND_MOD, NEG_POL, TOT_MOD) begin case REG_ADR is when 90 => REG_DAT(7 downto 5) <= "000"; REG_DAT(4 downto 0) <= PIP_SEL(4 downto 0); when 86 => REG_DAT <= CTR_REG; when 1 => REG_DAT <= PWR_REG; when 2 => REG_DAT <= CMP_REG; when 3 => REG_DAT <= THR_R00; when 4 => REG_DAT <= THR_R01; when 5 => REG_DAT <= THR_R02; when 6 => REG_DAT <= THR_R03; when 7 => REG_DAT <= THR_R10; when 8 => REG_DAT <= THR_R11; when 9 => REG_DAT <= THR_R12; when 10 => REG_DAT <= THR_R13; when 12 => REG_DAT <= TestEna03; when 13 => REG_DAT <= TestEna02; when 14 => REG_DAT <= TestEna01; when 15 => REG_DAT <= TestEna00; when 16 => REG_DAT <= TestEna23; when 17 => REG_DAT <= TestEna22; when 18 => REG_DAT <= TestEna21; when 19 => REG_DAT <= TestEna20; when 20 => REG_DAT <= TestEna43; when 21 => REG_DAT <= TestEna42; when 22 => REG_DAT <= TestEna41; when 23 => REG_DAT <= TestEna40; when 24 => REG_DAT <= TestEna63; when 25 => REG_DAT <= TestEna62; when 26 => REG_DAT <= TestEna61; when 27 => REG_DAT <= TestEna60; when 28 => REG_DAT <= TestEna70; when 29 => REG_DAT <= TestEna71; when 30 => REG_DAT <= TestEna72; when 31 => REG_DAT <= TestEna73; when 32 => REG_DAT <= TestEna50; when 33 => REG_DAT <= TestEna51; when 34 => REG_DAT <= TestEna52; when 35 => REG_DAT <= TestEna53; when 36 => REG_DAT <= TestEna30; when 37 => REG_DAT <= TestEna31; when 38 => REG_DAT <= TestEna32; when 39 => REG_DAT <= TestEna33; when 40 => REG_DAT <= TestEna10; when 41 => REG_DAT <= TestEna11; when 42 => REG_DAT <= TestEna12; when 43 => REG_DAT <= TestEna13; when 44 => REG_DAT <= OutDis03; when 45 => REG_DAT <= OutDis02; when 46 => REG_DAT <= OutDis01; when 47 => REG_DAT <= OutDis00; when 48 => REG_DAT <= OutDis23; when 49 => REG_DAT <= OutDis22; when 50 => REG_DAT <= OutDis21; when 51 => REG_DAT <= OutDis20; when 52 => REG_DAT <= OutDis43; when 53 => REG_DAT <= OutDis42; when 54 => REG_DAT <= OutDis41; when 55 => REG_DAT <= OutDis40; when 56 => REG_DAT <= OutDis63; when 57 => REG_DAT <= OutDis62; when 58 => REG_DAT <= OutDis61; when 59 => REG_DAT <= OutDis60; when 60 => REG_DAT <= OutDis70; when 61 => REG_DAT <= OutDis71; when 62 => REG_DAT <= OutDis72; when 63 => REG_DAT <= OutDis73; when 64 => REG_DAT <= OutDis50; when 65 => REG_DAT <= OutDis51; when 66 => REG_DAT <= OutDis52; when 67 => REG_DAT <= OutDis53; when 68 => REG_DAT <= OutDis30; when 69 => REG_DAT <= OutDis31; when 70 => REG_DAT <= OutDis32; when 71 => REG_DAT <= OutDis33; when 72 => REG_DAT <= OutDis10; when 73 => REG_DAT <= OutDis11; when 74 => REG_DAT <= OutDis12; when 75 => REG_DAT <= OutDis13; when 76 => REG_DAT <= CAL_ENA; when 77 => REG_DAT <= CUR_COM; when 78 => REG_DAT <= GAIN_S0; when 79 => REG_DAT <= GAIN_S1; when 80 => REG_DAT <= ANS_ENA; when 81 => REG_DAT <= IND_MOD; when 82 => REG_DAT <= NEG_POL; when 83 => REG_DAT <= TOT_MOD; when others => REG_DAT <= (others => '0'); end case; end process; -------------------------------------------- -- Activate default settings (TCLK ->) -------------------------------------------- process(TCLK, Write, FED_CNT, REG_ADR) begin if (TCLK'event and TCLK = '1') then if (Write = '1' and FED_CNT = 119 and REG_ADR = 85) then PRE_SET <= '1'; else PRE_SET <= '0'; end if; end if; end process; -------------------------- process(TCLK, PRE_SET) begin if (TCLK'event and TCLK = '0') then SET_DEF <= PRE_SET; end if; end process; -------------------------------------------- -- Comand launch pulse (TCLK ->) -------------------------------------------- process(TCLK, Write, FED_CNT, REG_ADR) begin if (TCLK'event and TCLK = '1') then if (Write = '1' and FED_CNT = 221 and REG_ADR = 86) then ACT_PUL <= '1'; else ACT_PUL <= '0'; end if; end if; end process; -------------------------------------------- -- Gate for the command counter -------------------------------------------- process(RES_DEL, ACT_PUL, Clock, COM_CNT, COM_LIM) begin if (RES_DEL = '1' or ACT_PUL = '1') then COM_GTE <= '1'; elsif (Clock'event and Clock = '1') then if (COM_CNT = COM_LIM) then COM_GTE <= '0'; else null; end if; end if; end process; -------------------------------------------- -- Command counter (Clock <-), (TCLK <-) -------------------------------------------- process(RES_DEL, ACT_PUL, Clock, COM_LDE, COM_INI, COM_GTE) begin if (RES_DEL = '1' or ACT_PUL = '1') then COM_CNT <= 0; elsif (Clock'event and Clock = '0') then if (COM_LDE = '1') then COM_CNT <= COM_INI; elsif (COM_GTE = '1') then COM_CNT <= COM_CNT + 1; else null; end if; end if; end process; -------------------------------------------- -- Counter load enable -------------------------------------------- process(Clock, COM_CNT) begin if (Clock'event and Clock = '1') then if (COM_CNT = 1) then COM_LDE <= '1'; else COM_LDE <= '0'; end if; end if; end process; -------------------------------------------- -- Counter limits -------------------------------------------- process(CTR_REG) begin case CTR_REG is when "00000001" => -- reset only COM_INI <= 2; COM_LIM <= 1897; when "00000010" => -- load ASICs only COM_INI <= 1898; COM_LIM <= 1972; when "00000011" => -- reset and load ASICs COM_INI <= 2; COM_LIM <= 1972; when "00000100" => -- read ASICs only COM_INI <= 1973; COM_LIM <= 2047; when "00000101" => -- reset and read ASICs COM_INI <= 2; -- (impractical action) COM_LIM <= 2047; when "00000110" => -- load and read ASICs COM_INI <= 1898; COM_LIM <= 2047; when "00000111" => -- reset, load and read COM_INI <= 2; COM_LIM <= 2047; when others => -- do nothing; COM_INI <= 2047; COM_LIM <= 2047; end case; end process; -------------------------------------------- -- LAM generation -------------------------------------------- LAM_PDS <= Power and (not COM_GTE); LAM_APX <= not COM_GTE; -------------------------------------------- -- Analog distribution box -------------------------------------------- process(Clock, COM_CNT) begin if (Clock'event and Clock = '1') then if (COM_CNT = 2) then Ana_PON <= '0'; Ana_NON <= '0'; elsif (COM_CNT = 511) then Ana_PON <= '1'; Ana_NON <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Digital distribution box -------------------------------------------- process(Clock, COM_CNT, AS_Ok, AD_Ok) begin if (Clock'event and Clock = '1') then if (COM_CNT = 2) then Dig_PON <= '0'; Dig_NON <= '0'; elsif (COM_CNT = 1279 and AS_Ok = '1' and AD_Ok = '1') then Dig_PON <= '1'; Dig_NON <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Power failure latch -------------------------------------------- process(P50_Ok, WDG_RES) begin if (P50_Ok = '0') then PWR_REG(7) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(7) <= '1'; end if; end process; -------------------------- process(P33_Ok, WDG_RES) begin if (P33_Ok = '0') then PWR_REG(6) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(6) <= '1'; end if; end process; -------------------------- process(P25_Ok, WDG_RES) begin if (P25_Ok = '0') then PWR_REG(5) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(5) <= '1'; end if; end process; -------------------------- process(P18_Ok, WDG_RES) begin if (P18_Ok = '0') then PWR_REG(4) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(4) <= '1'; end if; end process; -------------------------- process(DS_Ok, WDG_RES) begin if (DS_Ok = '0') then PWR_REG(3) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(3) <= '1'; end if; end process; -------------------------- process(DD_Ok, WDG_RES) begin if (DD_Ok = '0') then PWR_REG(2) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(2) <= '1'; end if; end process; -------------------------- process(AS_Ok, WDG_RES) begin if (AS_Ok = '0') then PWR_REG(1) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(1) <= '1'; end if; end process; -------------------------- process(AD_Ok, WDG_RES) begin if (AD_Ok = '0') then PWR_REG(0) <= '0'; elsif (WDG_RES'event and WDG_RES = '1') then PWR_REG(0) <= '1'; end if; end process; -------------------------------------------- -- Clear watchdogs (at the end of power -- reset and after power status readout) -------------------------------------------- process(TCLK, COM_CNT, Write, REG_ADR, FED_CNT) begin if (TCLK'event and TCLK = '1') then if (COM_CNT = 1896) then WDG_RES <= '1'; elsif (Write = '0' and REG_ADR = 1 and FED_CNT = 221) then WDG_RES <= '1'; else WDG_RES <= '0'; end if; end if; end process; -------------------------------------------- -- Power control -------------------------------------------- Power <= PWR_REG(7) and PWR_REG(6) and PWR_REG(5) and PWR_REG(4) and PWR_REG(3) and PWR_REG(2) and PWR_REG(1) and PWR_REG(0); -------------------------------------------- -- Threshold's update loop -------------------------------------------- process(TCLK) begin if (TCLK'event and TCLK = '1') then THR_CNT <= THR_CNT + 1; end if; end process; -------------------------- THR_REG <= conv_std_logic_vector(THR_CNT, 8); -------------------------------------------- -- Charge pump strobe -------------------------------------------- process(THR_R00, TCLK, THR_REG) begin if (THR_R00 = "11111111") then CH_PUMP0 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R00) then CH_PUMP0 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP0 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R01, TCLK, THR_REG) begin if (THR_R01 = "11111111") then CH_PUMP1 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R01) then CH_PUMP1 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP1 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R02, TCLK, THR_REG) begin if (THR_R02 = "11111111") then CH_PUMP2 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R02) then CH_PUMP2 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP2 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R03, TCLK, THR_REG) begin if (THR_R03 = "11111111") then CH_PUMP3 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R03) then CH_PUMP3 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP3 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R10, TCLK, THR_REG) begin if (THR_R10 = "11111111") then CH_PUMP4 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R10) then CH_PUMP4 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP4 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R11, TCLK, THR_REG) begin if (THR_R11 = "11111111") then CH_PUMP5 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R11) then CH_PUMP5 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP5 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R12, TCLK, THR_REG) begin if (THR_R12 = "11111111") then CH_PUMP6 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R12) then CH_PUMP6 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP6 <= '1'; else null; end if; end if; end process; -------------------------- process(THR_R13, TCLK, THR_REG) begin if (THR_R13 = "11111111") then CH_PUMP7 <= '1'; elsif (TCLK'event and TCLK = '0') then if (THR_REG = THR_R13) then CH_PUMP7 <= '0'; elsif (THR_REG = "00000000") then CH_PUMP7 <= '1'; else null; end if; end if; end process; -------------------------------------------- -- ASICs supervisor -------------------------------------------- process(Clock, COM_CNT, SET_H7, SET_H6, SET_H5, SET_H4, SET_H3, SET_H2, SET_H1, SET_H0, GET_H7, GET_H6, GET_H5, GET_H4, GET_H3, GET_H2, GET_H1, GET_H0) begin if (Clock'event and Clock = '1') then case COM_CNT is when 1899 to 1970 => RegIn13 <= SET_H7; -- | RegIn12 <= SET_H6; -- | RegIn11 <= SET_H5; -- | RegIn10 <= SET_H4; -- | Load data from RAM RegIn03 <= SET_H3; -- | RegIn02 <= SET_H2; -- | RegIn01 <= SET_H1; -- | RegIn00 <= SET_H0; -- | when 1974 to 2045 => RegIn13 <= GET_H7; -- | RegIn12 <= GET_H6; -- | RegIn11 <= GET_H5; -- | RegIn10 <= GET_H4; -- | Rewrite ASICs data RegIn03 <= GET_H3; -- | RegIn02 <= GET_H2; -- | RegIn01 <= GET_H1; -- | RegIn00 <= GET_H0; -- | when others => RegIn13 <= '0'; RegIn12 <= '0'; RegIn11 <= '0'; RegIn10 <= '0'; RegIn03 <= '0'; RegIn02 <= '0'; RegIn01 <= '0'; RegIn00 <= '0'; end case; end if; end process; -------------------------------------------- -- Generating the data strobe (Clock ->) -- (reference values are 12 and 84 dec.) -------------------------------------------- process(Clock, COM_CNT) begin if (Clock'event and Clock = '1') then if (COM_CNT = 1824 or COM_CNT = 1899 or COM_CNT = 1974) then HYB_GTE <= '1'; elsif (COM_CNT = 1896 or COM_CNT = 1971 or COM_CNT = 2046) then HYB_GTE <= '0'; else null; end if; end if; end process; -------------------------- DAT_STB <= Strobe and HYB_GTE; -------------------------------------------- -- Calibration pulse enable (Strobe ->) (TCLK <-) -------------------------------------------- process(Strobe, COM_CNT, REG_DAT) begin if (Strobe'event and Strobe = '1') then if (COM_CNT = 1963) then if (REG_DAT = "00000000") then CalEn <= '0'; else CalEn <= '1'; end if; else null; end if; end if; end process; -------------------------------------------- -- ASICs readout buffer (Clock <-) -- (latches the previous result) -------------------------------------------- process(Clock, RgOut13, RgOut12, RgOut11, RgOut10, RgOut03, RgOut02, RgOut01, RgOut00) begin if (Clock'event and Clock = '0') then GET_H7 <= RgOut13; GET_H6 <= RgOut12; GET_H5 <= RgOut11; GET_H4 <= RgOut10; GET_H3 <= RgOut03; GET_H2 <= RgOut02; GET_H1 <= RgOut01; GET_H0 <= RgOut00; end if; end process; -------------------------------------------- -- Perform ASIC and RAM comparison -------------------------------------------- process (Strobe, COM_CNT, SET_H7, SET_H6, SET_H5, SET_H4, SET_H3, SET_H2, SET_H1, SET_H0, GET_H7, GET_H6, GET_H5, GET_H4, GET_H3, GET_H2, GET_H1, GET_H0) begin if (Strobe'event and Strobe = '1') then if (COM_CNT = 1973) then CMP_REG <= (others => '1'); elsif (1974 <= COM_CNT and COM_CNT <= 2045) then if (GET_H7 /= SET_H7) then CMP_REG(7) <= '0'; else null; end if; if (GET_H6 /= SET_H6) then CMP_REG(6) <= '0'; else null; end if; if (GET_H5 /= SET_H5) then CMP_REG(5) <= '0'; else null; end if; if (GET_H4 /= SET_H4) then CMP_REG(4) <= '0'; else null; end if; if (GET_H3 /= SET_H3) then CMP_REG(3) <= '0'; else null; end if; if (GET_H2 /= SET_H2) then CMP_REG(2) <= '0'; else null; end if; if (GET_H1 /= SET_H1) then CMP_REG(1) <= '0'; else null; end if; if (GET_H0 /= SET_H0) then CMP_REG(0) <= '0'; else null; end if; else null; end if; end if; end process; -------------------------------------------- -- Computing readout address -- for the state machine -------------------------------------------- process(COM_CNT) begin case COM_CNT is when 1899 to 1971 => RDA_BUF <= conv_std_logic_vector((COM_CNT - 1887), 7); when 1974 to 2046 => RDA_BUF <= conv_std_logic_vector((COM_CNT - 1887 - 75), 7); when others => RDA_BUF <= (others => '0'); end case; end process; -------------------------------------------- -- Multiplexing readout address -------------------------------------------- process(COM_GTE, RDA_BUF, INP_ADR) begin if (COM_GTE = '1') then REG_ADR <= BIT7_to_NUM(RDA_BUF); else REG_ADR <= BIT7_to_NUM(INP_ADR); end if; end process; -------------------------------------------- end;