Exemplo n.º 1
0
int main(int argc, char** argv) 
{
	double		begin;
	double		end;
	size_t		nsym;
	size_t		nactive;
	size_t		n;
	size_t		max_succ;
	cfg_t*		cfg;
	bool		print;
	int		seed = 0;

	progname	= argv[0];

	if (argc == 7) {
		nsym	 	= atoi(argv[1]);
		n		= atoi(argv[2]);
		max_succ	= atoi(argv[3]);
		nactive	 	= atoi(argv[4]);
		print	 	= atoi(argv[6]);
	} else {
		nsym	 	= 100;
		n		= 10;
		max_succ	= 4;
		nactive	 	= 10;
		print		= 1;
	}

	printf("nsymbol   = %zu\n", nsym);
	printf("nvertex   = %zu\n", n);
	printf("max-succ  = %zu\n", max_succ);
	printf("nactive   = %zu\n", nactive);
	
	if (seed == 1)
		init_random(seed);
	else {
		printf("pid %d\n", getpid());
		init_random(getpid());
	}

	printf("generating cfg...\n");
	cfg = new_cfg(n, nsym, max_succ);
	generate_cfg(cfg, n, max_succ);

	printf("generating usedefs...\n");
	generate_usedefs(cfg, n, nsym, nactive);

	printf("liveness...\n\n");
	begin = sec();
	liveness(cfg);
	end = sec();

	printf("T = %8.4lf s\n\n", end-begin);

	if (print)
		print_sets(cfg, stdout);

	free_cfg(cfg);
	return 0;
}
Exemplo n.º 2
0
/*!
 *	@brief This function is cfg gnss   TXE interrupt mode
 *	@param : null  
 *	@return : null
 */
