void checkCount(float cnt){
  setDelay(cnt);
  loop();
  int count = counter.value*2+1;
  int i;
  for(i=0; !delayIsHigh() && i<100; ++i)
    toggleClock();
  BOOST_CHECK_EQUAL(i, count);
  toggleClock();
  for(i=0; !delayIsHigh() && i<100; ++i)
    toggleClock();
  BOOST_CHECK_EQUAL(i, count);
  toggleClock();
}
void checkDivideAndCount(float div, float cnt){
  setDivide(div);
  setDelay(cnt);
  loop();
  reset();
  int count = counter.value;
  int pulses = divider.value;
  BOOST_CHECK(pulses > count/2);
  int cycles = pulses*2+count*2+1;
  int i;
  for(i=0; !combinedIsHigh(); ++i)
    toggleClock();
  BOOST_CHECK_EQUAL(i, cycles);
  toggleClock();
  for(i=0; !combinedIsHigh(); ++i)
    toggleClock();
  BOOST_CHECK_EQUAL(i, pulses*2+1);
  toggleClock();
}
void checkSwing(float div, float del){
  setDivide(div);
  setDelay(del);
  setDelayMode();
  loop();
  int cycles = divider.value*2+1;
  int time = delay.value/2+1;
  int ticks = delay.value-time;
  int i;
  for(i=0; clockIsHigh() == combinedIsHigh() && i<1000; ++i)
    toggleClock();
  BOOST_CHECK_EQUAL(i, cycles);
  BOOST_CHECK(swinger.running == true);
  BOOST_CHECK(clockIsHigh());
  callTimer(time);
  setClock(false);
  for(i=0; !combinedIsHigh() && i<1000; ++i)
    callTimer();
  BOOST_CHECK_EQUAL(i, ticks);
  for(i=0; combinedIsHigh() && i<1000; ++i)
    callTimer();
  BOOST_CHECK_EQUAL(i, time);
}
Exemple #4
0
HockeyGame::HockeyGame(QString awayXML, QString homeXML, QString sponsor,
                       QString awayRank, QString homeRank, int screenWidth) :
    sponsor(sponsor),awayRank(awayRank), homeRank(homeRank),
    sb(sponsor, &gameClock, awayRank, homeRank), comparisonPreview(true),
    #ifdef GRADIENT_LOOK
    lt (awayColor, homeColor, screenWidth)
  #else
    lt(screenWidth), previewLt(screenWidth)
  #endif
{
    useClock = true;
    isFinal = false;
    awayScore = 0;
    homeScore = 0;
    homeSOG = 0;
    awaySOG = 0;
    period = 0;
    awayPlayersOnIce = 5;
    homePlayersOnIce = 5;
    timer.setTimerType(Qt::PreciseTimer);
    timer.setInterval(100);
    cgTimer.setTimerType(Qt::PreciseTimer);
    cgTimer.setInterval(100);
    tricasterRefresh.setInterval(1000*30);
    clockRunning = false;
    penaltiesActive = false;

    connect(&gameClock, SIGNAL(clockExpired()),
            this, SLOT(toggleClock()));
    connect(&timer, SIGNAL(timeout()), &gameClock, SLOT(tick()));
    connect(this, SIGNAL(periodChanged(int)), &sb, SLOT(updatePeriod(int)));
    connect(this, SIGNAL(awayScoreChanged(int)), &sb, SLOT(updateAwayScore(int)));
    connect(this, SIGNAL(homeScoreChanged(int)), &sb, SLOT(updateHomeScore(int)));
    connect(this, SIGNAL(penaltyChanged(int,Clock*,QString)), &sb, SLOT(preparePowerplayClock(int,Clock*,QString)));
    connect(this, SIGNAL(checkScoreboardPp()), this, SLOT(determinePpClockForScoreboard()));
    // Make teams...
    homeTeam = new HockeyTeam();
    awayTeam = new HockeyTeam();

    SeasonXMLHandler handler(homeTeam);
    handler.parseFile(homeXML);
    HockeyPlayer empty;
    empty.setName("No Name");
    homeTeam->addPlayer(empty);
    SeasonXMLHandler roadHandler(awayTeam);
    roadHandler.parseFile(awayXML);
    awayTeam->addPlayer(empty);

    firedPeriodChange = false;
    waitingForPeriodStart = false;
}

