/*************************************************************************** * INCLUDE FILE: AMS_MS_Definitions-n.h (n is the version number) * * Defines all constants that are needed for the program that writes * the Micro Sequencer (MS) code for the Associative Memory Sequencer (AMS). * * CONVENTIONS: * 1. all signals are high active, unless they end with underscore (_) * 2. offsets represent bit number in a word and start from 0 * * Original creation: S.Belforte June 29 1998. * * Revision history: * Version-0 * ============= * 30-Jun-1998 S.Belforte: 0-th version, create from scratch. * Still a bit patchy since for compatibility with * old ucode-19.c different states had to be given * the same number. * Version-1 * ============= * 1-Jul-1998 S.Belforte: rationalise state diagram, make it a pure Moore * FSM. Simplify flow as for ucodams-4.c. * Version-2 * ============= * 6-Jul-1998 S.Belforte: Name AMchip3 opcodes as in M.Dell'Orso's * test vector code * * Version-3 * ============= * 22-Sep-1998 A.Cerri: New u-seq. states added to implement the * 5/6 output: the output loop has been duplicated * (adding an _s, for SHIFT). * What we do is a SHIFT after all the 6/6 roads * are output from the AM, and then output again. * ****************************************************************************/ /********************** GENERAL STUFF ************************************* * ************************************************************************/ #define RamSize 128 * 1024 /* the address range in the MS RAM: 128 k */ int MaxAddress = RamSize - 1 ; /* the ram adresses vary in [0-MaxAddress] */ /********************** RAM INPUTS ************************************* * this are the input bits that form the address to the MS RAM in the AMS, * i.e. they are the inputs to the Finite State machine ************************************************************************/ /* First the current state, it is in the 8 least significant address bits */ int CurrentState; #define CurrentStateOffset 0 #define CurrentStateMask 0xFF /* 8 bits */ /* The next input signals are all single bits */ int MaxRoad; /* the OUT_CTR Xilinx flags reaching the output limit */ int Hold; /* the OUT_CTR Xilinx flags Hold from the HitBuffer */ int DataValid_; /* the GLUE3 signals a new Road to be output */ int DataValid; /* the same, but high active */ int EEin; /* the INPREG Xilinx flags the EndEvent on input */ int NewHit; /* the INPREG Xilinx signals a new Hit to be sent to AM */ #define MaxRoadOffset 8 #define MaxRoadMask 0x1 #define HoldOffset 9 #define HoldMask 0x1 #define DataValid_Offset 10 #define DataValidMask 0x1 #define EEinOffset 11 #define EEinMask 0x1 #define NewHitOffset 12 #define NewHitMask 0x1 /********************** RAM OUTPUTS ************************************* * this are the bits that form the data word stored the MS RAM in the AMS, * i.e. they are the output controls from the Finite State machine ************************************************************************/ /* First the state: next state is part of the output word, it is * in the least significant 8 bits of the output */ int NextState; #define NextStateOffset 0 #define NextStateMask 0xFF /* Now the output controls */ int OpCode; /* 4-bit OpCode to the AMboard for the AMchip3 */ int Done_; /* tells to GLUE3 that current Road has been dealt with */ int Done; /* the same, but high active */ int Sel_; /* Select_ bit for GLUE3 */ int Sel; /* the same, but high active */ int Pop; /* asks INPUT Xilinx to read next event from Hit FIFO */ int Push; /* tells OUTCTR Xilinx to send out current Road */ int EEout; /* tells OUTCTR to send out the End Event word */ int EPout; /* controls EndPacket bit in OUTCTR output */ int EEreset; /* tells everybody to get ready for next event */ #define OpCodeOffset 8 #define OpCodeMask 0xF /* Opcode will be bits 8-11 of the output */ #define Done_Offset 12 #define Done_Mask 0x1 #define Sel_Offset 13 #define Sel_Mask 0x1 #define PopOffset 14 #define PopMask 0x1 #define PushOffset 15 #define PushMask 0x1 #define EEoutOffset 16 #define EEoutMask 0x1 #define EPoutOffset 17 #define EPoutMask 0x1 #define EEresetOffset 18 #define EEresetMask 0x1 /********************** AM OPCODES ************************************* * these are the opcodes for the AMchip3 associative memory chip * they are all UPPERCASE ************************************************************************/ #define NOP0 0 /* No Operation */ #define READ 1 #define OUTPUT 2 #define WRITE 3 #define INPUT 4 #define CLRHIT 5 /* Clear Hit Registers */ #define NOP6 6 /* No Operation */ #define SHIFT 7 #define COUNT 8 #define CLRCNT 9 /* Clear Counter and Load Shift Register */ #define INIT 10 #define NOP11 11 /* for AMchip2 compatibility */ #define DISBL5 11 /* Disable mandatory match on plane 5 */ #define RESET 12 /* Reset handshake */ #define NOP13 13 /* for AMchip2 compatibility */ #define ENABL5 13 /* Enable mandatory match on plane 5 */ #define NOP14 14 /* No Operation */ #define NOP15 15 /* No Operation */ /********************** MICROSEQUENCER STATES **************************** * these are the various states of the MicroSequencer FSM. * They are coded as 8-bit integers, thus are only allowed to have * values in the 0-255 decimal range. * State 0 is reserved as Reset, since the AMS INIT singals forces the * reset of the MS state register, forcing CurrentState to be stuck at 0. ************************************************************************/ #define Reset 0 /* States for the initialization sequence, to be repeated before each event */ #define Init1 1 /* send EEreset and CLRHIT */ #define Init2 2 /* send CLRHIT */ #define Init3 3 /* send DISABLE, Pop, EEreset, Done_ */ /* States for handling the input loop */ #define WaitForHit 4 /* wait for NewHit */ #define ProcessHit 5 /* process hit, send INPUT opcode */ /* States for handling the match process in the Associative Memory */ #define StartCount 64 /* send CLRCNT before counting */ #define Count0 6 /* send COUNT for layer 0 */ #define Count1 7 /* send COUNT for layer 1 */ #define Count2 8 /* send COUNT for layer 2 */ #define Count3 9 /* send COUNT for layer 3 */ #define Count4 10 /* send COUNT for layer 4 */ #define Count5 11 /* send COUNT for layer 5 */ #define SyncGlue 50 /* send one NOP0 to let OR_ reach GLUE0 from AM */ /* States for waiting for DV_ to crawl up the glue pipeline, keep Opcode=OUTPUT at all times */ #define Wait1 12 #define Wait2 13 #define Wait3 14 #define Wait4 15 #define Wait5 30 #define Wait6 31 #define Wait7 32 #define Wait8 33 #define Wait9 34 #define Wait10 35 #define Wait11 36 #define Wait12 37 #define Wait13 38 #define Wait14 39 #define Wait15 40 #define Wait16 41 #define Wait17 42 #define Wait18 43 #define EndWait 19 /* last wait, in this state will look for DV_ */ /* States specific to the 5/6 case */ #define Do_Shift 111 /* send SHIFT */ /* patch for the "glue bug"*/ #define SyncGlue_s 150 /* send one NOP0 to let OR_ reach GLUE0 from AM */ /* States for waiting for DV_ to crawl up the glue pipeline, keep Opcode=OUTPUT at all times (5/6 case) */ #define Wait1_s 112 #define Wait2_s 113 #define Wait3_s 114 #define Wait4_s 115 #define Wait5_s 130 #define Wait6_s 131 #define Wait7_s 132 #define Wait8_s 133 #define Wait9_s 134 #define Wait10_s 135 #define Wait11_s 136 #define Wait12_s 137 #define Wait13_s 138 #define Wait14_s 139 #define Wait15_s 140 #define Wait16_s 141 #define Wait17_s 142 #define Wait18_s 143 #define EndWait_s 119 /* last wait, in this state will look for DV_ */ /* States for handling output loop */ /* wait for DV_ up to 3 cycles, if no DV_ means roads are finished */ #define NoDV_1 20 /* send OUTPUT */ #define NoDV_2 21 /* send OUTPUT */ #define ProcessRoad 22 /* DV_ arrived, send PUSH, Done_ and OUTPUT */ #define EndOutput 23 /* No DV_ or road limit reached, do nothing */ /* States for handling output loop */ /* wait for DV_ up to 3 cycles, if no DV_ means roads are finished */ /* 5/6 case */ #define NoDV_1_s 120 /* send OUTPUT */ #define NoDV_2_s 121 /* send OUTPUT */ #define ProcessRoad_s 122 /* DV_ arrived, send PUSH, Done_ and OUTPUT */ #define EndOutput_s 123 /* No DV_ or road limit reached, do nothing */ /* States for handling end event */ #define WaitParity 24 /* do nothing while OUTCTR computes parity bit */ #define EndEvent 25 /* send EEout */ /* All other states are illegal */ #define IllegalState 255