📄 aal2txtxbyte.c
字号:
/* Transmit CPS-Payload */ Branch(ALWAYS, Label(TX_CPS_PAYLOAD));/*---------------------------------------------------------------------------*/LabelDef(INSERT_STF_IN_CPS_PAYLOAD); DCPSIM_MESSAGE(INSERT_STF_IN_CPS_PAYLOAD); /* Save the microaddress for return */ CopyIreg(IREG_RETURN_ADDRESS,PCreg); /* Branch for transmitting CPS-PH */ Branch(ALWAYS, Label(TX_CPS_HEADER)); /* Get the address of li field of CPS-PH, save it in Ireg IREG_TEMP_STORAGE_1 */ CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->li); Branch(ALWAYS, Upc+1); Branch(ALWAYS, Upc+1); CregToIreg (IREG_TEMP_STORAGE_1); Branch(ALWAYS, Upc+1); /* Initialize IREG_CPS_PAYLOAD_COUNT with a 0 */ IregInit(IREG_CPS_PAYLOAD_COUNT, 0, UseBbus); Branch(ALWAYS, Upc+1); /* Make IREG_CPS_PAYLOAD_COUNT negative */ IregSUB(IREG_CPS_PAYLOAD_COUNT, IREG_TEMP_STORAGE_1); Branch(ALWAYS, Upc+1); /* Initialize IREG_TEMP_STORAGE_1 with a (CPS_PH_SIZE + 1), three bytes * of CPS-PH already sent. */ IregInit(IREG_TEMP_STORAGE_1, (CPS_PH_SIZE + 1), UseBbus); Branch(ALWAYS, Upc+1); /* Subtract IREG_STF_1_POSITION from IREG_TEMP_STORAGE_1 * Here, STF-1 position will be > 3, because it has to be inserted * in CPS payload after CPS-PH. */ IregSUB(IREG_TEMP_STORAGE_1, IREG_STF_1_POSITION); Branch(ALWAYS, Upc+1); /* If subtraction result is zero, then tx one payload byte and * mark it with EOF. */ Abus(IregsA(IREG_TEMP_STORAGE_1)); ALU(PassA); Branch(ALWAYS, Upc+1); Branch(ALUzero, Label(STF_AFTER_ONE_PAYLOAD_BYTE)); /* Transmit payload */ Pbus(Payload); Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_TEMP_STORAGE_1) + IregIncr(IREG_CPS_PAYLOAD_COUNT) + RepeatUntil); Branch(AllOnes(IREG_TEMP_STORAGE_1), Upc+1);/*---------------------------------------------------------------------------*/LabelDef(STF_AFTER_ONE_PAYLOAD_BYTE); DCPSIM_MESSAGE(STF_AFTER_ONE_PAYLOAD_BYTE); /* Indicate end of CPS payload */ Pbus(Payload); Actions(DataOutValid + UnloadFIFO + Merge9 + IregIncr(IREG_CPS_PAYLOAD_COUNT)); Branch(ALWAYS, Upc+1); /* Transmit STF Byte */ IregXmit(IREG_STF_1); Branch(ALWAYS, Upc+1); /* Check the content of IREG_CPS_PAYLOAD_COUNT */ IregTest(IREG_CPS_PAYLOAD_COUNT, UseAbus); Branch(ALWAYS, Upc+1); /* Has become 0, tx last byte */ Branch(ALUzero, Label(TX_LAST_CPS_PL_BYTE)); /* More bytes are there, tx those first */ /* Transmit rest of the bytes of the CPS Payload */ Pbus(Payload); Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_CPS_PAYLOAD_COUNT) + RepeatUntil); Branch(AllOnes(IREG_CPS_PAYLOAD_COUNT), Upc+1); /* Indicate end of the CPS payload */ Branch(ALWAYS, Label(TX_LAST_CPS_PL_BYTE));/*---------------------------------------------------------------------------*//* Prcocess, when CPS packet is going to create a new ATM SDU, STF position is 0 */LabelDef(NEW_ATM_SDU); DCPSIM_MESSAGE(NEW_ATM_SDU); /* Transmit STF */ IregXmit(IREG_STF_1); Branch(ALWAYS, Upc+1); /* Transmit CPS-PH */ /* Save the microaddress for return */ CopyIreg(IREG_RETURN_ADDRESS,PCreg); Branch(ALWAYS, Label(TX_CPS_HEADER)); Branch(ALWAYS, Label(TX_CPS_PAYLOAD));/*---------------------------------------------------------------------------*/LabelDef(TX_PREV_ATM_SDU); DCPSIM_MESSAGE(TX_PREV_ATM_SDU); /* Load the Creg with address */ CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->PrevAtmSduRecirBytes); Branch(ALWAYS, Upc+1); Branch(ALWAYS, Upc+1);/*---------------------------------------------------------------------------*/LabelDef(TX_RECIRC_PAYLOAD); DCPSIM_MESSAGE(TX_RECIRC_PAYLOAD); Abus(Creg); ALU(PassA); PayloadOut(ALUout); Actions(CregAddrIncr); Branch(ALWAYS,Upc+1); IregSUBlit(IREG_PREV_SDU_RECIRC_BYTES_COUNT, 1); Branch(ALWAYS,Upc+1); BranchNot(ALUzero,Label(TX_RECIRC_PAYLOAD)); /* Increment the return address */ Actions(IregIncr(IREG_RETURN_ADDRESS)); Branch(ALWAYS,Upc+1); /* Update PCreg with return address */ CopyIreg(PCreg, IREG_RETURN_ADDRESS); Branch(ALWAYS,Upc+1); /* Return to the calling function: shadow instruction */ Actions(RepeatUntil); Branch(NEVER,Upc);/*---------------------------------------------------------------------------*/LabelDef(TX_CPS_HEADER); DCPSIM_MESSAGE(TX_CPS_HEADER); /* Transmit IREG_CID: CPS-PH 1st Byte */ TxCidAccumCrc5 (FALSE); Branch(ALWAYS, Upc+1); /* Transmit CPS-PH 2nd Byte */ TxCpsPh2ndByteAccumCrc5 (FALSE); Branch(ALWAYS, Upc+1); /* Prepare and transmit CPS-PH 3rd Byte */ PrepareTxCpsPh3rdByte (FALSE); Branch(ALWAYS,Upc+1); /* Incremnet the return address */ Actions(IregIncr(IREG_RETURN_ADDRESS)); Branch(ALWAYS,Upc+1); /* Update PCreg with return address */ CopyIreg(PCreg, IREG_RETURN_ADDRESS); Branch(ALWAYS,Upc+1); /* Return to the calling function: shadow instruction */ Actions(RepeatUntil); Branch(NEVER,Upc);/*---------------------------------------------------------------------------*/LabelDef(FORM_CPS_PH_1ST_2ND_AND_PARTIAL_3RD_BYTES); DCPSIM_MESSAGE(FORM_CPS_PH_1ST_2ND_AND_PARTIAL_3RD_BYTES); /* Get the address of cid field of CPS-PH */ CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->cid); Branch(ALWAYS, Upc+1); Branch(ALWAYS, Upc+1); /* Save IREG_CID in IREG_CID Ireg */ CregToIreg(IREG_CID); Branch(ALWAYS, Upc+1); /* Load the creg with uui address */ CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->uui); Branch(ALWAYS, Upc+1); Branch(ALWAYS, Upc+1); /* Store uui in IREG_TEMP_STORAGE_1 */ CregToIreg(IREG_TEMP_STORAGE_1); Branch(ALWAYS, Upc+1); /* Rotate Byte by 3 bits to right */ Bbus(IregsB(IREG_TEMP_STORAGE_1)); ALU(RotateB(3)); /* Save the result in IREG_TEMP_STORAGE_1 */ IregsA(IREG_TEMP_STORAGE_1); Actions(IregsAwrite); Branch(ALWAYS, Upc+1); /* Keep a copy of rotated uui in IREG_CPS_PH_3RD_BYTE */ CopyIreg(IREG_CPS_PH_3RD_BYTE, IREG_TEMP_STORAGE_1); Branch(ALWAYS, Upc+1); /* AND the result by 0x03 to retain the 2 LSBs only */ IregANDlit(IREG_TEMP_STORAGE_1, 0x03); Branch(ALWAYS, Upc+1); /* Load the creg with li address */ CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->li); Branch(ALWAYS, Upc+1); Branch(ALWAYS, Upc+1); /* Store li in IREG_TEMP_STORAGE_2 */ CregToIreg(IREG_TEMP_STORAGE_2); Branch(ALWAYS, Upc+1); /* Rotate Byte by 6 bits to right */ Bbus(IregsB(IREG_TEMP_STORAGE_2)); ALU(RotateB(6)); /* Save the result in IREG_TEMP_STORAGE_2 */ IregsA(IREG_TEMP_STORAGE_2); Actions(IregsAwrite); Branch(ALWAYS, Upc+1); /* Do a OR, to form a byte with 6 bits of li and 2 MSBits of uui */ IregOR(IREG_TEMP_STORAGE_2, IREG_TEMP_STORAGE_1); Branch(ALWAYS, Upc+1); /* Store the result in IREG_CPS_PH_2ND_BYTE */ CopyIreg(IREG_CPS_PH_2ND_BYTE, IREG_TEMP_STORAGE_2); Branch(ALWAYS, Upc+1); /* AND IREG_CPS_PH_3RD_BYTE content by 0xE0 to retain the 3 MSBs only, * now this contains remaining 3 bits of uui at 3 MS position. */ IregANDlit(IREG_CPS_PH_3RD_BYTE, 0xE0); Branch(ALWAYS, Upc+1); /* Incremnet the return address */ Actions(IregIncr(IREG_RETURN_ADDRESS)); Branch(ALWAYS,Upc+1); /* Update PCreg with return address */ CopyIreg(PCreg, IREG_RETURN_ADDRESS); Branch(ALWAYS,Upc+1); /* Return to the calling function: shadow instruction */ Actions(RepeatUntil); Branch(NEVER,Upc);LabelDef(TRANSMIT_FIRST_PAYLOAD_BYTE); /* Transmit one Payload byte and Indicate EOF */ Pbus(Payload); Actions(DataOutValid + UnloadFIFO + Merge9); Branch(ALWAYS, Upc+1); /* Initialize IREG_TEMP_STORAGE_1 with a 1. It will count number * of payload bytes transmitted. */ IregInit(IREG_TEMP_STORAGE_1, 1, UseBbus); Branch(ALWAYS, Upc+1); /* Jump to transmit STF */ Branch(ALWAYS,Label(TRANSMIT_FIRST_STF));}/*---------------------------------------------------------------------------*/void TxCidAccumCrc5 (int EofFlag){ /* Transmit IREG_CID: CPS-PH 1st Byte */ Abus(IregsA(IREG_CID)); ALU(PassA); Pbus(ALUout); if (EofFlag == FALSE) { Actions(CRC5accum + DataOutValid); } else { Actions(CRC5accum + DataOutValid + Merge9); } return;}/*---------------------------------------------------------------------------*/void TxCpsPh2ndByteAccumCrc5 (int EofFlag){ /* Transmit CPS-PH 2nd Byte */ Abus(IregsA(IREG_CPS_PH_2ND_BYTE)); ALU(PassA); Pbus(ALUout); if (EofFlag == FALSE) { Actions(CRC5accum + DataOutValid); } else { Actions(CRC5accum + DataOutValid + Merge9); } return;}/*---------------------------------------------------------------------------*/void PrepareTxCpsPh3rdByte (int EofFlag){ /* Prepare and transmit CPS-PH 3rd Byte */ Abus(IregsA(IREG_CPS_PH_3RD_BYTE)); ALU(PassA); Pbus(ALUout); Actions(CRC5accumPartial); Branch(ALWAYS, Upc+1); /* Mask off 5 LS bits */ Abus(IregsA(IREG_CPS_PH_3RD_BYTE)); Bbus(Literal(0xE0)); ALU(AND); Actions(IregsAwrite); Branch(ALWAYS,Upc+1); /* Place accumulated CRC-5 in last 5 bits position */ Abus(IregsA(IREG_CPS_PH_3RD_BYTE)); Actions(CRC5mode); Bbus(CRC5); ALU(OR); Pbus(ALUout); if (EofFlag == FALSE) { Actions(DataOutValid); } else { Actions(DataOutValid + Merge9); } return;}/*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -