File: Global_DSP_Program.TXT Date: In Global DSP's (0) Wait for Beginning Status Word The Global DSP is waiting for both the Local DSP Object Lists and the Wake Up Word. The DSP polls the Dual Port Memory looking for the Wake Up Word. This polling is essentially "free" because no other CPU activity is going on or even possible during this time. Once the Wake Up Word has been received, the Global DSP reports back to the 68K that it has seen a valid Wake Up Word. The DSP will examine the Wake Up Word to see whether this is a Mark and Force Pass Event. If so, it will set up the Local-to- Global and Global-to-214 DMA Lists for Mark and Force Pass Transfers. (1) Wait for Local Count Data The Global DSP is waiting for the Local Data to come in via Comm Ports. The DSP will grab this data using DMA and Comm Port read synchronization so no CPU instructions are needed. Once the DMA is finished the DMA Controller will interrupt the DSP CPU. Once the DSP CPU sees all 11 Local lists received it will tell the 68K that all Local Data has been received. Then start the incoming Local Object (and MFP if appropriate) data. This is done via DMA, etc., but proceeds with a lower priority than the CPU, so in case of conflict the CPU wins. The Global DSP then proceeds to Execute the Global Algorithm (2) Scan the Object List Headers looking for Valid Objects The Global "Frame+Tool" scans through the 11 pairs of "Count" longwords and calculates the total number of Objects found for each Term. Once the Scan is finished, the Global Frame will compare the number of Valid Objects for each Term to the Count Threshold for each Term. It will then generate the appropriate set of Term Answers to return to the L1.5 Framework. It will then generate the Global DSP Section of the Data Block. Some headers need to be added to the Data Block, either by the Global DSP or maybe by some other box. It then proceed to wait for the Local Object Data (plus MFP Data if appropriate) to arrive via DMA. (3) Write the Global Data Block to a 214 Now the Global DSP waits for the 68K (RC) to say whether readout is required or not. If readout is required, the Global DSP places the DSP-sourced Sections of the Data Block into the selected MVME214 Load Module. It uses a DMA List to move this data. Note that the amount and content of the data varies between "normal" and Mark and Force Pass Events. (5) Wait for Initialize and Initialize Now the Global DSP waits for the 68K to tell it to initialize. Once it has received the signal for initialization, the Global DSP Initializes and returns to Step (0). PROGRAM FLOW ------------ G_Init (Global initialization, similar to L_Init) ------ (wait for "Load Parameters" interrupt, then call the following modules within an Interrupt Service Routine [all ISRs are in G_ISR]) ----- G_DSP_B2 ("Node-Specific" initialization, set up Com -------- Ports, etc) G_Params (Get Universal and Frame Parameters, as well -------- as the Global Tool Parameter Header and Tool ID) (from G_Params CALL the following module) G_Tl_Ini (Tool Initialization, including getting -------- Global Tool Parameters) (return to G_Params) (end the ISR, and force execution to resume at the beginning of the following module) G_Scan (Wait for Count data, scan the count data, ------ produce the Term Answers, wait for Object (+MFP) data, wait for Transfer word... i.e. this is the cyclic code section) That is, G_Scan is the "Glob-O-Code" which includes both Frame and Tool functions. Other modules outside the normal program flow: --------------------------------------------- G_ISR (Interrupt Service Routines) G_Data (real and "Place-holder" data) Constant.Inc (Include file for Program-specific constants, included in all source files, stored in the Common Code Subdirectory) Hydra.Inc (Include file for Hydra/C40 constants, included in G_Init and G_DSP_B2, stored in the Common Code Subdirectory) Macros.Inc (Include file for Macros, included in G_DSP_B2, stored in the Common Code Subdirectory) Detailed description of each module in the Local DSP Program ------------------------------------------------------------ 1. G_Init (Global DSP General Initialization) This is the first code to execute in the Global DSP Program. This routine is loaded at the bottom of the Local SRAM on the Hydra-II card i.e. 4000 0000h. This routine performs general purpose initialization. Note that these initialization tasks are not speed-critical. Hence the initialization code is not written "tightly" to be optimized for execution speed, but instead is written to be clearly understandable. For example, the initialization routines do not use delayed branches, and make use of the CALL construct to allow the routines to be easily modular. When the initialization is finished, this module makes a BRANCH to the "cyclic" portion of the Global DSP Program (which begins at the Scan Routine Initialization entry point). That point marks the transition from non-speed-critical to speed-critical code. This routine has the following steps: 1. Initialize the C40 Data Page Pointer Register. 2. Initialize the C40 Interrupt Vector Table Pointer 3. Initialize the C40 Trap Vector Table Pointer 4. Initialize the C40 Stack Pointer Register. 5. Initialize the C40 Status Register. 6. Initialize a pointer to the On-Chip Peripherals 7. Initialize the C40 Global Memory Interface Control Register and Local Memory Interface Control Register (note that the value for the LMICR is found in the Node-Specific Initialization Module) 8. Initialize the Error Handler (IIOF2) Interrupt Service Routine 9. Enable IIOF2 as an edge-triggered interrupt. 10. Initialize the Initialize (NMI) Interrupt Service Routine 11. Initialize a pointer to the Dual Port Memory 12. Send a "DSP Code Loaded and Started, Waiting for Parameters" status code to the TCC 13. Wait in a "dead loop" for the TCC to issue an NMI. When the TCC issues the NMI, the C40 will execute the NMI ISR, which will perform the Node-Specific Initialization, receive and check the Parameters, perform Tool Initialization, and branch to the beginning of the Scan Routine 2. G_DSP_B2 (Local DSP Node-Specific Initialization) This routine is the Global DSP Node-Specific Initialization. It is CALLed by either the Initialize_ISR routine or the Error_Handler_ISR routine. Note that there is only one Global DSP Node, but this module is used to keep the structure of the Global DSP code as similar as possible to the Local DSPs. This routine does not need to be optimized for speed, because it is not time-critical code. This module makes extensive use of macros, again in order to look like the Local DSP Node Specific Initialization module. This routine has the following steps: 1. Program the MVSB2400 chip to be a VSB Master (but not Crate Controller). 2. Define the constant part of the Global DSP Object List Header Word. 3. Define the header for the Synchronization entry of the DeBug Section of the Data Block. 4. Program the Comm Ports and DMA Channels corresponding to Local DSP Input Data. This uses the SETUP_DMA and SETUP_. This uses the SETUP_DMA and SETUP_LG_PREV_PORT macros. 5. RETURN to the calling module This module also contains a routine used to set up the Mark and Force Pass data readout. This routine is called from the L_Scan module whenever a Mark and Force Pass event flows through the L1.5 Cal Trig. This routine has the following steps: 1. Setup the Mark and Force Pass-flavor DMA from the Local DSPs. Recall that, during MFP events, each LDSP produces, in addition to its Local Object List, three entries (Trigger Tower Data, Reference Set Data, and Derived Constant data) for the DeBug Section of the Data Block. 2. Return to the calling module. This module also contains assembler .set and .word directives to define the contents of some node-specific variables. 3. G_Params (Global DSP Paramater Receiver and Checker) This is the the module which is responsible for retrieving the Parameters from Dual Port Memory and checking them for validity. It is called by the Initialize_ISR routine after the Node-Specific Initialization has completed. When called, it reads the appropriate section of Parameter space in the Dual Port Memory (recall that all Parameters for all DSP Nodes are presented in the Dual Port Memory, and this Node must select its own Parameters. First the Universal Parameters are read. This defines the Dual Port Memory Map Version and Revision, the Crate ID, and the Number of Terms defined for this code. These Parameters are checked for correctness. Next the Term Parameters are read. This is a multiple-step process. First the Frame Parameters are read. Currently no Frame Parameters are used by the Global DSP so for now we don't actually read Frame Parameters. Then Global Parameters are read. Global Parameters are stored by Term Number. For each Term, the Global Parameters are examined to determine which Tool should be used, and the appropriate Tool Initialization Routine is called to actually absorb the Tool-Specific Local Parameters. If the specified Tool does not exist, this routine is responsible for setting an error flag to the TCC. If the specified Tool does exist, the Tool is responsible for checking its Parameters and returning an success/failure exit code to this module. Note that this Parameter Checker module only checks one Term (Term #0), one Local Tool, and one Global Tool. It expects 4 Terms to be defined, all pointing to a single Tool. Once all Parameters have been received and checked, this routine sets a return status in the Dual Port Memory indicating the results of the Parameter reading and checking. It also pre-loads benign values into the Wake Up Word and Status to 68K Word in the Shared Dual Port Memory. Then contol is returned to the calling module 4. G_Tl_Ini (Global DSP Tool Initialization) This is the module that Initializes the Global Tool Code. Note that there must be one of these modules for each Global Tool. In this first version of the code there is only one Global Tool and hence only one Global Tool Initialization module. Note that this Tool is designed to evaluate 4 Terms, with 4 separate sets of Global Parameters. These must be Terms #0, #1, #2, and #3. This Tool Initialization module knows where to look in the Data Block to find the Global Parameters for each of these 4 Terms. This module is called only when new Parameters are loaded (i.e. in response to a START message from COOR). It performs the following functions: (0) Check the Tool Number found in the Parameter Block (only for Term #0) (1) Receive, check, and store the Global Tool Parameters Note that this version of the code receives, checks, and stores 4 copies of the Global Tool Parameters, one for each of the 4 Terms that this Tool evaluates. (3) Return a status code to the Parameter Checking module (4) Return to the calling module 5. G_Scan (Global DSP Scan Local Object List Headers) This is the program module for the "Scan Local Object List Headers" for the Global DSP program. This module examines the Local Object List Headers to determine the number of Objects found by the Local DSP Tool. This is the "cyclic" part of the L1.5 Cal Trig Code. It is branched to from either the Error_Handler_ISR or the Initialize_ISR, after those routines have completed all of their processing. This is now time-critical code which is written to be fast. This module performs the following functions: (1) Set/reset all pointers, etc. This either cleans up from the last time the loop was executed or initializes the loop for the first cycle (2) Set status to the 68K (EC) which indicates that the Global DSP has cleaned up and is waiting for all 12 DSPs to be synchronized (a.k.a. "GDSP at State D15"). The 68K (EC) will indicate that synchro has occured by clearing the previously valid Wake Up Word. (3) Wait for the previously valid Wake Up Word to be cleared. When the GDSP has found the previously valid Wake Up Word cleared, it will report to 68K (EC) that it is waiting for a valid Wake Up Word (a.k.a. "GDSP at State D0"). (4) Look for a valid Wake Up Word. When a valid Wake Up Word is found, set status to the 68K (EC) which indicates that the Global DSP has found a valid Wake Up Word (a.k.a. "GDSP at State D1"). (5) Build the Synchronization entry of the DeBug Section of the Data Block. (6) If the Wake Up Word indicates that this L1.5 Cal Trig Cycle is a Mark and Force Pass, then CALL the Setup Mark and Force Pass routine. This adds the Mark and Force Pass Data to the Local-to Global Transfer DMA Lists and the Data Block to 214 Transfer List. (7) Wait for all Local DSP Count Data to arrive. When all Local DSP Count data arrives, the DMA Lists will automatically halt themselves and will need to be kicked in order to receive the Object Lists (and optionally the MFP data). Although we could now start running the Tool, let's first reset the flag that says that a phase of the Local-to-Global Transfer has completed and then start the next phase of this Local-to-Global DSP (i.e. the Object Lists). The DMA for this next phase proceeds with LOWER priority than the CPU so in the event of a conflict, the Tool wins. (8) Now, while the Object Lists are rolling in, run the "Globo-Tool." Recall that the Counts are packed into 2 longwords/LDSP, with 2 Terms/longword. The Counts for Terms 0 and 1 are summed in R0 (T0 in low word, T1 in high word), while the Counts for Terms 2 and 3 are summed in R1 (T2 in low word, T3 in high word). Afterwards, the sums are unpacked and compared to the 4 individual Thresholds to generate the 4 Term Answers. (9) Return the Term Answers to the 68K, at the same time indicating to the 68K that all Terms have been evaluated (aka "GDSP at State D3"). (10) Wait for the Object Lists to finish arriving from the LDSP's. Once they have arrived, tell the 68K that all Local DSP data has arrived (aka "GDSP at State D2"). Yes, that's right return "D3" before "D2." (11) Wait for the 68K (RC) to indicate whether the Local DSP data (and the Global DSP Object List) should be transferred to the selected MVME-214 Load Buffer). (12) If this transfer is NOT required, set a status word to the 68K (EC) indicating that the transfer has NOT been performed. (13) If this transfer IS required, initiate the transfer to the 214 (via DMA). Wait for the transfer to complete, and then set a status word to the 68K (EC) indicating that the transfer has been completed. (14) Return to step (1)