void
HockeyGame::awayGoal() {
    awayScore ++;
    if (useClock)
        timeEventHappened = period > 3 ? gameClock.getTimeSinceOtStarted() :
                                         gameClock.getTimeSincePdStarted();
    emit awayScoreChanged(awayScore);
    if (getHomeTeam()->getPlayerInGoal()) {
        homeTeam->getGoalie().addGa();
    }
    awaySOG++;
    emit awaySogChanged(awaySOG);
}
int main () {
  
    DEF_GENPAT("dpt_regfile_genpat");

    // endereços de entrada
    DECLAR("CLK", ":2", "B", IN , "", "");

    DECLAR("A3" , ":2", "X", IN , "4 down to 0" , "");
    DECLAR("WD3", ":2", "X", IN , "31 down to 0", "");
    DECLAR("WE3", ":2", "B", IN , "", "");

    DECLAR("A1" , ":2", "X", IN , "4 down to 0" , "");
    DECLAR("RD1", ":2", "X", OUT, "31 down to 0", "");

    DECLAR("A2" , ":2", "X", IN , "4 down to 0" , "");
    DECLAR("RD2", ":2", "X", OUT, "31 down to 0", "");

    DECLAR("Vdd", ":2", "B", IN , "", "" );
    DECLAR("Vss", ":2", "B", IN , "", "" );

    LABEL ("regfile");

    AFFECT(cvect(), "Vdd", "0b1");
    AFFECT(cvect(), "Vss", "0b0");
    AFFECT(cvect(), "CLK", inttostr(CLK));
  
    RegInit();
    RegAffect();
    
    RegA3 = 0;
    RegWD3 = 0xFFFFFFFF;
    RegWE3 = 1;
    RegAffect();
    
    curvect++;
    toggleClock();
    RegWrite();

    curvect++;
    toggleClock();
    
    int reg;

    for(reg = 1; reg < 32; reg++) {
        RegA1 = reg - 1;
        RegA2 = reg;
        RegA3 = reg;
        
        RegWD3 = 0x00000000;
        RegWE3 = 1;
        RegAffect();
        
        curvect++; toggleClock();
        RegWrite();
        curvect++; toggleClock();
        
        RegWD3 = 0xFFFFFFFF;
        RegWE3 = 0;
        RegAffect();
        
        curvect++; toggleClock();
        RegWrite();
        curvect++; toggleClock();
        
        RegWE3 = 1;
        RegAffect();
        
        curvect++; toggleClock();
        RegWrite();
        curvect++; toggleClock();
        
        RegWD3 = 0x00000000;
        RegWE3 = 0;
        RegAffect();
        
        curvect++; toggleClock();
        RegWrite();
        curvect++; toggleClock();
        
        RegWE3 = 1;
        RegAffect();
        
        curvect++; toggleClock();
        RegWrite();
        curvect++; toggleClock();
        
        if(reg % 2 == 1) {
            RegWD3 = 0xFFFFFFFF;
            RegWE3 = 1;
            RegAffect();
            
            curvect++; toggleClock();
            RegWrite();
            curvect++; toggleClock();
        }
        
    }  

    SAV_GENPAT ();

    return 0;
}
int main() {
	FILE *arq = NULL;
    
    char patFilename[] = __FILE__;
    patFilename[ strlen(patFilename)-2 ] = '\0';

	arq = fopen("instructions/control.txt", "r+");
	
	if( !arq ) {
		fprintf(stderr, "\nCouldn't open 'instructions/control.txt' file.\n");
		return 1;
	}
	
	DEF_GENPAT(patFilename);
	
	DECLAR("CLK"	, ":2", "B", IN , "", "");
	DECLAR("Reset"	, ":2", "B", IN , "","");

	DECLAR("State"		, ":2", "X", OUT, "3 down to 0", "");

	DECLAR("Opcode"	, ":2", "B", IN , "5 down to 0", "");
	
	// Multiplexer Selects
	DECLAR("MemtoReg"	, ":2", "B", OUT, "", "");
	DECLAR("RegDst"		, ":2", "B", OUT, "", "");
	DECLAR("IorD"		, ":2", "B", OUT, "", "");
	DECLAR("PCSrc"		, ":2", "B", OUT, "1 down to 0", "");
	DECLAR("ALUSrcA"	, ":2", "B", OUT, "", "");
	DECLAR("ALUSrcB"	, ":2", "B", OUT, "1 down to 0", "");
	DECLAR("ALUOp"	    , ":2", "B", OUT, "1 down to 0", "");
	
	// Registers Enables
	DECLAR("IRWrite"	, ":2", "B", OUT, "", "");
	DECLAR("MemWrite"	, ":2", "B", OUT, "", "");	
	DECLAR("PCWrite"	, ":2", "B", OUT, "", "");
	DECLAR("RegWrite"	, ":2", "B", OUT, "", "");
	DECLAR("Branch"		, ":2", "B", OUT, "", "");

	DECLAR ("Vdd"		, ":2", "B", IN , "", "");
	DECLAR ("Vss"		, ":2", "B", IN , "", "");


	AFFECT ("0", "Vdd", "1");
	AFFECT ("0", "Vss", "0");
	AFFECT ("0", "CLK", "0");
    AFFECT ("0", "Reset", "1");
    AFFECT ("0", "Opcode", "0");
    
    FsmMode = MODE_FSM;
    
    curvect++;
    toggleClock();
    FsmReset();
    
    curvect++;
    toggleClock();
    
    AFFECT (cvect(), "Reset", "0");
    curvect++;
    
	while(1) {
    
        toggleClock();
        
        FsmRunState();
        
        curvect++;
        toggleClock();
        
        if(FsmNextState == 1) {
            if( !getNextInstr(arq) ) {
                break;
            }
            
            AFFECT(cvect(), "Opcode", inttostr(DecOpcode));
            FsmOpcode = DecOpcode;
        }
        curvect++;
        
	}
	
	SAV_GENPAT();
	
	return 0;
}