void ublox_cfg_in_init( void )
{
   int m = 0;
	 
   //unsigned char msgCFG_PRT[24]      = { 6, 0, 20, 0, 1, 0, 0, 0, 192, 8, 0, 0, 0, 194, 1, 0, 7, 0, 2, 0, 0, 0, 0, 0 };  //115200
   unsigned char msgCFG_PRT[24]      = { 6, 0, 20, 0, 1, 0, 0, 0, 192, 8, 0, 0, 0, 194, 1, 0, 7, 0, 3, 0, 0, 0, 0, 0 };  //115200  ubx output
  //unsigned char msgCFG_PRT[24]      = { 6, 0, 20, 0, 1, 0, 0, 0, 192, 8, 0, 0, 128, 37, 0, 0, 7, 0, 3, 0, 0, 0, 0, 0 };  //9600
   unsigned char msgCFG_MSG_0107[12] = { 6, 1, 8, 0, 1, 7, 0, 1, 0, 0, 0, 0 };	   /* msg 0x01 0x07 on uart at 1Hz */
   unsigned char msgCFG_MSG_0122[12] = { 6, 1, 8, 0, 1, 34, 0, 1, 0, 0, 0, 0 };	   /* msg 0x01 0x22 on uart at 1Hz */
   unsigned char msgCFG_MSG_0136[12] = { 6, 1, 8, 0, 1, 54, 0, 1, 0, 0, 0, 0 };	   /* msg 0x01 0x36 on uart at 1Hz */
   unsigned char msgCFG_MSG_0135[12] = { 6, 1, 8, 0, 1, 53, 0, 1, 0, 0, 0, 0 };	   /* msg 0x01 0x35 on uart at 1Hz */
   unsigned char msgCFG_MSG_0120[12] = { 6, 1, 8, 0, 1, 32, 0, 1, 0, 0, 0, 0 };	   /* msg 0x01 0x20 on uart at 1Hz */
   unsigned char msgCFG_MSG_0215[12] = { 6, 1, 8, 0, 2, 21, 0, 1, 0, 0, 0, 0 };	   /* msg 0x02 0x15 on uart at 1Hz */
// unsigned char msgCFG_MSG_0213[12] = { 6, 1, 8, 0, 1, 19, 0, 1, 0, 0, 0, 0 };	 /* msg 0x02 0x20 on uart at 1Hz */
	 
   unsigned char msgCFG_GNSS[48] = { 6, 62, 44, 0, 0, 32, 32, 5,             /* 32 channels tracking and using ,5 constellation config */
	                                   0, 8, 16, 0, 1, 0, 1, 1,   /* enable GPS; config 8~16 channels for GPS*/
		                                 1, 1,  3, 0, 0, 0, 1, 1,   /* disable SBAS; config 1~3 channels for SBAS*/
		                                 3, 8, 16, 0, 0, 0, 1, 1,   /* disable BDS; config 8~16 channels for BDS*/
		                                 5, 0,  3, 0, 1, 0, 1, 1,   /* enable QZSS; config 0~3 channels for QZSS*/
		                                 6, 8, 16, 0, 1, 0, 1, 1 }; /* enable GLONASS; config 8~16 channels for GLONASS*/

   unsigned char msgCFG_NAV[40] = {6, 36, 36, 0, 255, 255, 4, 3,                               /* 4: automotive (7: drone 2g), 2D/3D */ 
	                                 0, 0, 0, 0, 22, 57, 0, 0, 5, 0, 250, 0, 250, 0,             /* elevation mask 5 deg, PDOP mask 25, TDOP mask 25 */
	                                 100, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};	 /* pos accuracy mask 100m, clock accuracy mask 300m */
	 
																	 /*-------- turn off some NMEA messages ---------*/
   unsigned char msgGGA_Off[12] = {6, 1, 8, 0, 240, 0, 0, 0, 0, 0, 0, 0};   /* turn off GGA, 0xF0 0x00 */
   unsigned char msgGLL_Off[12] = {6, 1, 8, 0, 240, 1, 0, 0, 0, 0, 0, 0};   /* turn off GLL, 0xF0 0x01 */
 //  unsigned char msgGSA_Off[12] = {6, 1, 8, 0, 240, 2, 0, 0, 0, 0, 0, 0};   /* turn off GSA, 0xF0 0x02 */
 //  unsigned char msgGSV_Off[12] = {6, 1, 8, 0, 240, 3, 0, 0, 0, 0, 0, 0};   /* turn off GSV, 0xF0 0x03 */	 
   unsigned char msgRMC_Off[12] = {6, 1, 8, 0, 240, 4, 0, 0, 0, 0, 0, 0};   /* turn off RMC, 0xF0 0x04 */
   unsigned char msgVTG_Off[12] = {6, 1, 8, 0, 240, 5, 0, 0, 0, 0, 0, 0};   /* turn off VTG, 0xF0 0x05 */
   unsigned char msgZDA_Off[12] = {6, 1, 8, 0, 240, 8, 0, 0, 0, 0, 0, 0};   /* turn off ZDA, 0xF0 0x08 */;
	 
   /*---- set port baudrate, page 235, suggest 115200 ----*/
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_PRT, ubxCommandBuff, 24);
   ubxCfgAckStatus = 0;
   BSP_Uart3_SendBuff(m,ubxCommandBuff);

   delayMs(UBX_CFG_ACK_TIME);
   
   if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   {
      print("CfgGPps CFG_PRT ACK!");
   }
   else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   {
      print("CfgGPps CFG_PRT NAK!");
   }
   else
   {
      print("CfgGPps CFG_PRT no resp!");
   }

   
   //usart3 set baudrate  115200 according to msgCFG_PRT
   BSP_Uart3_Init(115200); 
   delayMs(UBX_CFG_ACK_TIME);

   /*------ request  0x01 0x07 at 1Hz -------------- */
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0107, ubxCommandBuff, 12);
   if(m!=0)
   {
      ubxCfgAckStatus = 0;
      BSP_Uart3_SendBuff(m,ubxCommandBuff);
      delayMs(UBX_CFG_ACK_TIME);
   
      if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
      {
         print("CfgGPps MSG_0107 ACK!");
      }
      else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
      {
         print("CfgGPps MSG_0107 NAK!");
      }
      else
      {
         print("CfgGPps MSG_0107 no resp!");
      }
   }
	 
   /**------  MSG 0x01 0x22-------------- */
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0122, ubxCommandBuff, 12);
   if(m!=0)
   {
      ubxCfgAckStatus = 0;
      BSP_Uart3_SendBuff(m,ubxCommandBuff);
      delayMs(UBX_CFG_ACK_TIME);
   
      if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
      {
         print("CfgGPps MSG_0122 ACK!");
      }
      else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
      {
        print("CfgGPps MSG_0122 NAK!");
      }
      else
      {
         print("CfgGPps MSG_0122 no resp!");
      }
   }
 
	 /**------ MSG  0x01 0x36-------------- */
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0136, ubxCommandBuff, 12);
   if(m!=0)
   {
      ubxCfgAckStatus = 0;
      BSP_Uart3_SendBuff(m,ubxCommandBuff);
      delayMs(UBX_CFG_ACK_TIME);
   
      if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
      {
         print("CfgGPps MSG_0136 ACK!");
      }
      else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
      {
         print("CfgGPps MSG_0136 NAK!");
      }
      else
   	  {
         print("CfgGPps MSG_0136 no resp!");
   	  }
   }
	 
  /**------ MSG  0x01 0x35-------------- */
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0135, ubxCommandBuff, 12);
   if(m!=0)
   {
         ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_0135 ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_0135 NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_0135 no resp!");
   	}
   }
 
	 /**------ MSG  0x01 0x20-------------- */
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0120, ubxCommandBuff, 12);
   if(m!=0)
   {
 	ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_0120 ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_0120 NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_0120 no resp!");
   	}
   }
 
	 /**------ MSG  0x02 0x15 (raw measurements)-------------- */
	 //(void)msgCFG_MSG_0215;
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_MSG_0215, ubxCommandBuff, 12);
   if(m!=0)
   {
	 ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_0215 ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_0215 NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_0215 no resp!");
   	}
   }
	 
	 	 /**------ MSG  0x02 0x13 (eph frames) not required at the current phase ------------- */
