uint32_t pgraph_celsius_xfrm_squash_z(struct pgraph_state *state, uint32_t val) {
	if (extr(state->debug_e, 22, 1) && !extr(state->bundle_raster, 30, 1)) {
		if (extr(val, 31, 1))
			return 0;
	}
	return val;
}
uint32_t pgraph_celsius_convert_light_sx(uint32_t val) {
	if (!extr(val, 23, 8))
		return 0;
	if (extr(val, 23, 8) == 0xff) {
		if (extr(val, 9, 14))
			return 0x7ffffc00;
		return 0x7f800000;
	}
	if ((val & 0x3ffff) < 0x3fe00)
		val += 0x200;
	return val & 0xfffffc00;
}
uint32_t pgraph_celsius_xfrm_squash_w(struct pgraph_state *state, uint32_t val) {
	int exp = extr(val, 23, 8);
	if (extr(state->debug_e, 22, 1) && !extr(state->bundle_raster, 30, 1)) {
		if (exp < 0x3f || extr(val, 31, 1)) {
			return 0x1f800000;
		}
	}
	if (exp >= 0xbf)
		insrt(val, 0, 31, 0x5f800000);
	val &= 0xffffff00;
	return val;
}
Esempio n. 4
0
int code_2op_reg_mem(char *mnem,char * sreg1,char *ev)	{
	int reg1 = getval(sreg1);
	int codesize = 0;
	if(!(reg1+1)){
		return 0;if(VERBOSE)
		printf("\nInstruction Result:%d",codesize);}	
	buffer.w=1;
	buffer.s = 0;
	buffer.mod = 0;
	buffer.rm = (*(ev+1)=='B'||*(ev+1)=='b')?6:7;	
	buffer.reg =reg1;
	int xt = extr(ev);
		if (!xt){
			int tmp[2];
			encode(tmp,xt);
			buffer.dispa=tmp[0];
			buffer.dispb=tmp[1];
		}
	int t_opcode = _opcode(mnem);
	if (t_opcode==-1)
		return 0; //insert some error handling code here
	buffer.opcode = t_opcode;
	if(byte1(buffer)) {
		putc(byte1(buffer),fp);	codesize++;}
	if(byte2(buffer)) {
		putc(byte2(buffer),fp);codesize++;}
	if(buffer.rm==7)	{
		putc(buffer.dispa,fp);
		putc(buffer.dispb,fp);
		codesize+=2;
	}
	_clean();
}
Esempio n. 5
0
void QueryExecutor::ExecuteExtractParametersQuery(DatabaseQuery::ExtractionParameters &pars) {
    IPKContainer* ipk = IPKContainer::GetObject();
    assert(ipk);

    SzbExtractor extr(szbase);
    extr.SetPeriod(PeriodToProbeType(pars.pt),
                   pars.start_time,
                   szb_move_time(pars.end_time, 1, PeriodToProbeType(pars.pt), 0),
                   0);

    extr.SetNoDataString(L"NO_DATA");
    extr.SetEmpty(0);

    FILE* output = fopen((const char*) SC::S2U(*pars.file_name).c_str(), "w");
    if (output == NULL)
        return;

    std::vector<SzbExtractor::Param> params;
    for (size_t i = 0; i < pars.params->size(); i++) {
        std::wstring param = pars.params->at(i);
        std::wstring prefix = pars.prefixes->at(i);
        szb_buffer_t* buffer = szbase->GetBuffer(prefix);
        params.push_back(SzbExtractor::Param(param, prefix, buffer, SzbExtractor::TYPE_AVERAGE));
    }

    extr.SetParams(params);
    extr.ExtractToCSV(output, L";");
    fclose(output);
}
uint32_t pgraph_celsius_xfrm_squash_xy(uint32_t val) {
	int exp = extr(val, 23, 8);
	if (exp <= 0x7a)
		return 0;
	if (exp < 0x92)
		insrt(val, 0, 0x92 - exp, 0);
	return val;
}
Esempio n. 7
0
int mmrd (uint32_t addr, uint32_t u1)
{
    extr(addr, addr, 2, 25);
    addr = addr << 2;
    mmio_write(FUC_MMIO_CTRL, addr  | (u1 & 1) | 0x80000000);
    while (mmio_read(FUC_MMIO_CTRL) & 0x80000000);
    while (!(mmio_read(FUC_DONE) & 0x40));
    return mmio_read(FUC_MMIO_RDVAL);
}
Esempio n. 8
0
void mmwr(uint32_t addr, int val, uint32_t u1, uint32_t u2)
{
    extr(addr, addr, 2, 25);
    mmio_write(FUC_MMIO_WRVAL, val);
    mmio_write(FUC_MMIO_CTRL, (addr << 2) |
	    (u1 & 1) | 0xc0000000 | (!!u2) << 29);
    while (mmio_read(FUC_MMIO_CTRL) & 0x80000000);
    if (u2)
	while (!(mmio_read(FUC_DONE)&0x80));
}
uint8_t pgraph_celsius_xfrm_f2b(uint32_t val) {
	if (extr(val, 31, 1))
		return 0;
	int exp = extr(val, 23, 8);
	if (exp >= 0x7f)
		return 0xff;
	if (exp < 0x76)
		return 0;
	uint32_t fr = extr(val, 10, 13);
	fr |= 1 << 13;
	fr <<= exp - 0x74;
	fr *= 0xff;
	fr >>= 23;
	fr++;
	fr >>= 1;
	if (fr > 0xff)
		fr = 0xff;
	return fr;
}
Esempio n. 10
0
PreprocessingPassResult ExtRewPre::applyInternal(
    AssertionPipeline* assertionsToPreprocess)
{
  theory::quantifiers::ExtendedRewriter extr(options::extRewPrepAgg());
  for (unsigned i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
  {
    assertionsToPreprocess->replace(
        i, extr.extendedRewrite((*assertionsToPreprocess)[i]));
  }
  return PreprocessingPassResult::NO_CONFLICT;
}
Esempio n. 11
0
int code_1op_mem(char *mnem,char *ev) {
	int codesize=0;	
	buffer.mod=00;
	buffer.rm = (*(ev+1)=='B'||*(ev+1)=='b')?6:7;	
	
	if(!strcmp(mnem,"POP")||!(strcmp(mnem,"pop"))){
		buffer.reg = 0;
		buffer.opc = 0xaf;
		int xt = extr(ev);
		if (!xt){
			int tmp[2];
			encode(tmp,xt);
			buffer.dispa=tmp[0];
			buffer.dispb=tmp[1];
		}}
	if(!strcmp(mnem,"PUSH")||!(strcmp(mnem,"push"))){
		buffer.reg = 6;
		buffer.opc = 0xff;
			int xt = extr(ev);
		if (!xt){
			int tmp[2];
			encode(tmp,xt);
			buffer.dispa=tmp[0];
			buffer.dispb=tmp[1];
		}
	}
	if(buffer.opc){ 
		putc(byte1(buffer),fp);codesize++;}
	if(byte2(buffer)) {
		putc(byte2(buffer),fp);codesize++;}
	if(buffer.rm==7)	{
		putc(buffer.dispa,fp);
		putc(buffer.dispb,fp);
		codesize++;
	}
	_clean();

	if(VERBOSE)
		printf("\nInstruction Result:%d",codesize);
	return codesize;
}
Esempio n. 12
0
int main (int argc, char * argv [])
  {
    int i = 0;
    int fd;
    fd = open (argv [1], O_RDONLY);
    if (fd < 0)
      {
        printf ("can't open file\n");
        exit (1);
      }
    for (;;)
      {
        ssize_t sz;
// 72 bits at a time; 2 dps8m words == 9 bytes
        uint8_t bytes [9];
        memset (bytes, 0, 9);
        sz = read (fd, bytes, 9);
        if (sz == 0)
          break;
        //if (sz != n) short read?
        uint64_t w1 = extr (bytes, 0, 36);
        uint64_t w2 = extr (bytes, 36, 36);
        // int text [8]; // 8 9-bit bytes in 2 words
        printf ("%08o   %012lo   %012lo   \"", i, w1, w2);
        i += 2;
        int j;

        static int byteorder [8] = { 3, 2, 1, 0, 7, 6, 5, 4 };
        for (j = 0; j < 8; j ++)
          {
            uint64_t c = extr (bytes, byteorder [j] * 9, 9);
            if (isprint (c))
              printf ("%c", (char) c);
            else
              printf ("\\%03lo", c);
          }
        printf ("\n");
      }
    return 0;
  }
Esempio n. 13
0
static int test_scan_access(struct hwtest_ctx *ctx) {
	uint32_t val = nva_rd32(ctx->cnum, 0x4006a4);
	int i;
	for (i = 0; i < 1000; i++) {
		uint32_t nv = jrand48(ctx->rand48);
		uint32_t next = val;
		nva_wr32(ctx->cnum, 0x4006a4, nv);
		if (nv & 1 << 24)
			insrt(next, 0, 1, extr(nv, 0, 1));
		if (nv & 1 << 25)
			insrt(next, 4, 1, extr(nv, 4, 1));
		if (nv & 1 << 26)
			insrt(next, 8, 1, extr(nv, 8, 1));
		if (nv & 1 << 27)
			insrt(next, 12, 5, extr(nv, 12, 5));
		uint32_t real = nva_rd32(ctx->cnum, 0x4006a4);
		if (real != next) {
			printf("ACCESS mismatch: prev %08x write %08x expected %08x real %08x\n", val, nv, next, real);
			return HWTEST_RES_FAIL;
		}
		val = next;
	}
	return HWTEST_RES_PASS;
}
Esempio n. 14
0
void work(void){

    uint32_t xdata;
    uint32_t cmd,data;
    mmio_write(FUC_NEWSCRATCH_SET2, 8);
    if (q2get != q2put) {
	struct qe *ptr = &q2[q2get & 7];
	cmd = ptr->cmd & ~0x7800;
	data = ptr->data;
	if (++q2get == 0x10)
	    q2get = 0;
    } else if (qget != qput) {
	struct qe *ptr = &queue[qget & 7];
	cmd = ptr->cmd & ~0x7800;
	data = ptr->data;
	if (++qget == 0x10)
	    qget = 0;
    } else {
	mmio_write(FUC_NEWSCRATCH_CLEAR2, 8);
	return;
    }

    in_temp_cmd = cmd;
    in_temp_data = data;


    set4160();
    waitdone_12();


    mmio_write(0xa24, 0);
    mmio_write(FUC_MEM_CHAN, 0); /* type=nv50_channnel????? */
    mmio_write(FUC_MEM_CMD, 7);
    while (mmio_read(FUC_MEM_CMD)&0x1f);

    setxferbase(10);
    extr(xdata,0x08020495,28,29);
    // base, 
    //xfer(0x80020494<<4,0,1,0,xdata,1,1,2);
    xfer(0x20495<<4,0,5,&temp[0],0,2,1,2);

    clear4160();
    mmio_write(0x808, 0xb0000000 | temp[0]);
    mmio_write(0x804, 0xb0000000 | temp[1]);
    mmio_write(0x80c, 0x12345678);


}
Esempio n. 15
0
  void FeatureLocation ::
  applyTransform(const ntk::AffineTransform& transform)
  {
    cv::Point2f extr (p_image.x+cos(orientation)*scale,
                      p_image.y+sin(orientation)*scale);

    transform.transformPoint(extr.x, extr.y);
    transform.transformPoint(p_image.x, p_image.y);

    double dx = (extr.x-p_image.x);
    double dy = (extr.y-p_image.y);
    double tanx = dy/dx;
    if (dx < 0) tanx *= -1;
    orientation = atan(tanx);
    if (dx < 0) orientation = M_PI - orientation;
    scale = sqrt(dx*dx+dy*dy);
  }
Esempio n. 16
0
void study_il(jvec &EP,jvec &MD,jvec &Q2,jvec &fP,jvec &fM,jvec &f0,jvec &fT,int il_sea,int il)
{
  int ic_base=8;
  jvec EP_ic[3],MD_ic[3],Q2_ic[3],fP_ic[3],fM_ic[3],f0_ic[3],fT_ic[3];
  for(int dic=2;dic>=0;dic--)
    {
      int ic=ic_base+dic;
      Q2_ic[dic]=fP_ic[dic]=f0_ic[dic]=fT_ic[dic]=jvec(nth,njack);
      extr(EP_ic[dic],MD_ic[dic],Q2_ic[dic],fP_ic[dic],fM_ic[dic],f0_ic[dic],fT_ic[dic],il_sea,il,ic);
    }
  
  EP=parab_spline(EP_ic,xc,xc_phys,combine("plots/EP_spline_%d.xmg",il).c_str());
  MD=parab_spline(MD_ic,xc,xc_phys,combine("plots/MD_spline_%d.xmg",il).c_str());
  Q2=parab_spline(Q2_ic,xc,xc_phys,combine("plots/Q2_spline_%d.xmg",il).c_str());
  fP=parab_spline(fP_ic,xc,xc_phys,combine("plots/fP_spline_%d.xmg",il).c_str());
  fM=parab_spline(fM_ic,xc,xc_phys,combine("plots/fM_spline_%d.xmg",il).c_str());
  f0=parab_spline(f0_ic,xc,xc_phys,combine("plots/f0_spline_%d.xmg",il).c_str());
  fT=parab_spline(fT_ic,xc,xc_phys,combine("plots/fT_spline_%d.xmg",il).c_str());
  fP[0]*=0;
  fT[0]*=0;
  
  ofstream out_fP(combine("plots/fP_%d.xmg",il).c_str());
  ofstream out_fM(combine("plots/fM_%d.xmg",il).c_str());
  ofstream out_f0(combine("plots/f0_%d.xmg",il).c_str());
  ofstream out_fT(combine("plots/fT_%d.xmg",il).c_str());
  out_fP<<"@type xydy"<<endl;
  out_fM<<"@type xydy"<<endl;
  out_f0<<"@type xydy"<<endl;
  out_fT<<"@type xydy"<<endl;
  for(int ith=0;ith<nth;ith++)
    {
      if(ith) out_fP<<Q2[ith].med()<<" "<<fP[ith]<<endl;
      if(ith) out_fM<<Q2[ith].med()<<" "<<fM[ith]<<endl;
      out_f0<<Q2[ith].med()<<" "<<f0[ith]<<endl;
      if(ith) out_fT<<Q2[ith].med()<<" "<<fT[ith]<<endl;
    }
}
Esempio n. 17
0
uint32_t pgraph_celsius_xfrm_mul(uint32_t a, uint32_t b) {
	bool sign = extr(a, 31, 1) ^ extr(b, 31, 1);
	int expa = extr(a, 23, 8);
	int expb = extr(b, 23, 8);
	uint32_t fra = extr(a, 0, 23) | 1 << 23;
	uint32_t frb = extr(b, 0, 23) | 1 << 23;
	if ((expa == 0xff && fra > 0x800000) || (expb == 0xff && frb > 0x800000))
		return 0x7fffffff;
	if (!expa || !expb)
		return 0;
	if (expa == 0xff || expb == 0xff)
		return 0x7f800000;
	uint32_t fr;
	int exp;
	exp = expa + expb - 0x7f;
	uint64_t frx = (uint64_t)fra * frb;
	frx >>= 23;
	if (frx > 0xffffff) {
		frx >>= 1;
		exp++;
	}
Esempio n. 18
0
int main (int argc, char * argv [])
{
    int fd;
    int32_t blksiz;
    int32_t blksiz2;
    //fd = open ("20184.tap", O_RDONLY);
    fd = open (argv [1], O_RDONLY);
    if (fd < 0)
    {
        printf ("can't open tape\n");
        exit (1);
    }
    int blkno = 0;
    for (;;)
    {
        ssize_t sz;
        sz = read (fd, & blksiz, sizeof (blksiz));
        if (sz == 0)
            break;
        if (sz != sizeof (blksiz))
        {
            printf ("can't read blksiz\n");
            exit (1);
        }
        printf ("blksiz %d\n", blksiz);

        if (! blksiz)
        {
            printf ("tapemark\n");
        }
        else
        {
// 72 bits at a time; 2 dps8m words == 9 bytes
            int i;
            uint8_t bytes [9];
            for (i = 0; i < blksiz; i += 9)
            {
                int n = 9;
                if (i + 9 > blksiz)
                    n = blksiz - i;
                memset (bytes, 0, 9);
                sz = read (fd, bytes, n);
//{ int jj; for (jj = 0; jj < 72; jj ++) { uint64_t k = extr (bytes, jj, 1); printf ("%ld", k); } printf ("\n"); }
//printf ("%02X %02X %02X %02X %02X\n", bytes [0], bytes [1], bytes [2], bytes [3], bytes [4]);
                if (sz == 0)
                {
                    printf ("eof whilst skipping byte\n");
                    exit (1);
                }
                if (sz != n)
                {
                    printf ("can't skip bytes\n");
                    exit (1);
                }
                uint64_t w1 = extr (bytes, 0, 36);
//printf ("%012lo\n", w1);
                uint64_t w2 = extr (bytes, 36, 36);
                // int text [8]; // 8 9-bit bytes in 2 words
                printf ("%04d:%04o   %012lo   %012lo   \"", blkno, i * 2 / 9, w1, w2);
                int j;
//{printf ("\n<<%012lo>>\n", (* (uint64_t *) bytes) & 0777777777777); }

                static int byteorder [8] = { 3, 2, 1, 0, 7, 6, 5, 4 };
                for (j = 0; j < 8; j ++)
                {
                    uint64_t c = extr (bytes, byteorder [j] * 9, 9);
                    if (isprint (c))
                        printf ("%c", (char) c);
                    else
                        printf ("\\%03lo", c);
                }
                printf ("\n");
            }
            sz = read (fd, & blksiz2, sizeof (blksiz2));
            if (sz != sizeof (blksiz2))
            {
                printf ("can't read blksiz2\n");
                exit (1);
            }
            if (blksiz != blksiz2)
            {
                printf ("blksiz != blksiz2\n");
                exit (1);
            }
            blkno ++;
        }
    }
    return 0;
}
Esempio n. 19
0
 inline void syncFrom(const Obj& mObj) override
 {
     extr(mObj, name, value);
 }
Esempio n. 20
0
matf GetExtrinsicsFromEssential(const matf & essMat_, const TrackedPoint & one_point,
				bool correct_essMat, int c) {
  matf essMat;
  if (correct_essMat) {
    SVD svd2(essMat_);
    matf D = matf(3,3,0.0f);
    D(0,0) = D(1,1) = (svd2.w.at<float>(0,0) + svd2.w.at<float>(1,0)) * 0.5f;
    essMat = svd2.u * D * svd2.vt;
  } else  {
    matf essMat = essMat_;
  }
  SVD svd(essMat);
  //assert(epsEqual(D(0,0) / D(1,0), 1.0, 0.1) && epsEqual(D(2,0), 0.0f));
  matf W(3,3,0.0f); //TODO do not recreate at each call
  W(0,1) = -1.0f;
  W(1,0) = W(2,2) = 1.0f;
  
  matf extr(3,4);
  matf tmp;
  //case 1
  tmp = svd.u*W*svd.vt;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      extr(i,j) = tmp(i,j);
  for (int i = 0; i < 3; ++i)
    extr(i, 3) = svd.u.at<float>(i, 2);
  //cout << extr << endl;
  if ((c == 1) || ((c == -1) && IsExtrinsicsPossible(extr, one_point))) {
    //cout << "case 1" << endl;
    return extr;
  }
  //case 2
  for (int i = 0; i < 3; ++i)
    extr(i, 3) = -svd.u.at<float>(i, 2);
  //cout << extr << endl;
  if ((c == 2) || ((c == -1) && IsExtrinsicsPossible(extr, one_point))) {
    //cout << "case 2" << endl;
    return extr;
  }
  //case 3
  tmp = svd.u*W.t()*svd.vt;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      extr(i,j) = tmp(i,j);
  //cout << extr << endl;
  if ((c == 3) || ((c == -1) && IsExtrinsicsPossible(extr, one_point))) {
    //cout << "case 3" << endl;
    return extr;
  }
  //case 4
  for (int i = 0; i < 3; ++i)
    extr(i, 3) = svd.u.at<float>(i, 2);
  //cout << extr << endl;
  if ((c == 4) || ((c == -1) && IsExtrinsicsPossible(extr, one_point))) {
    //cout << "case 4" << endl;
    return extr;
  }
  //assert(false); //this should not happen. If it does, sth is wrong
  // (the point might be the on the principal plane, or there is a bug)
  return matf(0,0); // remove warning
}
Esempio n. 21
0
uint32_t pgraph_celsius_xfrm_squash(uint32_t val) {
	if (extr(val, 24, 7) == 0x7f)
		val &= 0xff000000;
	return val;
}