Esempio n. 1
0
File: box.cpp Progetto: EQ4/atanua
Box::~Box()
{
    delete[] mExtPin;
    mExtPin = NULL;
    delete mBsi;
    // unlike every other chip, our tooltip is dynamically loaded.
    delete[] mTooltip;
    delete[] mDisplayString;

    // Need to fry all boxed components too!

    int found = 1;
    while (found)
    {
        found = 0;
        int i = 0;
        while (i < (signed)gChip.size() && gChip[i]->mBox != mBoxed) i++;
        if (i < (signed)gChip.size())
        {
            found = 1;
            delete_chip(gChip[i]);
        }
    }
    gActiveBoxes--;
}
Esempio n. 2
0
void NF_Page_Read(unsigned long addr, unsigned char *buff, int size)
{
	int i, len;
	
	// 选中NF
	select_chip();
	
	// 清除RnB
	clear_RnB();
	
	// 发送0x00命令
	send_cmd(0x00);
	
	// 发送2个列地址
	send_addr(0x00);
	send_addr(0x00);
	
	// 发送3个行地址
	send_addr(addr & 0xFF);
	send_addr((addr >> 8) & (0xFF));
	send_addr((addr >> 16) & (0xFF));
	
	// 发送0x30命令
	send_cmd(0x30);
	
	// 等待RnB信号
	wait_RnB();
	
	/* 判断出一个合适的size */
	if(size > PAGE_SIZE)
		len = size > PAGE_SIZE*4 ? PAGE_SIZE*4 : size;
	else if(size < PAGE_SIZE)
		len = size;
	else
		len = PAGE_SIZE;
	
//	len = size > PAGE_SIZE ? size : PAGE_SIZE;
//	if(len > PAGE_SIZE*4)
//		len = PAGE_SIZE*4;
	
	// 读取数据
	for(i=0; i < len; i++)
	{
		*buff++ = NFDATA;
	}
	
	//取消选中
	delete_chip();
}
Esempio n. 3
0
void reset()
{
	// 选中NandFlash
	select_chip();
	
	// 清除RnB(NF忙信号)
	clear_RnB();
	
	// 发送0xFF信号
	send_cmd(0xFF);
	
	// 等待RnB
	wait_RnB();
	
	// 取消选中
	delete_chip();
}
Esempio n. 4
0
void do_optimize_box(int aBox)
{
	unsigned int i = 0;
	do
	{
		if (gChip.size() &&
			gChip[i]->mBox == aBox &&
			gChip[i]->isUselessInBox())
		{
			delete_chip(gChip[i]);
		}
		else
		{
			i++;
		}
	}
	while (i < gChip.size());	
}
Esempio n. 5
0
void delete_chip(Chip *c)
{
    // First let's find the chip's index.
    int idx = 0;
    int i;
    for (i = 0; i < (signed)gChip.size(); i++)
    {
        if (gChip[i] == c)
        {
            idx = i;
            break;
        }
    }


    // Special case: if chip is "connection pin" which has two connections, fuse the two wires together.
    // Otherwise work as usual.
    if (stricmp(gChipName[idx], "Connection Pin") == 0)
    {
        int wires[2];
        int wirecount = 0;
        int w;
        wires[0] = wires[1] = 0;
        for (w = 0; w < (signed)gWire.size(); w++)
        {
            if (gWire[w]->mFirst == gChip[idx]->mPin[0] ||
                gWire[w]->mSecond == gChip[idx]->mPin[0])
            {
                if (wirecount == 2)
                {
                    wirecount++;
                    break;
                }
                wires[wirecount] = w;
                wirecount++;
            }
        }

        if (wirecount == 2)
        {
            // exactly two wires found
            Pin *loosepin = NULL;
            if (gWire[wires[0]]->mFirst == gChip[idx]->mPin[0])
            {
                loosepin = gWire[wires[0]]->mSecond;
            }
            else
            {
                loosepin = gWire[wires[0]]->mFirst;
            }

            if (gWire[wires[1]]->mFirst == gChip[idx]->mPin[0])
            {
                gWire[wires[1]]->mFirst = loosepin;
            }
            else
            {
                gWire[wires[1]]->mSecond = loosepin;
            }
            
            delete gWire[wires[0]];            
            gWire.erase(gWire.begin() + wires[0]);

            delete gChip[idx];
            gChip.erase(gChip.begin() + idx);
            gChipName.erase(gChipName.begin() + idx);
            return; 
        }
    }


    // Delete all wires connected to all pins. 
    int p;
    for (p = 0; p < (signed)c->mPin.size(); p++)
    {
        int w;
        for (w = 0; w < (signed)gWire.size(); w++)
        {
            if (gWire[w]->mFirst == c->mPin[p] ||
                gWire[w]->mSecond == c->mPin[p])
            {
                if (gConfig.mWireFry)
                {
                    //////////////////////////////////////////////////////////
                    // wire fry code
                    Pin *query = NULL;
                    
                    if (gWire[w]->mFirst == c->mPin[p])
                        query = gWire[w]->mSecond;
                    else
                        query = gWire[w]->mFirst;


                    int chipidx = 0;
                    int i;
                    for (i = 0; i < (signed)gChip.size(); i++)
                    {
                        if (gChip[i] == query->mHost)
                        {
                            chipidx = i;
                            break;
                        }
                    }

                    if (stricmp(gChipName[chipidx], "Connection Pin") == 0)
                    {
                        // Make sure it's not on the list already
                        int found = 0;
                        int k;
                        for (k = 0; !found && k < (signed)gFryList.size(); k++)
                            if (gFryList[k] == query->mHost)
                                found = 1;
                        if (!found)
                            gFryList.push_back(query->mHost);
                    }

                    // wire fry code
                    //////////////////////////////////////////////////////////
                }

                delete gWire[w];
                gWire.erase(gWire.begin() + w);
                w--; // back one step
            }
        }
    }

    if (gConfig.mWireFry)
    {
        while (!gFryList.empty())
        {
            Chip * chiptofry = gFryList.back();
            gFryList.pop_back();
            int wirecount = 0;
            int w;
            for (w = 0; w < (signed)gWire.size(); w++)
            {
                if (gWire[w]->mFirst == chiptofry->mPin[0] ||
                    gWire[w]->mSecond == chiptofry->mPin[0])
                {
                    wirecount++;
                }
            }
            if (wirecount <= 2)
            {
                delete_chip(chiptofry);
            }
        }
    }

    // now we're ready to delete the chip. 
    for (i = 0; i < (signed)gChip.size(); i++)
    {
        if (gChip[i] == c)
        {
			// tricky - deleting a chip may nuke lots of chips as it may be a box
			Chip *chip_to_delete = gChip[i];
            gChip.erase(gChip.begin() + i);
            gChipName.erase(gChipName.begin() + i);
            delete chip_to_delete;
            return; 
        }
    }

	// Remember to rebuild the nets after deletion! 
	// (Moved outside function for performance reasons)
    //build_nets();
}