⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aal2txtxbyte.c

📁 摩托罗拉Motolola公司网络处理器C3的示范代码.实现了ATM的AAL2层交换功能.想了解网络处理器的可以
💻 C
📖 第 1 页 / 共 3 页
字号:
        /* Initialize IREG_TEMP_STORAGE_1 with a 0. It will count number         * of payload bytes transmitted.         */        IregInit(IREG_TEMP_STORAGE_1, 0, UseBbus);        Branch(ALWAYS, Upc+1);        Pbus(Payload);    Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_CPS_PAYLOAD_COUNT) + IregIncr(IREG_TEMP_STORAGE_1) + RepeatUntil);    Branch(AllOnes(IREG_CPS_PAYLOAD_COUNT), Upc+1);        /* Indicate  EOF */    Pbus(Payload);    Actions(DataOutValid + UnloadFIFO + IregIncr(IREG_TEMP_STORAGE_1)+ Merge9);        Branch(ALWAYS, Upc+1);LabelDef(TRANSMIT_FIRST_STF);        /* Transmit STF 1 */        IregXmit(IREG_STF_1);        Branch(ALWAYS, Upc+1);        /* This SDU will be filled by 47 CPS payload bytes, rest of the CPS payload bytes         * will be packed in the next new SDU.         */        IregInit(IREG_CPS_PAYLOAD_COUNT, -(47-1), UseBbus);        Branch(ALWAYS, Upc+1);        Branch(ALWAYS, Label(TX_CPS_PAYLOAD_ACROSS_TWO_SDU));/*---------------------------------------------------------------------------*//* Process, when two STF are present and position of the first STF is 0, it means * two new SDU are going to be prepared with this CPS packet. */LabelDef(TWO_NEW_ATM_SDU);    DCPSIM_MESSAGE(TWO_NEW_ATM_SDU);        /* Transmit STF-1 */        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));        /* First SDU will be filled by 44 CPS payload bytes */        IregInit(IREG_CPS_PAYLOAD_COUNT, -(44-1), UseBbus);        Branch(ALWAYS, Upc+1);        /* Initialize IREG_TEMP_STORAGE_1 with a 0. It will count number         * of payload bytes transmitted.         */        IregInit(IREG_TEMP_STORAGE_1, 0, UseBbus);        Branch(ALWAYS, Upc+1);/*---------------------------------------------------------------------------*/LabelDef(TX_CPS_PAYLOAD_ACROSS_TWO_SDU);        DCPSIM_MESSAGE(TX_CPS_PAYLOAD_ACROSS_TWO_SDU);        Pbus(Payload);    Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_CPS_PAYLOAD_COUNT) + IregIncr(IREG_TEMP_STORAGE_1) + RepeatUntil);    Branch(AllOnes(IREG_CPS_PAYLOAD_COUNT), Upc+1);        /* Indicate end of CPS payload */    Pbus(Payload);    Actions(DataOutValid + UnloadFIFO + Merge9 + IregIncr(IREG_TEMP_STORAGE_1));        Branch(ALWAYS, Upc+1);        /* Transmit second STF byte */    CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->Stf2);    Branch(ALWAYS, Upc+1);    Branch(ALWAYS, Upc+1);        /* Transmit STF */    Abus(Creg);    ALU(PassA);    Pbus(ALUout);    Actions(DataOutValid);    Branch(ALWAYS, Upc+1);        /* Get the address of li field of CPS-PH, save it in Ireg IREG_TEMP_STORAGE_2 */        CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->li);    Branch(ALWAYS, Upc+1);    Branch(ALWAYS, Upc+1);        CregToIreg (IREG_TEMP_STORAGE_2);        Branch(ALWAYS, Upc+1);        /* Subtract IREG_TEMP_STORAGE_2 from IREG_TEMP_STORAGE_1 to get the remaining         * payload bytes count in negative         */        IregSUB(IREG_TEMP_STORAGE_1, IREG_TEMP_STORAGE_2);        Branch(ALWAYS, Upc+1);        /* If result is zero, it means only one payload byte is remaining to transmit */        Abus(IregsA(IREG_TEMP_STORAGE_1));        ALU(PassA);        Branch(ALWAYS, Upc+1);    Branch(ALUzero, Label(TX_LAST_CPS_PL_BYTE));        /* There are more than one payload bytes, transmit those */        Pbus(Payload);    Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_TEMP_STORAGE_1) + RepeatUntil);    Branch(AllOnes(IREG_TEMP_STORAGE_1), Upc+1);/*----------------------------------------------------------------------------*//* Transmit last CPS payload byte with EOF */LabelDef(TX_LAST_CPS_PL_BYTE);    DCPSIM_MESSAGE(TX_LAST_CPS_PL_BYTE);        /* Indicate end of CPS payload */    Pbus(Payload);    Actions(DataOutValid + UnloadFIFO + Merge9);        Branch(ALWAYS, Label(GIVE_MERGE_TO_RC));/*----------------------------------------------------------------------------*//* Process when no STF is present in the merge space */LabelDef(NO_STF_PRESENT);    DCPSIM_MESSAGE(NO_STF_PRESENT);        /* Check if previous ATM SDU bytes are being recirculated because of         * non-alignment issue.         */        Abus(IregsA(IREG_PREV_SDU_RECIRC_BYTES_COUNT));        ALU(PassA);        Branch(ALWAYS, Upc+1);    Branch(ALUzero, Label(NO_STF_NO_PREV_ATM_SDU));        Branch(ALWAYS, Label(NO_STF_PREV_ATM_SDU_PRESENT));/*---------------------------------------------------------------------------*/LabelDef(NO_STF_NO_PREV_ATM_SDU);        DCPSIM_MESSAGE(NO_STF_NO_PREV_ATM_SDU);        /* Save the microaddress for return */        CopyIreg(IREG_RETURN_ADDRESS,PCreg);        /* Branch for Tx CPS-PH */        Branch(ALWAYS, Label(TX_CPS_HEADER));/*---------------------------------------------------------------------------*/LabelDef(TX_CPS_PAYLOAD);        DCPSIM_MESSAGE(TX_CPS_PAYLOAD);        /* Transmit the CPS payload */        /* Get the address of LI field of CPS-PH, save it in Ireg IREG_CPS_PAYLOAD_COUNT */        CregsAddrWrite(AAL2TXMERGE + (int) &((Aal2TxMergeSpace*)NULL)->li);    Branch(ALWAYS, Upc+1);    Branch(ALWAYS, Upc+1);        CregToIreg (IREG_CPS_PAYLOAD_COUNT);        Branch(ALWAYS, Upc+1);        /* Initialize IREG_TEMP_STORAGE_1 with 0 */        IregInit(IREG_TEMP_STORAGE_1, 0, UseBbus);        Branch(ALWAYS, Upc+1);        /* Make IREG_CPS_PAYLOAD_COUNT negative */        IregSUB(IREG_TEMP_STORAGE_1, IREG_CPS_PAYLOAD_COUNT);        Branch(ALWAYS, Upc+1);        /* If result is zero, it means only one payload byte is there to transmit */        Abus(IregsA(IREG_TEMP_STORAGE_1));        ALU(PassA);        Branch(ALWAYS, Upc+1);    Branch(ALUzero, Label(TX_LAST_CPS_PL_BYTE));        /* Otherwise, there are more than one bytes to transmit */        Pbus(Payload);    Actions(UnloadFIFO + DataOutValid + IregIncr(IREG_TEMP_STORAGE_1) + RepeatUntil);    Branch(AllOnes(IREG_TEMP_STORAGE_1), Upc+1);        /* Indicate end of CPS payload. LI is (length of payload) - 1, so there is one         * more byte to transmit.         */        Branch(ALWAYS, Label(TX_LAST_CPS_PL_BYTE));/*---------------------------------------------------------------------------*//* Process when no previous ATM SDU bytes are being recirculated */LabelDef(NO_STF_PREV_ATM_SDU_PRESENT);        DCPSIM_MESSAGE(NO_STF_PREV_ATM_SDU_PRESENT);        /* Save the microaddress for return */        CopyIreg(IREG_RETURN_ADDRESS,PCreg);        /* Branch for transmitting prev ATM SDU  */        Branch(ALWAYS, Label(TX_PREV_ATM_SDU));        /* Save the microaddress for return */        CopyIreg(IREG_RETURN_ADDRESS,PCreg);    Branch(ALWAYS, Label(TX_CPS_HEADER));    Branch(ALWAYS, Label(TX_CPS_PAYLOAD));/*---------------------------------------------------------------------------*//* Prcocess, when only one STF byte is present */LabelDef(NO_SECOND_STF_PRESENT);        DCPSIM_MESSAGE(NO_SECOND_STF_PRESENT);        /* Check the first STF byte position */        Abus(IregsA(IREG_STF_1_POSITION));    ALU(PassA);        Branch(ALWAYS, Upc+1);    Branch(ALUzero, Label(NEW_ATM_SDU));        /* Process when position of the first STF is non zero */        /* Check the number of bytes in the previous SDU being re-circulated */        Abus(IregsA(IREG_PREV_SDU_RECIRC_BYTES_COUNT));    ALU(PassA);        Branch(ALWAYS, Upc+1);        Branch(ALUzero, Label(INSERT_ONE_STF_AND_TX_CPS));        /* Previous ATM SDU bytes are non-zero, first transmit them */        /* Save the microaddress for return */        CopyIreg(IREG_RETURN_ADDRESS,PCreg);        /* Branch for transmitting prev ATM SDU  */        Branch(ALWAYS, Label(TX_PREV_ATM_SDU));/*---------------------------------------------------------------------------*/LabelDef(INSERT_ONE_STF_AND_TX_CPS);        DCPSIM_MESSAGE(INSERT_ONE_STF_AND_TX_CPS);        /* Save the address of TX_CPS_PAYLOAD, it is required only in the case, when         * STF has ti be inserted immediately after CPS-PH. Other cases directly call         * TX_CPS_PAYLOAD.         */        Abus(AddressOf(Label(TX_CPS_PAYLOAD)));        ALU(PassA);        IregsA(IREG_RETURN_ADDRESS);        Actions(IregsAwrite);        Branch(ALWAYS,Upc+1);        /* Subtract 1 from IREG_RETURN_ADDRESS, because it is getting         * incrmented in INSERT_STF_IMM_AFTER_CPS_PH.         */        IregSUBlit(IREG_RETURN_ADDRESS, 1);        Branch(ALWAYS, Upc+1);        /* Check if STF has to be inserted after CPS PH */        CopyIreg(IREG_TEMP_STORAGE_1, IREG_STF_1_POSITION);        Branch(ALWAYS, Upc+1);        /* Subtract CPS_PH_SIZE from STF position value, to find the location         * of STF insertion.         */        IregSUBlit(IREG_TEMP_STORAGE_1, CPS_PH_SIZE);        Branch(ALWAYS, Upc+1);        Abus(IregsA(IREG_TEMP_STORAGE_1));        ALU(PassA);        Branch(ALWAYS, Upc+1);        Branch(ALUzero, Label(INSERT_STF_IMM_AFTER_CPS_PH));        /* After INSERT_STF_IMM_AFTER_CPS_PH, execution control goes         * to TX_CPS_PAYLOAD.         */        Branch(ALUneg, Label(INSERT_STF_IN_BETW_CPS_PH));        Branch(ALWAYS, Label(INSERT_STF_IN_CPS_PAYLOAD));        /* Does not fall through *//*---------------------------------------------------------------------------*/LabelDef(INSERT_STF_IMM_AFTER_CPS_PH);        DCPSIM_MESSAGE(INSERT_STF_IMM_AFTER_CPS_PH);        /* Transmit IREG_CID: CPS-PH 1st Byte */        TxCidAccumCrc5 (FALSE);        Branch(ALWAYS, Upc+1);        /* Transmit CPS-PH second Byte */        TxCpsPh2ndByteAccumCrc5 (FALSE);        Branch(ALWAYS, Upc+1);        /* Transmit CPS-PH 3rd byte with EOF */        PrepareTxCpsPh3rdByte (TRUE);        Branch(ALWAYS, Upc+1);        /* Transmit STF Byte */        IregXmit(IREG_STF_1);        Branch(ALWAYS, Upc+1);        /* Increment the return address */        Actions(IregIncr(IREG_RETURN_ADDRESS));        Branch(ALWAYS,Upc+1);        CopyIreg(PCreg, IREG_RETURN_ADDRESS);        Branch(ALWAYS,Upc+1);        /* Return to the calling function: shadow instruction */        Actions(RepeatUntil);        Branch(NEVER,Upc);/*---------------------------------------------------------------------------*//* 1 or 2 bytes of the CPS-PH fills the previous ATM SDU, rest of the bytes come * in the next SDU. */LabelDef(INSERT_STF_IN_BETW_CPS_PH);        DCPSIM_MESSAGE(INSERT_STF_IN_BETW_CPS_PH);        /* Copy STF-1 position */        CopyIreg(IREG_TEMP_STORAGE_1, IREG_STF_1_POSITION);        Branch(ALWAYS,Upc+1);        /* Subtract CPS_PH_SIZE - 2 from position to find out the location of insertion         * within CPS-PH.         */        IregSUBlit(IREG_TEMP_STORAGE_1, CPS_PH_SIZE - 2);        Branch(ALWAYS, Upc+1);        Branch(ALUzero, Label(INSERT_STF_AFTER_CID));        /* Transmit IREG_CID: CPS-PH 1st Byte */        TxCidAccumCrc5 (FALSE);        Branch(ALWAYS, Upc+1);        /* Transmit CPS-PH 2nd byte with EOF */        TxCpsPh2ndByteAccumCrc5 (TRUE);        Branch(ALWAYS, Upc+1);        /* Transmit STF Byte */        IregXmit(IREG_STF_1);        Branch(ALWAYS, Upc+1);        Branch(ALWAYS, Label(ONE_STF_TX_UUI_AND_ONWARDS));/*---------------------------------------------------------------------------*/LabelDef(INSERT_STF_AFTER_CID);        DCPSIM_MESSAGE(INSERT_STF_AFTER_CID);        /* Transmit IREG_CID with EOF */        TxCidAccumCrc5 (TRUE);        Branch(ALWAYS, Upc+1);        /* Transmit STF Byte */        IregXmit(IREG_STF_1);        Branch(ALWAYS, Upc+1);        /* Transmit CPS-PH second Byte */        TxCpsPh2ndByteAccumCrc5 (FALSE);        Branch(ALWAYS, Upc+1);/*---------------------------------------------------------------------------*/LabelDef(ONE_STF_TX_UUI_AND_ONWARDS);        DCPSIM_MESSAGE(ONE_STF_TX_UUI_AND_ONWARDS);        /* Transmit CPS-PH 3rd Byte */        PrepareTxCpsPh3rdByte (FALSE);        Branch(ALWAYS, Upc+1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -