コード例 #1
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
ECDFlipFlop::ECDFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id )
	: ClockedFlipFlop( icnDocument, newItem, id ? id : "d_flipflop" )
{
	m_name = i18n("D-Type Flip-Flop");
	
	setSize( -32, -24, 64, 48 );
	init2PinLeft( -8, 8 );
	init2PinRight( -8, 8 );
	initSymbolFromTrigger();
	
	m_prevD = false;
	m_pSimulator = Simulator::self();
	
	m_bPrevClock = false;
	m_pD = createLogicIn( m_pNNode[0] );
	m_pClock = createLogicIn( m_pNNode[1] );
	m_pQ = createLogicOut( m_pPNode[0], false );
	m_pQBar = createLogicOut( m_pPNode[1], false );
	
	setp = createLogicIn( createPin( 0, -32, 90, "set" ) );
	rstp = createLogicIn( createPin( 0, 32, 270, "rst" ) );
	
	// (The display text for D, >, Set, Rst is set in initSymbolFromTrigger
	addDisplayText( "Q",	QRect( 12,	-16,	20, 16 ), "Q" );
	addDisplayText( "Q'",	QRect( 12,	0,		20, 16 ), "Q'" );
	
	m_pD->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::inputChanged) );
	m_pClock->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::clockChanged) );
	setp->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::asyncChanged) );
	rstp->setCallback( this, static_cast<CallbackPtr>(&ECDFlipFlop::asyncChanged) );
	
	inStateChanged(false);
}
コード例 #2
0
Inverter::Inverter( ICNDocument *icnDocument, bool newItem, const char *id )
	: Component( icnDocument, newItem, id ? id : "not" )
{
	m_name = i18n("Inverter");
	setSize( -8, -8, 16, 16 );

	init1PinLeft();
	init1PinRight();
	
	m_pIn = createLogicIn(m_pNNode[0]);
	m_pOut = createLogicOut( m_pPNode[0], true );
	
	m_pIn->setCallback( this, (CallbackPtr)(&Inverter::inStateChanged) );
	inStateChanged(false);
}
コード例 #3
0
void MultiInputGate::updateInputs(int newNum) {
	if (newNum == m_numInputs) return;

	if (newNum < 2) newNum = 2;
	else if (newNum > maxGateInput)
		newNum = maxGateInput;

	int newWidth = logicSymbolShapeToWidth();

	QRect r(-newWidth / 2, -8 * newNum, newWidth, 16 * newNum);

	setSize(r, true);
	updateSymbolText();

	const bool added = (newNum > m_numInputs);

	if (added) {
		for (int i = m_numInputs; i < newNum; ++i) {
			ECNode *node = createPin(0, 0, 0, "in" + QString::number(i));
			inNode[i] = node;

			inLogic[i] = new LogicIn(LogicConfig());
			setup1pinElement(*(inLogic[i]), node->pin());

			inLogic[i]->setCallback(this, (CallbackPtr)(&MultiInputGate::inStateChanged));
		}
	} else {
		for (int i = newNum; i < m_numInputs; ++i) {
			removeNode("in" + QString::number(i));
			removeElement(inLogic[i], false);
			inNode[i] = 0;
			inLogic[i] = 0;
		}
	}

	m_numInputs = newNum;

	// We can't call a pure-virtual function if we haven't finished our constructor yet...

	if (m_bDoneInit)
		inStateChanged(!added);

	updateAttachedPositioning();
}
コード例 #4
0
ファイル: flipflop.cpp プロジェクト: ktechlab/ktechlab-0.3
ECJKFlipFlop::ECJKFlipFlop( ICNDocument *icnDocument, bool newItem, const char *id )
	: ClockedFlipFlop( icnDocument, newItem, id ? id : "jk_flipflop" )
{
	m_name = i18n("JK-Type Flip-Flop");
	
	setSize( -32, -32, 64, 64 );
	init3PinLeft( -16, 0, 16 );
	init2PinRight( -16, 16 );
	initSymbolFromTrigger();
	
	m_bPrevClock = false;
	
	createProperty( "trig", Variant::Type::Select );
	property("trig")->setCaption( i18n("Trigger Edge") );
	QStringMap allowed;
	allowed["Rising"] = i18n("Rising");
	allowed["Falling"] = i18n("Falling");
	property("trig")->setAllowed( allowed );
	property("trig")->setValue("Rising");
	m_edgeTrigger = Rising;
	initSymbolFromTrigger();
	
	m_pJ = createLogicIn( m_pNNode[0] );
	m_pClock = createLogicIn( m_pNNode[1] );
	m_pK = createLogicIn( m_pNNode[2] );
	
	m_pQ = createLogicOut( m_pPNode[0], false );
	m_pQBar = createLogicOut( m_pPNode[1], false );

	setp = createLogicIn( createPin( 0, -40, 90, "set" ) );
	rstp = createLogicIn( createPin( 0, 40, 270, "rst" ) );
	
	addDisplayText( "Q",	QRect( 12,	-24,	20, 16 ), "Q" );
	addDisplayText( "Q'",	QRect( 12,	8,		20, 16 ), "Q'" );
		
	m_pClock->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::clockChanged) );
	setp->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::asyncChanged) );
	rstp->setCallback( this, static_cast<CallbackPtr>(&ECJKFlipFlop::asyncChanged) );
	
	inStateChanged(false);
}
コード例 #5
0
ECAnd::ECAnd(ICNDocument *icnDocument, bool newItem, const char *id)
                      : MultiInputGate(icnDocument, newItem, id ? id : "and", "&", false, 32, false) {
	m_name = i18n("AND Gate");

	inStateChanged(false);
}
コード例 #6
0
ECNor::ECNor(ICNDocument *icnDocument, bool newItem, const char *id)
                    : MultiInputGate(icnDocument, newItem, id ? id : "nor", QChar(0x2265) + QString("1"), true, 48, true) {
	m_name = i18n("NOR Gate");

	inStateChanged(false);
}
コード例 #7
0
ECXor::ECXor(ICNDocument *icnDocument, bool newItem, const char *id)
                       : MultiInputGate(icnDocument, newItem, id ? id : "xor", "=1", false, 48, true) {
	m_name = i18n("XOR gate");

	inStateChanged(false);
}