//   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
//   m = generate_cfg(msgCFG_MSG_0213, ubxCommandBuff, 12);
//	 if(m!=0)
//   {
//		 ubx_config_set(m);
//   }
	 
	 /*--------- config constellations ---------*/
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_GNSS, ubxCommandBuff, 48);
   if(m!=0)
   {
	 ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_GNSS ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_GNSS NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_GNSS no resp!");
   	}
   } 

	 
  /*--------- config GNSS Nav engine / dynamic range; ---------*/
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   m = generate_cfg(msgCFG_NAV, ubxCommandBuff, 40);
   if(m!=0)
   {
	 ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_NAV ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_NAV NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_NAV no resp!");
   	}
   } 

   /*------- disable some of NMEA to save throughput ------*/
   memset(ubxCommandBuff, 0, sizeof(ubxCommandBuff));
   
   m = generate_cfg(msgGGA_Off, ubxCommandBuff, 12);
    ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_GGA_Off ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_GGA_Off NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_GGA_Off no resp!");
   	}
   m = generate_cfg(msgGLL_Off, ubxCommandBuff, 12);
    ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_GLL_Off ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_GLL_Off NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_GLL_Off no resp!");
   	}
   m = generate_cfg(msgRMC_Off, ubxCommandBuff, 12);
    ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_RMC_Off ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_RMC_Off NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_RMC_Off no resp!");
   	}
   m = generate_cfg(msgVTG_Off, ubxCommandBuff, 12);
    ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_VTG_Off ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_VTG_Off NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_VTG_Off no resp!");
   	}
   m = generate_cfg(msgZDA_Off, ubxCommandBuff, 12);
    ubxCfgAckStatus = 0;
   	BSP_Uart3_SendBuff(m,ubxCommandBuff);
   	delayMs(UBX_CFG_ACK_TIME);
   
   	if((UBX_ID_ACKACK&ubxCfgAckStatus)==UBX_ID_ACKACK)
   	{
   		print("CfgGPps MSG_ZDA_Off ACK!");
   	}
   	else if((UBX_ID_ACKNAK&ubxCfgAckStatus)==UBX_ID_ACKNAK)
   	{
		print("CfgGPps MSG_ZDA_Off NAK!");
   	}
   	else
   	{
   		print("CfgGPps MSG_ZDA_Off no resp!");
   	}
   return;
}
Exemplo n.º 3
0
void c_optimize() {
   inst_t current = instList;
    int size=0;
    while(current->next != NULL) {
        size++;
        current=current->next;
    }
    live_range *live;
    block_array cfg;
    //ddg_t ddg;
    /* file pointer to dump output code */
    FILE *fptr = fopen(outfile, "w");

    codegen_entry(fptr);

    yywrap();
    yyparse();

    if (num_errors > 0)
        return;

    if (verbose)
        print_list(stdout, instList);

    find_function(); /* remove extra instructions needed for simulation */
    cfg = generate_cfg();
   // ddg = generate_ddg();
    live=liveness(size);
    live->dead++;
    live->dead--;
    cfg.num_of_labels++;
    cfg.num_of_labels--;
    /************************************************************************/
    /************************************************************************/
    /************************************************************************/
    /************************************************************************/
    /*    Call your implementation from here                                */

    /* Find single basic block loops and perform Iterative Modulo Scheduling */

  multiOpSetup(instList);
	
  if (flag_regalloc)
    {
      // perform register allocation
      printf("Perform register allocation.\n"); // REMOVE ME
    }

    if (flag_sched) {
        // perform scheduling      
        printf("Perform scheduling.\n"); // REMOVE ME      
    }


    /************************************************************************/
    /************************************************************************/
    /************************************************************************/
    /************************************************************************/

    print_list(fptr, instList); /* dump code to output file */

    codegen_exit(fptr);
    fclose(fptr); /* close file */
}