Example #1
0
/* Show current setup */
void vpr_show_setup(INP t_options options, INP t_vpr_setup vpr_setup) {
	ShowSetup(options, vpr_setup);
}
Example #2
0
/* Initialize VPR 
 1. Read Options
 2. Read Arch
 3. Read Circuit
 4. Sanity check all three
 */
void vpr_init(INP int argc, INP char **argv, OUTP t_options *options,
		OUTP t_vpr_setup *vpr_setup, OUTP t_arch *arch) {
	char* pszLogFileName = "vpr_stdout.log";
	unsigned char enableTimeStamps = 1;
	unsigned long maxWarningCount = 100000;
	unsigned long maxErrorCount = 1000;

	if (PrintHandlerExists() == 1) {
		has_printhandler_pre_vpr = TRUE;
	} else {
		has_printhandler_pre_vpr = FALSE;
	}
	if (has_printhandler_pre_vpr == FALSE) {
		PrintHandlerNew(pszLogFileName);
		PrintHandlerInit(enableTimeStamps, maxWarningCount, maxErrorCount);
	}

	/* Print title message */
	vpr_print_title();

	/* Print usage message if no args */
	if (argc < 3) {
		vpr_print_usage();
		exit(1);
	}

	memset(options, 0, sizeof(t_options));
	memset(vpr_setup, 0, sizeof(t_vpr_setup));
	memset(arch, 0, sizeof(t_arch));

	/* Read in user options */
	ReadOptions(argc, argv, options);
	/* Timing option priorities */
	vpr_setup->TimingEnabled = IsTimingEnabled(options);
	/* Determine whether echo is on or off */
	setEchoEnabled(IsEchoEnabled(options));
	setDumpVtbEnabled(IsDumpVtbEnabled(options));
	SetPostSynthesisOption(IsPostSynthesisEnabled(options));
	vpr_setup->constant_net_delay = options->constant_net_delay;

	/* Read in arch and circuit */
	SetupVPR(options, vpr_setup->TimingEnabled, TRUE, &vpr_setup->FileNameOpts,
			arch, &vpr_setup->Operation, &vpr_setup->user_models,
			&vpr_setup->library_models, &vpr_setup->PackerOpts,
			&vpr_setup->PlacerOpts, &vpr_setup->AnnealSched,
			&vpr_setup->RouterOpts, &vpr_setup->RoutingArch,
			&vpr_setup->Segments, &vpr_setup->Timing, &vpr_setup->ShowGraphics,
			&vpr_setup->GraphPause, &vpr_setup->PowerOpts);

	/* Check inputs are reasonable */
	CheckOptions(*options, vpr_setup->TimingEnabled);
	CheckArch(*arch, vpr_setup->TimingEnabled);

	/* Verify settings don't conflict or otherwise not make sense */
	CheckSetup(vpr_setup->Operation, vpr_setup->PlacerOpts,
			vpr_setup->AnnealSched, vpr_setup->RouterOpts,
			vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing,
			arch->Chans);

	/* flush any messages to user still in stdout that hasn't gotten displayed */
	fflush(stdout);

	/* Read blif file and sweep unused components */
	read_and_process_blif(vpr_setup->PackerOpts.blif_file_name,
			vpr_setup->PackerOpts.sweep_hanging_nets_and_inputs,
			vpr_setup->user_models, vpr_setup->library_models,
			vpr_setup->PowerOpts.do_power, vpr_setup->FileNameOpts.ActFile);
	fflush(stdout);

	ShowSetup(*options, *vpr_setup);
}
Example #3
0
int
main(int argc,
     char **argv)
{
	int simSize = 14;
	int xx;
	simResults = (double *) malloc(simSize*sizeof(double));
	simCounts = (unsigned long *) malloc(simSize*sizeof(unsigned long));
	simIndex = 0;
	
	for(xx = 0; xx < simSize ; xx++)
	{
		simResults[xx] = 0.0;
		simCounts[xx] = 0;
	}
	
	
    t_options Options;
    t_arch Arch = { 0 };

	enum e_operation Operation;
    struct s_placer_opts PlacerOpts;
    struct s_annealing_sched AnnealSched;
    struct s_router_opts RouterOpts;
    struct s_det_routing_arch RoutingArch;
    t_segment_inf *Segments;
    t_timing_inf Timing;
    t_subblock_data Subblocks;
    boolean ShowGraphics;
    boolean TimingEnabled;
    int GraphPause;


    /* Print title message */
    PrintTitle();

    /* Print usage message if no args */
    if(argc < 2)
	{
	    PrintUsage();
	    exit(1);
	}

    /* Read in available inputs  */
    ReadOptions(argc, argv, &Options);

    /* Determine whether timing is on or off */
    TimingEnabled = IsTimingEnabled(Options);

    /* Use inputs to configure VPR */
    SetupVPR(Options, TimingEnabled, &Arch, &Operation, &PlacerOpts,
	     &AnnealSched, &RouterOpts, &RoutingArch, &Segments,
	     &Timing, &Subblocks, &ShowGraphics, &GraphPause);

    /* Check inputs are reasonable */
    CheckOptions(Options, TimingEnabled);
    CheckArch(Arch, TimingEnabled);

    /* Verify settings don't conflict or otherwise not make sense */
    CheckSetup(Operation, PlacerOpts, AnnealSched, RouterOpts,
	       RoutingArch, Segments, Timing, Subblocks, Arch.Chans);

    /* Output the current settings to console. */
    ShowSetup(Options, Arch, TimingEnabled, Operation, PlacerOpts,
	      AnnealSched, RouterOpts, RoutingArch, Segments, Timing,
	      Subblocks);

	if(Operation == TIMING_ANALYSIS_ONLY) {
		do_constant_net_delay_timing_analysis(
			Timing, Subblocks, Options.constant_net_delay);
		return 0;
	}

    /* Startup X graphics */
    set_graphics_state(ShowGraphics, GraphPause, RouterOpts.route_type);
    if(ShowGraphics)
	{
	    init_graphics("VPR:  Versatile Place and Route for FPGAs");
	    alloc_draw_structs();
	}

    /* Do the actual operation */
    place_and_route(Operation, PlacerOpts, Options.PlaceFile,
		    Options.NetFile, Options.ArchFile, Options.RouteFile,
		    AnnealSched, RouterOpts, RoutingArch,
		    Segments, Timing, &Subblocks, Arch.Chans);

    /* Close down X Display */
    if(ShowGraphics)
	close_graphics();

	/* free data structures */
	free(Options.PlaceFile);
	free(Options.NetFile);
	free(Options.ArchFile);
	free(Options.RouteFile);

	freeArch(&Arch);
	
	printf("\nTiming Results\n");
	for(xx = 0; xx < simSize ; xx++)
	{
		if(simCounts[xx] != 0)
		{
			simResults[xx] /= (double) simCounts[xx];
		}
		
		printf("Index: %d\tAverage Clock: %f\n", xx, simResults[xx]);
		
	}
	
	
	free(simResults);
	free(simCounts);
	
    /* Return 0 to single success to scripts */
    return 0;
}
Example #4
0
File: c-ufo.c Project: gke/UAVP
void main(void)
{
	uns8	DropoutCount;
	int		nii@NegFact;
	uns8	LowGasCount;

	OPTION_REG = 0b.00000.011;	// TMR0 w/ int clock, 1:16 presc (see _PreScale0),
					// weak pullups on
// general ports setup
	TRISA = 0b.00111111;	// all inputs
	ADCON1 = 0b.0.000.0010;	// uses 5V as Vref

#ifdef BOARD_3_0
	PORTB = 0b.1000.0000;		// all outputs to low, except RB7 (LISL-CS)!
	TRISB = 0b.0000.0000;	// all servo and LED outputs
	PORTC = 0b.0100.0000;		// all outputs to low, except TxD
	TRISC = 0b.10000100;	// RC7, RC2 are inputs
#endif
#ifdef BOARD_3_1
	PORTB = 0b.1100.0000;		// all outputs to low, except RB6 & 7 (I2C)!
	TRISB = 0b.0100.0000;	// all servo and LED outputs
	PORTC = 0b.0110.0000;		// all outputs to low, except TxD and CS
	TRISC = 0b.10000100;	// RC7, RC2 are inputs
	RBPU_ = 1;			// enable weak pullups
#endif

#ifdef BOARD_3_1
	LedShadow = 0;
#endif

    ALL_LEDS_OFF;

// timer setup
	T1CON = 0b.00.11.0001;	// enable TMR1, 1:8 prescaler, run with 2us clock
	CCP1CON = 0b.00.00.0100;	// capture mode every falling edge

	TMR2 = 0;
	T2CON = 0b.0.1111.1.11;	// enable TMR2, 1:16 prescaler, 1:16 postscaler (see _Pre/PostScale2)
	PR2 = TMR2_5MS;		// set compare reg to 9ms

// setup flags register
	Flags = 0;
	_NoSignal = 1;		// assume no signal present

	InitArrays();

	LedRed_ON;		// red LED on
	Delaysec(1);	// wait 1/10 sec until LISL is ready to talk
#ifdef USE_ACCSENS
	IsLISLactive();
#ifdef ICD2_DEBUG
	_UseLISL = 1;	// because debugger uses RB7 (=LISL-CS) :-(
#endif
	NeutralLR = 0;
	NeutralFB = 0;
	NeutralUD = 0;
	if( _UseLISL )
		GetEvenValues();	// into Rp, Np, Tp
#endif

// setup serial port for 8N1
	TXSTA = 0b.0010.0100;	// async mode, BRGH = 1
	RCSTA = 0b.1001.0000;	// receive mode
	SPBRG = _B38400;
#ifdef BOARD_3_0
	_SerEnabled = 1;	// serial link is enabled
#endif
	W = RCREG;			// be sure to empty FIFO

// enable the interrupts
	CCP1IE = 1;
	TMR2IE = 1;		// T1-Capture and T2 interrupt enable
		
	PEIE = 1;		// enable peripheral interrupts


// send hello text to serial COM
	Delaysec(1);	// just to see the output after powerup

	ShowSetup(1);

	IK6 = IK7 = _Neutral;

#ifdef BOARD_3_1
	InitDirection();	// init compass sensor
#endif

Restart:
	IGas =IK5 = _Minimum;	// assume parameter set #1

// DON'T MOVE THE UFO!
// ES KANN LOSGEHEN!

	while(1)
	{
		T0IE = 0;		// disable TMR0 interrupt
		ALL_LEDS_OFF;
		LedRed_ON;		// red LED on
		if(_UseLISL)
			LedYellow_ON;	// to signal LISL sensor is active

		InitArrays();

		GIE = 1;		// enable all interrupts

// Wait until a valid RX signal is received

		DropoutCount = MODELLOSTTIMER;
		do
		{
			Delaysec(2);	// wait 2/10 sec until signal is there
			ProcessComCommand();
			if( _NoSignal )
			{
				if( Switch )
				{
					if( --DropoutCount == 0 )
					{
						Beeper_TOG;	// toggle beeper "model lost"
						DropoutCount = MODELLOSTTIMERINT;
					}
				}
				else
					Beeper_OFF;
			}
		}
		while( _NoSignal || !Switch);	// no signal or switch is off

// RX Signal is OK now
// Wait 2 sec to allow enter of prog mode
		LedRed_OFF;
		LedYellow_ON;	
		Delaysec(20);
		LedYellow_OFF;

// die Variablen einlesen
		ReadEEdata();
		
// check for prog mode (max. throttle)
		if( IGas > _ProgMode ) 
		{
			DoProgMode();
			goto Restart;
		}

// Just for safety: don't let motors start if throttle is open!
// check if Gas is below _ThresStop

		DropoutCount = 1;
		while( IGas >= _ThresStop )
		{
			if( _NoSignal )
				goto Restart;

			if( _NewValues )
			{
				OutSignals();
				_NewValues = 0;
				if( --DropoutCount <= 0 )
				{
					LedRed_TOG;	// toggle red Led 
					DropoutCount = 10;		// to signal: THROTTLE OPEN
				}
			}
			ProcessComCommand();
		}

// ###############
// ## MAIN LOOP ##
// ###############
// loop length is controlled by a programmable variable "TimeSlot"
// which sets wait time in ms
// standard ESCs will need at least 9 or 10 as TimeSlot.
		DropoutCount = 0;
		BlinkCount = 0;
		IntegralCount = 32;	// do 32 cycles to find integral zero point

		while(Switch == 1)	// as long as power switch is ON
		{
// wait pulse pause delay time (TMR0 has 1024us for one loop)
			TMR0 = 0;
			T0IF = 0;
			T0IE = 1;	// enable TMR0

			RollSamples =
			NickSamples = 0;	// zero gyros sum-up memory
// sample gyro data and add everything up while waiting for timing delay

			GetGyroValues();
#ifdef BOARD_3_1
			if( (BlinkCount & 0x03) == 0 )	// enter every 4th scan
				GetDirection();	// read compass sensor
#endif

			while( TimeSlot > 0 )
			{
// Here is the place to insert own routines
// It should consume as less time as possible!
// ATTENTION:
// Your routine must return BEFORE TimeSlot reaches 0
// or non-optimal flight behavior might occur!!!
			}

			T0IE = 0;	// disable timer
			GetGyroValues();
			nisampcnt = 2;	// 2 samples done


/* this section is no longer needed
			if( nisampcnt & 0x01 )	// odd value?
			{
				nisampcnt++;	// one more sample to get even numbers
				GetGyroValues();
			}
*/
			ReadEEdata();	// re-sets TimeSlot

// Setup Blink counter
			if( BlinkCount == 0 )
				BlinkCount = BLINK_LIMIT;
			BlinkCount--;

// get the gyro values and Batt status
			CalcGyroValues();
			GetVbattValue();

// check for signal dropout while in flight
			if( _NoSignal && _Flying )
			{
				DropoutCount++;
				if( DropoutCount < MAXDROPOUT )
				{	// use last Gas
					ALL_LEDS_OFF;
					IRoll = 0;
					INick = 0;
					ITurn = 0;
					goto DoPID;
				}
				break;	// timeout, stop everything
			}
// allow motors to run on low throttle 
// even if stick is at minimum for a short time
			if( _Flying && (IGas <= _ThresStop) )
			{
				if( --LowGasCount > 0 )
					goto DoPID;
			}

			if( _NoSignal || 
			    ( (_Flying && (IGas <= _ThresStop)) ||
			      (!_Flying && (IGas <= _ThresStart)) ) )
			{	// UFO is landed, stop all motors

				TimeSlot += 2; // to compensate PID() calc time!

				IntegralCount = 32;	// do 32 cycles to find integral zero point
				InitArrays();	// resets _Flying flag!
				MidRoll = 0;	// gyro neutral points
				MidNick = 0;
				MidTurn = 0;
				YawNeutral  = 
				RollNeutral = 	// stick neutral points
				NickNeutral = 0x7F;
				if( _NoSignal && Switch )	// _NoSignal set, but Switch is on?
				{
					break;	// then RX signal was lost
				}
				ALL_LEDS_OFF;
				LedGreen_ON;

#ifdef BOARD_3_0
				if( !_SerEnabled )
				{
					SPEN = 1;	// enable RS232
					CREN = 1;
					_SerEnabled = 1;
				}
#endif
				ProcessComCommand();
			}
			else
			{	// UFO is flying!
				if( !_Flying )	// about to start
				{	// set current gyro values as midpoints
					if( RollNeutral == 0x7F )  
						RollNeutral = IRoll;
					if( NickNeutral == 0x7F )
						NickNeutral = INick;
					if( YawNeutral  == 0x7F )
						YawNeutral  = ITurn;
#ifdef BOARD_3_1
					AbsDirection = COMPASS_INVAL;
#endif

#ifdef BOARD_3_0
// check if LISL Sensor is available
					if( _UseLISL && _SerEnabled )
					{
						SPEN = 0;	// disable RS232 to allow LISL sensor to work
						CREN = 0;
						TRISC.7 = 1;	// RC7 is input (data)
						TRISC.6 = 0;	// RC6 is output (clock)
						_SerEnabled = 0;
					}

// if no LISL available, do COM commands also (important if you set ConfigParam wrong!)
					if( _SerEnabled )
#endif
						ProcessComCommand();
				}

				_Flying = 1;
				DropoutCount = 0;
				LowGasCount = 100;
#ifdef NADA // test
				ALL_LEDS_OFF;
				nii = IRoll - RollNeutral;
				if( (nii > 5) || (nii < -5) )
					LedRed_ON;
				nii = INick - NickNeutral;
				if( (nii > 5) || (nii < -5) )
					LedYellow_ON;
				nii = ITurn - YawNeutral;
				if( (nii > 5) || (nii < -5) )
					LedBlue_ON;
#endif
					
// LED game 
#ifndef NOLEDGAME
// do the LED game :-)
				ALL_LEDS_OFF;
#define LED_SHOW_LIM	2
				if( !_LowBatt )
				{
					nii = IRoll-RollNeutral;
					if( nii >  LED_SHOW_LIM )
					{
						LedRed_ON;
					}
					if( nii < -LED_SHOW_LIM )
					{
						LedGreen_ON;
					}
					x = INick-NickNeutral;
					if( nii >  LED_SHOW_LIM )
					{
						LedBlue_ON;
					}
					if( nii < -LED_SHOW_LIM )
					{
						LedYellow_ON;
					}
					if( ARE_ALL_LEDS_OFF )
						ALL_LEDS_ON;
				}
#endif
DoPID:
// do the calculations
				Rp = 0;
				Np = 0;
				if(	IntegralCount > 0 )
					IntegralCount--;
				else
				{
					PID();
					MixAndLimit();
				}

// remember old gyro values
				REp = RE;
				NEp = NE;
				TEp = TE;
			}

			if( _LowBatt )
			{
				if( BlinkCount < BLINK_LIMIT/2 )
				{
					Beeper_OFF;
					LedRed_OFF;
				}
				else
				{
					Beeper_ON;
					LedRed_ON;
				}
			}

			// Output the results to the speed controllers
			MixAndLimitCam();
			OutSignals();

		}	// END NORMAL OPERATION WHILE LOOP

// CPU kommt hierher wenn der Schalter ausgeschaltet wird
		Beeper_OFF;
#ifdef BOARD_3_0
		SPEN = 1;	// enable RS232
		CREN = 1;
		_SerEnabled = 1;
#endif
	}
	ALL_OUTPUTS_OFF;
}
Example #5
0
File: pu-test.c Project: gke/UAVP
void main(void)
{
	int8	i;

	DisableInterrupts;

	InitPorts();
	InitADC();

	OpenUSART(USART_TX_INT_OFF&USART_RX_INT_OFF&USART_ASYNCH_MODE&
			USART_EIGHT_BIT&USART_CONT_RX&USART_BRGH_HIGH, _B38400);
	
	OpenTimer0(TIMER_INT_OFF&T0_8BIT&T0_SOURCE_INT&T0_PS_1_16);
	OpenTimer1(T1_8BIT_RW&TIMER_INT_OFF&T1_PS_1_8&T1_SYNC_EXT_ON&T1_SOURCE_CCP&T1_SOURCE_INT);

	OpenCapture1(CAPTURE_INT_ON & C1_EVERY_FALL_EDGE); 	// capture mode every falling edge
	CCP1CONbits.CCP1M0 = NegativePPM;

	OpenTimer2(TIMER_INT_ON&T2_PS_1_16&T2_POST_1_16);		
	PR2 = TMR2_5MS;		// set compare reg to 9ms

	INTCONbits.TMR0IE = false;

	// setup flags register
	for ( i = 0; i<16; i++ )
		Flags[i] = false;

	_NoSignal = true;
	InitArrays();
	ReadParametersEE();
	ConfigParam = 0;

    ALL_LEDS_OFF;
	Beeper_OFF;

	LedBlue_ON;

	INTCONbits.PEIE = true;		// enable peripheral interrupts
	EnableInterrupts;

	LedRed_ON;		// red LED on

	Delay1mS(100);
	IsLISLactive();
#ifdef ICD2_DEBUG
	_UseLISL = 1;	// because debugger uses RB7 (=LISL-CS) :-(
#endif

	NewK1 = NewK2 = NewK3 = NewK4 =NewK5 = NewK6 = NewK7 = 0xFFFF;

	PauseTime = 0;

	InitBarometer();

	InitDirection();
	Delay1mS(COMPASS_TIME);

	// send hello text to serial COM
	Delay1mS(100);
	ShowSetup(true);
	Delay1mS(BARO_PRESS_TIME);
	while(1)
	{
		// turn red LED on of signal missing or invalid, green if OK
		// Yellow led to indicate linear sensor functioning.
		if( _NoSignal || !Switch )
		{
			LedRed_ON;
			LedGreen_OFF;
			if ( _UseLISL  )
				LedYellow_ON;
		}
		else
		{
			LedGreen_ON;
			LedRed_OFF;
			LedYellow_OFF;
		}

		ProcessComCommand();

	}
} // main
Example #6
0
// if a command is waiting, read and process it.
// Do NOT call this routine while in flight!
void ProcessComCommand(void)
{
    int size1 *p;
	uns8 nireg;
	
	nireg = RecvComChar();
	if( nireg.6 )	// 0x40..0x7F, a character
		nireg.5=0;
	switch( nireg )
	{
		case '\0' : break;
		case 'L'  :	// List parameters
			SendComText(SerList);	// must send it (UAVPset!)
			if( IK5 > _Neutral )
				SendComChar('2');
			else
				SendComChar('1');
			ReadEEdata();
			nireg = 1;
			for(p = &FirstProgReg; p <= &LastProgReg; p++)
			{
				SendComText(SerReg1);
				SendComValU(nireg);
				SendComText(SerReg2);
				SendComValS(*p);
				nireg++;
			}
			ShowPrompt();
			break;
		case 'M'  : // modify parameters
			LedBlue_ON;
			SendComText(SerReg1);
			nireg = RecvComNumU();
			nireg--;
			SendComText(SerReg2);	// = 
			nival = RecvComNumS();
			EEDATA = nival;
			if( IK5 > _Neutral )
				nireg += _EESet2;
			EEADR = nireg;
// prog values into data flash
			ProgRegister();

// if config register on set #1 is progged,
// write through the transmitter config bits to set #2
			if( nireg == 15 /* = &ConfigParam - &FirstProgReg */ )
			{
				nival &= 0x12;	// read the programmed value
					// mask only bits _FutabaMode and _NegativePPM
				EEADR += _EESet2;	// goto set #2
// da gehts no
				RD = 1;
// da niimer
				EEDATA &= 0xED;
				EEDATA |= nival;

				ProgRegister();	// write to set#2 config reg
			}
			LedBlue_OFF;
			ShowPrompt();
			break;
		case 'S' :	// show status
			ShowSetup(0);
			break;
		case 'N' :	// neutral values
			SendComText(SerNeutralR);
			SendComValS(NeutralLR);

			SendComText(SerNeutralN);
			SendComValS(NeutralFB);

			SendComText(SerNeutralY);
			Tp -= 1024;		// subtract 1g (vertical sensor)
			SendComValS(NeutralUD);
			ShowPrompt();
			break;
		case 'R':	// receiver values
			SendComText(SerRecvCh);
			SendComValU(IGas);
			SendComChar(',');
			SendComChar('R');
			SendComChar(':');
			SendComValS(IRoll);
			SendComChar(',');
			SendComChar('N');
			SendComChar(':');
			SendComValS(INick);
			SendComChar(',');
			SendComChar('Y');
			SendComChar(':');
			SendComValS(ITurn);
			SendComChar(',');
			SendComChar('5');
			SendComChar(':');
			SendComValU(IK5);
			SendComChar(',');
			SendComChar('6');
			SendComChar(':');
			SendComValU(IK6);
			SendComChar(',');
			SendComChar('7');
			SendComChar(':');
			SendComValU(IK7);
			ShowPrompt();
			break;

		case 'B':	// call bootloader
#asm
			movlw	0x1f
			movwf	PCLATH
			dw	0x2F00
#endasm
//			BootStart();	// never comes back!
		
#ifndef TESTOUT	
		case 'T':
			RE = 10;
			NE = 20;
			Rw = 30;
			Nw = 40;
			MatrixCompensate();
			ShowPrompt();
			break;
#endif

		case '?'  : // help
			SendComText(SerHelp);
			ShowPrompt();
	}
}