. FPGA Decoder How to decode the input SMT data stream for FPGA simulation STR, 21 April 1999 Assuming an input file has been generated, with the specifications described in the " Addendum to D0Note 3599 ", here is the description of a simple decoder. Let's say that we just want to read out the input data stream and count how many chips and how many channels have been readout. The input data stream, for now, should contain only one HDI,that belongs to a specific Sequencer. Let's remind here that the input data stream is composed of words 8 bit long. step 1 - INITIALIZE Sequencer_Number and HDI_Number and counters: Sequencer_Number = 0 HDI_number = 0 chip_count = 0 channel_count = 0 step 2 - read first two words on input file : - read first word - // this gives the sequencer number ________________________ |0 |0 |0 |0 |0 |1 |0 |1 | ------------------------ in this case the Sequencer number is 9 - save it in Sequencer_Number - read second word - // the 3 LSB ( less significant bits) of this word give the HDI number _________________________ |X |X |X |X |X |0 |1 |0 | ------------------------ n.b. - the X stands for any number, we disregard this part for now in this case the HDI number is 4 - save it in HDI_Number step 3 - start the read loop : // from this point on, the data structure contains a regular sequence of 'odd words' and 'even words'. The odd words contain control bits and addresses, and the even words contain data ( channel content ) - read in 'next word' and check on the 2 MSB(most significant bits): if the 2 MSB = "1 0" // it is a new chip ________________________ |1 |0 |0 |0 |0 |0 |1 |1 | ------------------------ then - read chip number ( in the 6 LSB) of the same word in this case chip number is 5. - save this value in local variable chip_number - increment counter chip_count - check that next word is ________________________ |0 |0 |0 |0 |0 |0 |0 |0 | ------------------------ IF it is not, send a 'fatal error' and EXIT if the 2 MSB = "0 0" // it is a channel address ________________________ |0 |0 | | | |1 |0 |0 | ------------------------ then - read the channel address . In this case it is 8. - save it in local variable channel_address - increment counter channel_count - read next word - save its content in local variable channel_content if the 2 MSB = "1 1" // this is the end of data, or HDI's end ________________________ |1 |1 | | | | | | | ------------------------ then - print " end of HDI " - print counters : Sequencer_Number = 9 HDI_Number = 4 chip_count= channel_count = Remark - Local variables channel_address and channel_content will constitute the input for the "Cluster Algorithm" processor. In this specific program they are of no use. The other local variable chip_number also is of no use at present. (We keep it and probably want to save it as information of the hardware address in case this will need to be forwarded to L3).