***************************** * * * D-Zero Run II Upgrade * * * * Level 1 Trigger Framework * * * * and * * * * Level 2 Trigger Framework * * * * Level 1 * * Term Receiver Module FPGA * * * ***************************** Original: 2-DEC-1997 Latest: 21-NOV-2000 Introduction ------------ The L1 Term Receiver Module FPGA is used in all MSA FPGA locations on the Term Receiver Module cards Each Term Receiver Module FPGA has the following input and output connections: 1. On-Card Bus (including High-Quality Timing Signals). 2. High-Speed Readout Interface. 3. 4 Subsystem Input Input Terms (these are Main Signal Array (MSA) Input Signals). 4. 1 Subsystem Gap Marker (this is an MSA Input Signal). 5. 1 Subsystem Strobe Signal (this is an MSA Input Signal). 6. 4 Isochronous Output Terms (these are MSA Output Signals). The purpose of this FPGA is to receive 4 Input Terms (e.g. And-Or Input Terms, Front-End Busy signals, etc), optionally buffer them in a FIFO, and provide them to the Level 1 Framework in an isochronous fashion. Some state and status readout (via HSRO and Monitor Readout) and scalers (readout via Monitor Readout) are also provided. Operation--General Comments --------------------------- This FPGA is used for several functions in the Level 1 Trigger Framework: 1. receiving And-Or Input Terms 2. receiving Front-End Busy Disable signals 3. receiving Individual Specific Trigger Disable signals 4. receiving Global Specific Trigger Disable signals All of these functions have considerable similarity (as described above), but minor differences do exist. For example: 1. AOIT's arrive at different FPGA's with different latencies, and must be synchronized in FIFO's across all FPGA's. 2. The various Disables arrive "unsynchronized" and are passed through the TRM FPGA's as quickly as possible (in D-Latch mode rather than FIFO mode) 3. AOIT's arrive with (and use) Strobe and Gap signals. L1 Specific Trigger Fired Mask to L2 arrives with a Strobe (Global L1 Accept) signal, but no Gap. All other applications use neither Strobe nor Gap. A single FPGA design is able to support all of these functions, by making certain aspects of its logic programmable via TCC. The Term Receiver Module FPGA is composed of the following elements: 1. On-Card Bus Interface 2. High-Speed Readout Interface 3. 32 Stage FIFO for 4 Input Terms (plus Gap), consisting of: A. 32 x 5 FIFO B. Programmable FIFO Error Detection logic C. Automatic FIFO Re-synchronization logic 4. FIFO Bypass Data Path (D-Latch Mode) 5. Two Test Data Registers 6. Output Term Source Selection 7. Output Term Latches and Drivers 8. Output Term State and FIFO Status Recording logic 9. Output Term Scaler logic Each element is described below. 1. On-Card Bus Interface This is the standard On-Card Bus Interface from the MSU FPGA Common Block Library. Its operation is described elsewhere and will not be repeated here. 2. High-Speed Readout Interface This is the standard High-Speed Readout Interface from the MSU FPGA Common Block Library. Its operation is described elsewhere and will not be repeated here. Note that two words are provided for HSRO. The first word has information about the output terms (see Monitor Readout Copy of HSRO States for a bit description), and the second word contains status information relating to the FIFO (see Monitor Readout Copy of HSRO FIFO Status). The first word is passed through the beam crossing history shift register so that the data read out is associated with the L1 Accept beam crossing. The second word is not delayed and reflects the status of the FIFO at the time the capture signal is asserted. 3. 32 Stage FIFO for 4 Input Terms (plus Gap) The heart of this FPGA is a 32 stage FIFO, consisting of: A. 32 x 5 FIFO B. Programmable FIFO Error Detection logic C. Automatic FIFO Re-synchronization logic 3.A 32 x 5 FIFO The incoming Input Terms, plus the Gap signal (as appropriate), are stored in a 32 stage by 5 bit wide FIFO. The depth of this FIFO is set by the maximum L1 Framework AOIT latency of 25 ticks. This FIFO is built using 5 32x1 dual-port RAM's (from the Xilinx component library), with additional control logic (write address counter, read address counter, empty/full condition detection, etc.) as needed. Data is written into the FIFO on the rising edge of the Input Strobe (which accompanies the incoming Input Terms on the P2/P3 backplane connectors). Writing data into the FIFO increments the Write Address by 1, in preparation for the next write (i.e. this new incremented address indicates which RAM location will be written to on the NEXT Input Strobe rising edge). Data is read from the FIFO and latched (in the Output Term Latch, described below) on the rising edge of the TRM Clock. The Read Clock is a HQ Timing Signal. Reading data from the FIFO increments the Read Address by 1, in preparation for the next read (i.e. this new incremented address indicates which RAM location's data will be latched on the NEXT TRM Clock rising edge), providing for the most rapid clock-to-output data path, since it is not necessary to wait for the counter to increment and the RAM to be addressed, but only for the D-latch to update. No phase relationship is assumed between the Input Strobe and the TRM Clock, beyond the system-level requirement (in the case of And-Or Input Terms) that the rising edge of the Input Strobe for the data from tick "n" (in the Front-End Timezone) occur before the beginning of tick "n" (in the Framework Timezone). 3.B Programmable FIFO Error Detection logic The FIFO must be capable of detecting two different error conditions in all applications: 1. FIFO Full: if, following a Write, the Write Address is equal to the Read Address, the FIFO is Full and cannot accept another Input. A Write request under these conditions is a "FIFO Full" error. 2. FIFO Empty: if, following a Read, the Read Address is equal to the Write Address, the FIFO is Empty and cannot provide another Output. A Read request under these conditions is a "FIFO Empty" error. Note that correctly processing these errors requires "knowing" whether the last action was a Write or a Read. This is done by watching the Write Address and Read Address directions, see Xilinx App. Note XAPP 051. Additionally, for the AOIT receiving application, two more checks are performed on the FIFO. Recall that each L1 Trigger Subsystem has a different Beam Crossing to L1 Framework AOIT latency. The TRM's are responsible for providing isochronous (i.e. all from the same Beam Crossing) AOIT's to the AONM's. Since the L1 Trigger Subsystems do not "tag" their data with a Beam Crossing Number, some other technique is required to verify this synchronization. The chosen technique is to label certain ticks as "Gap Beam Crossings." Each L1 Trigger Subsystem sets its Subsystem Gap Marker along with its AOIT's for these ticks. The AOIT TRM's are also told, via a P1 Timing called the Framework Gap Marker, which ticks correspond to Gaps, and verifies that all the Subsystem Gap Markers are set for these ticks, and conversely that no Subsystem Gap Markers are set for ticks not marked as Framework Gaps. The checks are therefore: 1. Missing Subsystem Gap Marker: this tick is marked as a Gap tick (via the HQ Timing Signal Framework Gap Marker), but the data read from the FIFO does not have the Subsystem Gap Marker set. 2. Unexpected Subsystem Gap Marker: this tick is NOT marked as a Gap tick (via the Framework Gap Marker), but the data read from the FIFO has the Subsystem Gap Marker set. All of these checks can be ignored, via writes to a control register. The FIFO Empty/Full checks must be performed in all applications, and should not be turned off. The Gap Marker checks are only required for the AOIT application, and should be turned off for all other applications. Any error that occurs is latched into a status register. This register can either be cleared via a TCC write, or automatically clear itself when the FIFO is resynched (depending on the mode of operation selected). If any error occurs, this FPGA pulls the Chip Status signal to the VME Interface FPGA, which will result in the VME Interface FPGA requesting an interrupt via the VME bus (if interrupts are enabled). This is how TCC is informed of a FIFO error. Several states and scalers are recorded for monitoring and high speed readout to help characterize the system operation and diagnose errors. At the system level, once an error is detected (here considering only the AOIT application), the flow of events must be stopped. TCC probably cannot respond to the VME Interrupt quickly enough, so a purely "hardware" path will likely be used. The current scheme has the VME Interface FPGA "copying" the VME Interrupt Request to the BSF FPGA, which propagates it off-card via the P5 Global I/O. The 4 AOIT TRM's each make a single output, which must be ORed together somewhere (possibly in the BSF of one of these cards, or in an FM) to produce a single overall "FIFO Error" type signal. This signal is called the "Maginot Line," because it likely does not become active until several bad events have been passed through the TRM's (because the detection logic can only sense Gap-related errors on certain ticks). The "Maginot Line" is fed back to the TRM's (as a P1 Timing Signal) which forces the outputs to a specified state (see below), and may also be used as a Global Disable. This "Maginot Line" loop is not part of the TRM FPGA functionality, but rather part of the system-level services provided to the FPGA. 3.C Automatic FIFO Re-synchronization logic The error detection logic is also used to perform a "self-synching" startup (or re-startup) of the FIFO upon detection of an error, or when requested by TCC via a VME write. The re-synchronization occurs as follows: 0. Detect a synchronization error (or be requested by TCC). Latch the source of error in a control status type register and request a VME Interrupt as described above. 1. Force both the Write Address Counter (WAC) and Read Address Counter (RAC) to zero (on the next Input Strobe and TRM Clock rising edge, respectively), and continue holding them at zero. This causes the Input Term information to be repetitively written to (and read from) DPRAM address zero. 2. When the Term Input Group contains an asserted Subsystem Gap signal (at the rising edge of Input Strobe), the WAC is taken out of reset. The data for this tick is written at DPRAM address zero. At the next rising edge of Input Strobe, the next Terms OVERWRITE the Terms with the asserted Gap, and the WAC increments to 1. Each subsequent Input Strobe now writes to address "n" and increments the WAC to address "n+1." Note that there is no guarantee that the Subsystem Gap signal will not glitch (except, of course, for the region near the Input Strobe rising edge). A "high" glitch in Subsystem Gap must NOT stimulate the counter to begin counting. 3. After the WAC has been enabled to increment, wait for the Framework Gap P1 Timing Signal to be asserted (at the rising edge of TRM Clock). At this time, allow the RAC to begin incrementing. In the worst case, the RAC must begin incrementing within 40 ns after the WAC has begun incrementing. Again, a glitch in the Framework Gap P1 Timing Signal, although unlikely, must not stimulate the counter to begin counting. 4. Wait for TCC to service the VME Interrupt and clear the above-mentioned control status register. For this auto-synching to work, the maximum L1 Trigger Subsystem latency must be less than the time between Gaps. The expected case of 25 ticks of L1 latency vs. Gaps every (approximately) 48 ticks meets this constraint. Note that the TRM FPGA has a built-in shift register delay of 26 ticks on the Framework Gap P1 Timing Signal. This is because th TRM FPGA is not given a Framework Gap P1 Timing Signal, but instead a Front-End Time Zone Gap P1 Timing Signal. It compensates for this discrepancy by making an internally delayed copy. 4. FIFO Bypass Data Path (D-Latch Mode) Many TRM applications (Individual/Global/Front-End Busy Disables) do not require the above-described FIFO. For these applications, a FIFO Bypass mode, in which the Input Terms directly become the Output Terms (which are latched by the TRM Clock P1 Timing Signal as described below). This latching is required because the downstream Framework logic expects its inputs to change only at discrete, specified "phases" in the tick. 5. Two Test Data Registers The TRM FPGA has two separate Test Data Registers, programmable via TCC. Each of these registers contains a 4-bit pattern to which the 4 Output Terms can be driven, again under TCC control. These data registers are called the A and B Test Data Registers, and are used both for system testing and also for forcing the output to a known state during (for example) system startup or a FIFO synch error. The details of Output Term source selection are provided in the following section. 6. Output Term Source Selection The TRM Output Term source selection logic is made up of a pair of multiplexers. The first mux is under TCC control via VME register access, and the second is controlled by the Maginot Line P1 Timing Signal. They are arranged as shown below: Maginot Line P1 TS -----------. | Output Mux Control Reg | | | .-------. | FIFO Bypass -/--| | | 4 | 4-bit | | | | .-------. FIFO --------/--| 3:1 |-/---| | 4 | | 4 | 4-bit | | mux | | | TDR A -------/--| | | 2:1 |-/-- Output Terms 4 `-------' | | 4 (to Output Term | mux | Latches and TDR B -------/----------------| | Drivers) `-------' If the Maginot Line P1 Timing Signal (see above sections for details) is LOW, then TCC can select (at VME register access speed) either the FIFO, FIFO Bypass, or Test Data Register A Output Terms. If the Maginot Line is HIGH, then the Output Terms come from Test Data Register B, regardless of the "upstream" mux programming. During normal physics running, TCC would select either the FIFO or FIFO Bypass Output Terms (depending on the particular TRM application), and program Test Data Register B with all zeros. The Maginot Line would typically be LOW (allowing the selected Output Terms to be driven off-chip), but would go HIGH in the event of a FIFO synch error, causing the all-zero Output Terms from TDR B to be driven off-chip. During system testing, TCC would select Test Data Register A, and control the Maginot Line (via a helper channel) to alternate between driving TDR A and TDR B off-chip. This would allow "single-chance" system testing, by sending a long string of, e.g. TDR A, with a single tick of TDR B interposed. By asserting the Capture Monitor Data P1 Timing Signal at a controlled time following the "TDR B" tick, the results of the TDR B Output Terms can be captured and analyzed. During testing, the Output Terms must change at the same "phase" of the tick as they would during normal running. Rather than trying to precisely control the timing of the Maginot Line, the Output Terms (regardless of source) are all latched as described in the following section. 7. Output Term Latches and Drivers Regardless of the source of the Output Terms, they are all latched (on the rising edge of the TRM Clock P1 Timing Signal) before being driven off-chip. The reasons for latching the FIFO and FIFO Bypass mode Output Terms are described above. The reason for latching the Output Terms when they come from Test Data Registers is more subtle. During system testing, it is desirable for the Output Terms to change at the same "phase" of the tick as they do during normal running. If the Output Terms coming from Test Data Registers were not latched, then the Maginot Line P1 Timing Signal would need to switch at a very precise time to emulate the real system timing. Latching the Output Terms in all cases eliminates this system-level concern. 8. Output Term State and FIFO Status Recording logic The 4 Output Terms (regardless of source) and some FIFO status information are available for readout via both the HSRO readout mechanism and the Monitor Readout mechanism. The data capture and readout are performed in the standard fashion, described elsewhere. 9. Output Term Scaler logic Additionally, each Output Term (again, regardless of source) is fed to its own 32-bit scaler, which is incremented on every tick during which the Output Term is HIGH. Again, if Test Data Mode is selected, the Test Data, and not the FIFO output, act as the scaler gates. These scalers can be reset via a HQ Timing Signal. The 32-bit values from these scalers are available via Monitor Readout, again the capture and readout are performed in the standard fashion. Programming Interface --------------------- The Per-Bunch Scaler FPGA has the following VME-visible registers: Reg Register Addr Access Contents ---- ------ -------- 0 R/W Chip Control Status Register (LSW) 1 R/W Chip Control Status Register (MSW) 2 R/W Scaler Timing Signal Reset Enable Register 3 R/W Scaler Force Reset Register 8 R/W FIFO Control Status Register 9 R FIFO Error Reporting Register 10 R FIFO Counter Status Register 12 R/W Test Data Register A 13 R/W Test Data Register B 16 R/W Output Term Source Selection Register 24 R HSRO State 25 R/W HSRO Terminal Count 26 R HSRO Current Count 32 R/W Tick History Shift Register Control Reg 36 R Monitor Readout copy of HSRO States 40 R Output Term 0 Scaler Monitor Register (LSW) 41 R Output Term 0 Scaler Monitor Register (MSW) 42 R Output Term 1 Scaler Monitor Register (LSW) 43 R Output Term 1 Scaler Monitor Register (MSW) 44 R Output Term 2 Scaler Monitor Register (LSW) 45 R Output Term 2 Scaler Monitor Register (MSW) 46 R Output Term 3 Scaler Monitor Register (LSW) 47 R Output Term 3 Scaler Monitor Register (MSW) 48 R Monitor Readout copy of HSRO FIFO Status The bit allocation in each of these registers is: Chip Control Status Register LSW (Register Address 0) Bit Access Contents --- ------ -------- 0 R/W Chip Interrupt Enable ('1': interrupts enabled) 1 R/W Internal Interrupt Request ('1': on-chip logic is requesting an interrupt, regardless of the Chip Interrupt Enable, this is the logical OR of all enabled sources of Internal Interrupt Request) 2 R Chip Status Signal (Interrupt Request Status) (logical AND of Chip Interrupt Enable and Chip Interrupt Request--this is the logical INVERSE of the Chip_Status*(x) signal from this chip to the VME Interface FPGA) 3 R/W Enable Latched_FIFO_Error to generate Internal Interrupt Request 4 R Latched_FIFO_Error generating Internal Interrupt Request (AND of Latched_FIFO_Error and the above control bit) 5 R/W Enable FIFO_Not_Empty to generate Internal Interrupt Request (NOTE: FIFO_Not_Empty should *not* be used to generate VME Interrupts because it is not latched. This is used only in L2 applications, where the "Interrupt Request" goes out via P5 not via VME. To accomplish this, disable VME Interrupt Generation from this card in the VME FPGA Board CSR) 6 R FIFO_Not_Empty generating Internal Interrupt Request (AND of FIFO_Not_Empty and the above control bit) 7:15 --- not allocated The Chip Status Register MSW is currently unused. Scaler Timing Signal Reset Enable Register Bit Access Contents --- ------ -------- 0 R/W Enable Timing Signal Reset for Output Term 0 Scaler 1 R/W Enable Timing Signal Reset for Output Term 1 Scaler 2 R/W Enable Timing Signal Reset for Output Term 2 Scaler 3 R/W Enable Timing Signal Reset for Output Term 3 Scaler 15:4 R/W Unallocated Scaler Force Reset Register Bit Access Contents --- ------ -------- 0 R/W Force Reset for Output Term 0 Scaler 1 R/W Force Reset for Output Term 1 Scaler 2 R/W Force Reset for Output Term 2 Scaler 3 R/W Force Reset for Output Term 3 Scaler 15:4 R/W Unallocated FIFO Control Status Register Bit Access Contents --- ------ -------- 0 R/W Enable "FIFO Full" Error Checking 1 R/W Enable "FIFO Empty" Error Checking 2 R/W Enable "Missing Subsys Gap" Error Checking 3 R/W Enable "Unexpected Subsys Gap" Error Checking 4 R/W TCC Force FIFO Error (Sets FIFO_Error flag. TCC must pulse this bit high and then back low again) 7:5 R/W Unallocated 8 R/W Enable Automatic Error Clearing 9 R/W Manually Clear Errors (Only meaningful when Automatic Error Clearing is disabled. TCC must pulse this bit high and then back low again) 15:10 R/W Unallocated FIFO Error Reporting Register Bit Access Contents --- ------ -------- 0 R FIFO Full Error (Latched) 1 R FIFO Empty Error (Latched) 2 R Missing Subsystem Gap Error (Latched) 3 R Unexpected Subsystem Gap Error (Latched) 4 R TCC Forced FIFO Error (Latched) 7:5 R Unallocated 8 R FIFO Error Flag (logical OR of bits 4:0) 15:9 R Unallocated FIFO Counter Status Register Bit Access Contents --- ------ -------- 4:0 R FIFO DPRAM Write Address (see note below) 6:5 R Unallocated 7 R FIFO DPRAM Write Counter Reset 12:8 R FIFO DPRAM Read Address (see note below) 14:13 R Unallocated 15 R FIFO DPRAM Read Counter Reset FIFO DPRAM Write/Read Addresses do NOT progress in standard binary sequence. They progress in a modified Grey code as follows: step address in seq dec hex bin ------ --- --- --- 1 0 0x00 00000 (reset state) 2 1 0x01 00001 3 3 0x03 00011 4 7 0x07 00111 5 6 0x06 00110 6 5 0x05 00101 7 2 0x02 00010 8 4 0x04 00100 9 8 0x08 01000 10 9 0x09 01001 11 11 0x0b 01011 12 15 0x0f 01111 13 14 0x0e 01110 14 13 0x0d 01101 15 10 0x0a 01010 16 12 0x0c 01100 17 24 0x18 11000 18 25 0x19 11001 19 27 0x1b 11011 20 31 0x1f 11111 21 30 0x1e 11110 22 29 0x1d 11101 23 26 0x1a 11010 24 28 0x1c 11100 25 16 0x10 10000 26 17 0x11 10001 27 19 0x13 10011 28 23 0x17 10111 29 22 0x16 10110 30 21 0x15 10101 31 18 0x12 10010 32 20 0x14 10100 1 0 0x00 00000 (sequence begins again) step address in seq dec hex bin ------ --- --- --- 1 0 0x00 00000 (reset state) 2 1 0x01 00001 7 2 0x02 00010 3 3 0x03 00011 8 4 0x04 00100 6 5 0x05 00101 5 6 0x06 00110 4 7 0x07 00111 9 8 0x08 01000 10 9 0x09 01001 15 10 0x0a 01010 11 11 0x0b 01011 16 12 0x0c 01100 14 13 0x0d 01101 13 14 0x0e 01110 12 15 0x0f 01111 25 16 0x10 10000 26 17 0x11 10001 31 18 0x12 10010 27 19 0x13 10011 32 20 0x14 10100 30 21 0x15 10101 29 22 0x16 10110 28 23 0x17 10111 17 24 0x18 11000 18 25 0x19 11001 23 26 0x1a 11010 19 27 0x1b 11011 24 28 0x1c 11100 22 29 0x1d 11101 21 30 0x1e 11110 20 31 0x1f 11111 1 0 0x00 00000 (sequence begins again) Test Data Register A/B Bit Access Contents --- ------ -------- 3:0 R/W Output Term 3:0 15:4 R/W Unallocated Output Source Selection Register Bit Access Contents --- ------ -------- 1:0 R/W Output Source Select ('00': FIFO Bypass '01': FIFO '10': Test Data Register A '11': Undefined) 15:2 R/W Unallocated HSRO State Bit Access Contents --- ------ -------- 0 R HSRO_DCE_IN* 1 R HSRO_DCE_OUT* 2 R Enable_HSRO_Data 15:3 R not allocated HSRO Terminal Count Bit Access Contents --- ------ -------- 3:0 R/W Number of Words for High-Speed Readout (MUST be greater than 0 if chip HSRO is enabled) 14:4 R/W not allocated 15 R/W Enable HSRO from this Chip (0: DCE_In* passes directly through to DCE_Out* 1: DCE_Out* is generated by the terminal count comparator) Tick History Shift Register Control Reg Bit Access Contents --- ------ -------- 2:0 R/W Depth in stage 1 of BXHSR 15:3 R/W unallocated Output Term Scaler Monitor Registers Bit Access Contents --- ------ -------- 15:0 R Scaler MS Word / LS Word as appropriate Output Term State Monitor Register Bit Access Contents --- ------ -------- 0 R Output Term 0 State: Triggered Tick - 1 1 R Output Term 1 State: Triggered Tick - 1 2 R Output Term 2 State: Triggered Tick - 1 3 R Output Term 3 State: Triggered Tick - 1 4 R Output Term 0 State: Triggered Tick 5 R Output Term 1 State: Triggered Tick 6 R Output Term 2 State: Triggered Tick 7 R Output Term 3 State: Triggered Tick 8 R Output Term 0 State: Triggered Tick + 1 9 R Output Term 1 State: Triggered Tick + 1 10 R Output Term 2 State: Triggered Tick + 1 11 R Output Term 3 State: Triggered Tick + 1 12 R Output Term 0 State: Triggered Tick + 2 13 R Output Term 1 State: Triggered Tick + 2 14 R Output Term 2 State: Triggered Tick + 2 15 R Output Term 3 State: Triggered Tick + 2 Monitor Readout copy of HSRO FIFO Status Bit Access Contents --- ------ -------- 0 R FIFO Full Error (Latched) 1 R FIFO Empty Error (Latched) 2 R Missing Subsystem Gap Error (Latched) 3 R Unexpected Subsystem Gap Error (Latched) 8:4 R Write Counter (Current) 9 R Write Counter Reset (Current) 14:10 R Read Counter (Current) 15 R Read Counter Reset (Current)