示例#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 ListManager::refList(size_t i)
{
	l[i]->refcount++;
#ifdef DGDEBUG
	std::cout << "referencing list ref: " << i << ", refcount: " << l[i]->refcount << " (" << l[i]->sourcefile << ")" << std::endl;
#endif
	for (size_t j = 0; j < l[i]->morelists.size(); ++j)
		refList(l[i]->morelists[j]);
}
示例#3
0
// create a new phrase list. check dates on top-level list files to see if a reload is necessary.
// note: unlike above, doesn't automatically call readPhraseList.
// pass in exception, banned, and weighted phrase lists all at once.
int ListManager::newPhraseList(const char *exception, const char *banned, const char *weighted)
{
	time_t bannedpfiledate = getFileDate(banned);
	time_t exceptionpfiledate = getFileDate(exception);
	time_t weightedpfiledate = getFileDate(weighted);
	for (size_t i = 0; i < l.size(); i++) {
		if (l[i] == NULL) {
			continue;
		}
		if ((*l[i]).exceptionpfile == String(exception) && (*l[i]).bannedpfile == String(banned) && (*l[i]).weightedpfile == String(weighted)) {
			if (bannedpfiledate <= (*l[i]).bannedpfiledate && exceptionpfiledate <= (*l[i]).exceptionpfiledate && weightedpfiledate <= (*l[i]).weightedpfiledate) {
				// Known limitation - only weighted, exception, banned phrase
				// list checked for changes - not the included files.
				//
				//need to check all files that were included for phrase list
				//so when phrases read in in list container it needs to store
				//all the file names and if a single one has changed needs a
				//complete regenerate
#ifdef DGDEBUG
				std::cout << "Using previous phrase: " << exception << " - " << banned << " - " << weighted << std::endl;
#endif
				refList(i);
				return i;
			}
		}
	}
	int free = findNULL();
	if (free > -1) {
		l[(unsigned) free] = new ListContainer;
	} else {
		l.push_back(new ListContainer);
		free = l.size() - 1;
	}
	(*l[(unsigned) free]).parent = true;  // all phrase lists are parent as
	// there are no sub lists
	(*l[(unsigned) free]).bannedpfiledate = bannedpfiledate;
	(*l[(unsigned) free]).exceptionpfiledate = exceptionpfiledate;
	(*l[(unsigned) free]).weightedpfiledate = weightedpfiledate;
	(*l[(unsigned) free]).exceptionpfile = exception;
	(*l[(unsigned) free]).bannedpfile = banned;
	(*l[(unsigned) free]).weightedpfile = weighted;
	return (unsigned) free;
}
示例#4
0
// load the given list, or increase refcount on list if it's already been loaded.
int ListManager::newItemList(const char *filename, bool startswith, int filters, bool parent)
{
	for (size_t i = 0; i < l.size(); i++) {
		if (l[i] == NULL) {
			continue;
		}
		if ((*l[i]).previousUseItem(filename, startswith, filters)) {
			// this upToDate check also checks all .Included files
			if ((*l[i]).upToDate()) {
#ifdef DGDEBUG
				std::cout << "Using previous item: " << i << " " << filename << std::endl;
#endif
				refList(i);
				return i;
			}
		}
	}
	// find an empty list slot, create a new listcontainer, and load the list
	int free = findNULL();
	if (free > -1) {
		l[free] = new ListContainer;
	} else {
#ifdef DGDEBUG
		std::cout << "pushing back for new list" << std::endl;
#endif
		l.push_back(new ListContainer);
		free = l.size() - 1;
	}
	(*l[free]).parent = parent;
	if (!(*l[free]).readItemList(filename, startswith, filters)) {
		delete l[free];
		l[free] = NULL;
		return -1;
	}
	return free;
}
示例#5
0
void CHtvDesign::SynHtAsymBlockRams(CHtvIdent *pHier)
{
    string inputFileName = g_htvArgs.GetInputFileName();

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

        if (!identIter->IsHtMrdBlockRam() && !identIter->IsHtMwrBlockRam())
            continue;

        CHtvIdent *pBlockRam = identIter();

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

        int selWidth = pBlockRam->GetType()->GetHtMemorySelWidth();

        int dataWidth = pBlockRam->GetType()->GetType()->GetWidth();

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

        vector<int> refList(pBlockRam->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;
            }

            bool bMultiple;
            CHtvIdent * pWriteMethod = FindUniqueAccessMethod(&pBlockRam->GetHierIdent()->GetWriterList(), bMultiple);

            if (bMultiple)
                ParseMsg(PARSE_FATAL, pBlockRam->GetLineInfo(), "ht_asym_block_ram write by muliple methods");

            CHtvIdent * pReadMethod = FindUniqueAccessMethod(&pBlockRam->GetHierIdent()->GetReaderList(), bMultiple);

            if (bMultiple)
                ParseMsg(PARSE_FATAL, pBlockRam->GetLineInfo(), "ht_asym_block_ram read by muliple methods");

            if (pReadMethod->GetClockIdent()->GetName() == pWriteMethod->GetClockIdent()->GetName()) {

                if (pBlockRam->GetType()->IsHtBlockRamDoReg()) {
                    if (identIter->IsHtMrdBlockRam()) {
                        m_bIs1CkDoRegHtMrdBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtBlockMrdRam1CkDoReg #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                    if (identIter->IsHtMwrBlockRam()) {
                        m_bIs1CkDoRegHtMwrBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtBlockMwrRam1CkDoReg #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                } else {
                    if (identIter->IsHtMrdBlockRam()) {
                        m_bIs1CkHtMrdBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMrdBlockRam1Ck #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                    if (identIter->IsHtMwrBlockRam()) {
                        m_bIs1CkHtMwrBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMwrBlockRam1Ck #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                }

                m_vFile.Print(".ck( %s ), ", pWriteMethod->GetClockIdent()->GetName().c_str());
            } else {
                if (pBlockRam->GetType()->IsHtBlockRamDoReg()) {
                    if (identIter->IsHtMrdBlockRam()) {
                        m_bIs2CkDoRegHtMrdBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMrdBlockRam2CkDoReg #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                    if (identIter->IsHtMwrBlockRam()) {
                        m_bIs2CkDoRegHtMwrBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMwrBlockRam2CkDoReg #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                } else {
                    if (identIter->IsHtMrdBlockRam()) {
                        m_bIs2CkHtMrdBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMrdBlockRam2Ck #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                    if (identIter->IsHtMwrBlockRam()) {
                        m_bIs2CkHtMwrBlockRamsPresent = true;
                        m_vFile.Print("\n%s_HtMwrBlockRam2Ck #( .DATA_W(%d), .ADDR_W(%d), .SEL_W(%d) ) %s%s ( ",
                                      inputFileName.c_str(), dataWidth, addrWidth, selWidth, pBlockRam->GetName().c_str(), modDimStr.c_str());
                    }
                }
                m_vFile.Print(".rck( %s ), ", pReadMethod->GetClockIdent()->GetName().c_str());
                m_vFile.Print(".wck( %s ), ", pWriteMethod->GetClockIdent()->GetName().c_str());
            }

            m_vFile.Print(".we( %s_WrEn%s ), ", cQueName.c_str(), refDimStr.c_str());
            if (identIter->IsHtMrdBlockRam())
                m_vFile.Print(".ws( %s_WrSel%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".wa( %s_WrAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".wd( %s_WrData%s ), ", cQueName.c_str(), refDimStr.c_str());
            if (identIter->IsHtMwrBlockRam())
                m_vFile.Print(".rs( %s_RdSel%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".ra( %s_RdAddr%s ), ", cQueName.c_str(), refDimStr.c_str());
            m_vFile.Print(".rd( %s_RdData%s ) );\n", cQueName.c_str(), refDimStr.c_str());

        } while (!pBlockRam->DimenIter(refList));
    }
}
示例#6
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));
    }
}