예제 #1
0
void CHtvDesign::SynHtDistQueRams(CHtvIdent *pHier)
{
    string inputFileName = g_htvArgs.GetInputFileName();

    CHtvIdentTblIter identIter(pHier->GetFlatIdentTbl());
    for (identIter.Begin(); !identIter.End(); identIter++) {
        if (!identIter->IsVariable() || !identIter->IsHtDistQue())
            continue;

        CHtvIdent *pQueueRam = identIter();
        m_bIsHtQueueRamsPresent = true;

        // Block Ram
        int addrWidth = pQueueRam->GetType()->GetHtMemoryAddrWidth1();
        addrWidth += pQueueRam->GetType()->GetHtMemoryAddrWidth2();

        string cQueName = pQueueRam->GetName();
        if (cQueName.substr(0,2) == "r_" || cQueName.substr(0,2) == "m_")
            cQueName.replace(0, 2, "c_");
        else
            cQueName.insert(0, "c_");

        string rQueName = pQueueRam->GetName();
        if (rQueName.substr(0,2) == "m_")
            rQueName.replace(0, 2, "r_");

        vector<int> refList(pQueueRam->GetDimenCnt(), 0);

        char buf[128];
        do {
            string refDimStr;
            string modDimStr;

            for (size_t i = 0; i < refList.size(); i += 1) {
                sprintf(buf, "$%d", refList[i]);
                refDimStr += buf;

                sprintf(buf, "$%d", refList[i]);
                modDimStr += buf;
            }

            m_vFile.Print("\n%s_HtQueueRam #( .DATA_WIDTH(%d), .ADDR_WIDTH(%d) ) %s%s ( ",
                          inputFileName.c_str(), pQueueRam->GetWidth(), addrWidth, pQueueRam->GetName().c_str(), modDimStr.c_str());

            bool bMultiple;
            CHtvIdent * pMethod = FindUniqueAccessMethod(&pQueueRam->GetHierIdent()->GetWriterList(), bMultiple);

            if (bMultiple)
                ParseMsg(PARSE_FATAL, pQueueRam->GetLineInfo(), "ht_queue push by muliple methods");

            m_vFile.Print(".clk( %s ), ", pMethod->GetClockIdent()->GetName().c_str());
            m_vFile.Print(".we( %s_WrEn%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".wa( %s_WrAddr%s[%d:0] ), ", rQueName.c_str(), refDimStr.c_str(), addrWidth-1);
            m_vFile.Print(".din( %s_WrData%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".ra( %s_RdAddr%s[%d:0] ), ", rQueName.c_str(), refDimStr.c_str(), addrWidth-1);
            m_vFile.Print(".dout( %s_RdData%s ) );\n", cQueName.c_str(), refDimStr.c_str());

        } while (!pQueueRam->DimenIter(refList));
    }
}
예제 #2
0
void CHtvDesign::SynHtDistRams(CHtvIdent *pHier)
{
    string inputFileName = g_htvArgs.GetInputFileName();

    CHtvIdentTblIter identIter(pHier->GetFlatIdentTbl());
    for (identIter.Begin(); !identIter.End(); identIter++) {
        if (!identIter->IsVariable() || !identIter->IsHtMemory())
            continue;

        if (identIter->IsHtBlockRam() || identIter->IsHtMrdBlockRam() || identIter->IsHtMwrBlockRam() || identIter->IsHtQueue())
            continue;

        CHtvIdent *pDistRam = identIter();
        m_bIsHtDistRamsPresent = true;

        int addrWidth = pDistRam->GetType()->GetHtMemoryAddrWidth1();
        addrWidth += pDistRam->GetType()->GetHtMemoryAddrWidth2();

        vector<CHtDistRamWeWidth> *pWeWidth = pDistRam->GetHtDistRamWeWidth();

        for (size_t j = 0; j < pWeWidth->size(); j += 1) {
            int highBit = (*pWeWidth)[j].m_highBit;
            int lowBit = (*pWeWidth)[j].m_lowBit;

            size_t i;
            for (i = 0; i < m_htDistRamTypes.size(); i += 1) {
                if (m_htDistRamTypes[i].m_addrWidth == addrWidth &&
                        m_htDistRamTypes[i].m_dataWidth == highBit-lowBit+1)
                    break;
            }

            if (i == m_htDistRamTypes.size())
                m_htDistRamTypes.push_back(CHtDistRamType(addrWidth, highBit-lowBit+1));
        }

        string cQueName = pDistRam->GetName();
        if (cQueName.substr(0,2) == "r_" || cQueName.substr(0,2) == "m_")
            cQueName.replace(0, 2, "c_");
        else
            cQueName.insert(0, "c_");

        bool bMultiple;
        CHtvIdent * pMethod = FindUniqueAccessMethod(&pDistRam->GetHierIdent()->GetWriterList(), bMultiple);

        if (bMultiple)
            ParseMsg(PARSE_FATAL, pDistRam->GetLineInfo(), "ht_queue push by muliple methods");

        CHtvIdent *pClockIdent = pMethod->GetClockIdent();

        vector<int> refList(pDistRam->GetDimenCnt(), 0);

        char buf[128];
        do {
            string refDimStr;
            string modDimStr;

            for (size_t i = 0; i < refList.size(); i += 1) {
                sprintf(buf, "$%d", refList[i]);
                refDimStr += buf;

                sprintf(buf, "$%d", refList[i]);
                modDimStr += buf;
            }

            if (pWeWidth->size() == 1) {
                m_vFile.Print("\n%s_HtDistRam #( .DATA_WIDTH(%d), .ADDR_WIDTH(%d) ) %s%s ( ",
                              inputFileName.c_str(), pDistRam->GetWidth(), addrWidth, pDistRam->GetName().c_str(), modDimStr.c_str());

                m_vFile.Print(".clk( %s ), ", pClockIdent->GetName().c_str());
                m_vFile.Print(".we( %s_WrEn%s ), ", cQueName.c_str(), refDimStr.c_str());
                m_vFile.Print(".wa( %s_WrAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
                m_vFile.Print(".din( %s_WrData%s ), ", cQueName.c_str(), refDimStr.c_str());
                m_vFile.Print(".ra( %s_RdAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
                m_vFile.Print(".dout( %s_RdData%s ) );\n", cQueName.c_str(), refDimStr.c_str());

            } else {
                for (size_t j = 0; j < pWeWidth->size(); j += 1) {
                    int highBit = (*pWeWidth)[j].m_highBit;
                    int lowBit = (*pWeWidth)[j].m_lowBit;

                    m_vFile.Print("\n%s_HtDistRam #( .DATA_WIDTH(%d), .ADDR_WIDTH(%d) ) %s%s_%d_%d ( ",
                                  inputFileName.c_str(), highBit-lowBit+1, addrWidth,
                                  pDistRam->GetName().c_str(), modDimStr.c_str(), highBit, lowBit);

                    m_vFile.Print(".clk( %s ), ", pClockIdent->GetName().c_str());
                    m_vFile.Print(".we( %s_WrEn_%d_%d%s ), ", cQueName.c_str(), highBit, lowBit, refDimStr.c_str());
                    m_vFile.Print(".wa( %s_WrAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
                    m_vFile.Print(".din( %s_WrData%s[%d:%d] ), ", cQueName.c_str(), refDimStr.c_str(), highBit, lowBit);
                    m_vFile.Print(".ra( %s_RdAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
                    m_vFile.Print(".dout( %s_RdData%s[%d:%d] ) );\n", cQueName.c_str(), refDimStr.c_str(), highBit, lowBit);
                }
            }

        } while (!pDistRam->DimenIter(refList));
    }
}