コード例 #1
0
ファイル: lininteg.cpp プロジェクト: lyq105/mfem
void VectorBoundaryFluxLFIntegrator::AssembleRHSElementVect(
    const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
{
    int dim = el.GetDim()+1;
    int dof = el.GetDof();

    shape.SetSize (dof);
    nor.SetSize (dim);
    elvect.SetSize (dim*dof);

    const IntegrationRule *ir = IntRule;
    if (ir == NULL)
        ir = &IntRules.Get(el.GetGeomType(), el.GetOrder() + 1);

    elvect = 0.0;
    for (int i = 0; i < ir->GetNPoints(); i++)
    {
        const IntegrationPoint &ip = ir->IntPoint(i);
        Tr.SetIntPoint (&ip);
        CalcOrtho(Tr.Jacobian(), nor);
        el.CalcShape (ip, shape);
        nor *= Sign * ip.weight * F -> Eval (Tr, ip);
        for (int j = 0; j < dof; j++)
            for (int k = 0; k < dim; k++)
                elvect(dof*k+j) += nor(k) * shape(j);
    }
}
コード例 #2
0
ファイル: lininteg.cpp プロジェクト: lyq105/mfem
void BoundaryNormalLFIntegrator::AssembleRHSElementVect(
    const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
{
    int dim = el.GetDim()+1;
    int dof = el.GetDof();
    Vector nor(dim), Qvec;

    shape.SetSize(dof);
    elvect.SetSize(dof);
    elvect = 0.0;

    const IntegrationRule *ir = IntRule;
    if (ir == NULL)
    {
        int intorder = oa * el.GetOrder() + ob;  // <----------
        ir = &IntRules.Get(el.GetGeomType(), intorder);
    }

    for (int i = 0; i < ir->GetNPoints(); i++)
    {
        const IntegrationPoint &ip = ir->IntPoint(i);

        Tr.SetIntPoint(&ip);
        CalcOrtho(Tr.Jacobian(), nor);
        Q.Eval(Qvec, Tr, ip);

        el.CalcShape(ip, shape);

        elvect.Add(ip.weight*(Qvec*nor), shape);
    }
}
コード例 #3
0
ファイル: lininteg.cpp プロジェクト: lyq105/mfem
void BoundaryFlowIntegrator::AssembleRHSElementVect(
    const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect)
{
    int dim, ndof, order;
    double un, w, vu_data[3], nor_data[3];

    dim  = el.GetDim();
    ndof = el.GetDof();
    Vector vu(vu_data, dim), nor(nor_data, dim);

    const IntegrationRule *ir = IntRule;
    if (ir == NULL)
    {
        // Assuming order(u)==order(mesh)
        order = Tr.Elem1->OrderW() + 2*el.GetOrder();
        if (el.Space() == FunctionSpace::Pk)
            order++;
        ir = &IntRules.Get(Tr.FaceGeom, order);
    }

    shape.SetSize(ndof);
    elvect.SetSize(ndof);
    elvect = 0.0;

    for (int p = 0; p < ir->GetNPoints(); p++)
    {
        const IntegrationPoint &ip = ir->IntPoint(p);
        IntegrationPoint eip;
        Tr.Loc1.Transform(ip, eip);
        el.CalcShape(eip, shape);

        Tr.Face->SetIntPoint(&ip);

        u->Eval(vu, *Tr.Elem1, eip);

        if (dim == 1)
            nor(0) = 2*eip.x - 1.0;
        else
            CalcOrtho(Tr.Face->Jacobian(), nor);

        un = vu * nor;
        w = 0.5*alpha*un - beta*fabs(un);
        w *= ip.weight*f->Eval(*Tr.Elem1, eip);
        elvect.Add(w, shape);
    }
}
コード例 #4
0
CollOfVector EquelleRuntimeCPU::normal(const CollOfFace& faces) const
{
    const int n = faces.size();
    const int dim = grid_.dimensions;
    Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor> nor(n, dim);
    for (int i = 0; i < n; ++i) {
        const double* fn = grid_.face_normals + dim * faces[i].index;
        for (int d = 0; d < dim; ++d) {
            nor(i, d) = fn[d];
        }
    }
    // Since the UnstructuredGrid uses the unorthodox convention that face
    // normals are scaled with the face areas, we must renormalize them.
    nor.colwise() /= nor.matrix().rowwise().norm().array();
    CollOfVector normals(dim);
    for (int d = 0; d < dim; ++d) {
        normals.col(d) = CollOfScalar(nor.col(d));
    }
    return normals;
}
コード例 #5
0
ファイル: segmentation.cpp プロジェクト: ToMadoRe/v4r
void Segmenter::calculateNormals()
{
  // calcuate normals
  normals.reset(new pcl::PointCloud<pcl::Normal>);
  v4r::ZAdaptiveNormals<pcl::PointXYZRGB>::Parameter param;
  param.adaptive = true;
  v4r::ZAdaptiveNormals<pcl::PointXYZRGB> nor(param);
  nor.setInputCloud(pcl_cloud);
  nor.compute();
  nor.getNormals(normals);
}
コード例 #6
0
 void
 SegmenterLight::computeNormals (pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud_in,
                            pcl::PointCloud<pcl::Normal>::Ptr &normals_out)
 {
   normals_out.reset (new pcl::PointCloud<pcl::Normal>);
   surface::ZAdaptiveNormals::Parameter za_param;
   za_param.adaptive = true;
   surface::ZAdaptiveNormals nor (za_param);
   nor.setInputCloud (cloud_in);
   nor.compute ();
   nor.getNormals (normals_out);
 }
コード例 #7
0
ファイル: gen_data_sample.cpp プロジェクト: teamurko/Shad
int main(int argc, char** argv)
{
    if (argc != 2) {
        printUsage(argv[0]);
        return 1;
    }

    boost::mt19937 rng;
    boost::normal_distribution<> nd(0.0, 1.0);
    boost::variate_generator<boost::mt19937&,
          boost::normal_distribution<> > nor(rng, nd);

    const size_t dimSize = 2;
    const size_t numElements = 300000;
    const size_t numClusters = 3;
    std::vector<Point> means(numClusters);
    means[0] = Point(dimSize, 1.0);
    means[1] = Point(dimSize);
    means[2] = Point(dimSize);
    means[2][0] = -2;
    means[2][1] = 2;
    std::vector<double> deviations;
    deviations.push_back(2.0);
    deviations.push_back(3.0);
    deviations.push_back(4.0);

    std::cout << numElements << " " << numClusters << " "
              << dimSize << std::endl;

    for (size_t i = 0; i < numElements; ++i) {
        int r = rand() % 3;
        Point point(dimSize);
        for (size_t j = 0; j < dimSize; ++j) {
            point[j] = means[r][j] + nor() * deviations[r];
        }
        print(point);
    }

    return 0;
}
コード例 #8
0
ファイル: ALU.c プロジェクト: joaocarlos/uRISC
void execALU(){
	switch(controle_alu.op_code){
		case  1: add();      break;
		case  2: addinc();   break;
		case  3: and();      break;
		case  4: andnota();  break;
		case  5: asl();      break;
		case  6: asr();      break;
		case  7: deca();     break;
		case  8: inca();     break;
		case  9: j();        break;
		case 10: jal(); 	 break;
		case 11: jf(); 	  	 break;
		case 12: jr(); 		 break;
		case 13: jt(); 		 break;
		case 14: lch(); 	 break;
		case 15: lcl(); 	 break;
		case 16: load();	 break;
		case 17: loadlit();	 break;
		case 18: lsl();		 break;
		case 19: lsr();		 break;
		case 20: nand();	 break;
		case 21: nor();		 break;
		case 22: ones();	 break;
		case 23: or();		 break;
		case 24: ornotb();	 break;
		case 25: passa();	 break;
		case 26: passnota(); break;
		case 27: store();	 break;
		case 28: sub();		 break;
		case 29: subdec();	 break;
		case 30: xnor();	 break;
		case 31: xor();		 break;
		case 32: zeros();	 break;
	}
}
コード例 #9
0
void simulate_MainWindow::simulate()
{
    currInstr=instrList[PC/4];
    currBin=binList[PC/4];

    vector<string> result;
    string temp=currInstr.toStdString();
    string_split(temp,result);

    coutString="";
    RD=RS=RT=immediate=address=0;
    v0=v1=v2=v3="None";
    v0=result[0];
    v1=result[1];
    printf("v0=%s\nv1=%s\n",v0.c_str(),v1.c_str());
    if(v0=="jr"||v0=="j"||v0=="jal")  // 2 parametes
    {
        if(v0=="jr")
        {
            jr();
        }
        else if(v0=="j")
            j();
        else if(v0=="jal")
            jal();
    }
    else if(v0=="lui")    // 3 parameters
    {
        v2=result[2];
        lui();
    }
    else                 // 4 parameters
    {
        v2=result[2];
        v3=result[3];
        if(v0=="add")
            add();
        else if(v0=="addu")
            addu();
        else if(v0=="sub")
            sub();
        else if(v0=="subu")
            subu();
        else if(v0=="and")
            and_funct();
        else if(v0=="or")
            or_funct();
        else if(v0=="xor")
            xor_funct();
        else if(v0=="nor")
            nor();
        else if(v0=="slt")
            slt();
        else if(v0=="sltu")
            sltu();
        else if(v0=="sll")
            sll();
        else if(v0=="srl")
            srl();
        else if(v0=="sllv")
            sllv();
        else if(v0=="srlv")
            srlv();
        else if(v0=="srav")
            srav();
        else if(v0=="addi")
            addi();
        else if(v0=="addiu")
            addiu();
        else if(v0=="andi")
            andi();
        else if(v0=="ori")
            ori();
        else if(v0=="xori")
            xori();
        else if(v0=="sw")
            sw();
        else if(v0=="lw")
            lw();
        else if(v0=="beq")
            beq();
        else if(v0=="bne")
            bne();
        else if(v0=="slti")
            slti();
        else if(v0=="sltiu")
            sltiu();
    }
    display_all();
}
コード例 #10
0
ファイル: lininteg.cpp プロジェクト: lyq105/mfem
void DGDirichletLFIntegrator::AssembleRHSElementVect(
    const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect)
{
    int dim, ndof;
    bool kappa_is_nonzero = (kappa != 0.);
    double w;

    dim = el.GetDim();
    ndof = el.GetDof();

    nor.SetSize(dim);
    nh.SetSize(dim);
    ni.SetSize(dim);
    adjJ.SetSize(dim);
    if (MQ)
        mq.SetSize(dim);

    shape.SetSize(ndof);
    dshape.SetSize(ndof, dim);
    dshape_dn.SetSize(ndof);

    elvect.SetSize(ndof);
    elvect = 0.0;

    const IntegrationRule *ir = IntRule;
    if (ir == NULL)
    {
        // a simple choice for the integration order; is this OK?
        int order = 2*el.GetOrder();
        ir = &IntRules.Get(Tr.FaceGeom, order);
    }

    for (int p = 0; p < ir->GetNPoints(); p++)
    {
        const IntegrationPoint &ip = ir->IntPoint(p);
        IntegrationPoint eip;

        Tr.Loc1.Transform(ip, eip);
        Tr.Face->SetIntPoint(&ip);
        if (dim == 1)
            nor(0) = 2*eip.x - 1.0;
        else
            CalcOrtho(Tr.Face->Jacobian(), nor);

        el.CalcShape(eip, shape);
        el.CalcDShape(eip, dshape);
        Tr.Elem1->SetIntPoint(&eip);
        // compute uD through the face transformation
        w = ip.weight * uD->Eval(*Tr.Face, ip) / Tr.Elem1->Weight();
        if (!MQ)
        {
            if (Q)
                w *= Q->Eval(*Tr.Elem1, eip);
            ni.Set(w, nor);
        }
        else
        {
            nh.Set(w, nor);
            MQ->Eval(mq, *Tr.Elem1, eip);
            mq.MultTranspose(nh, ni);
        }
        CalcAdjugate(Tr.Elem1->Jacobian(), adjJ);
        adjJ.Mult(ni, nh);

        dshape.Mult(nh, dshape_dn);
        elvect.Add(sigma, dshape_dn);

        if (kappa_is_nonzero)
            elvect.Add(kappa*(ni*nor), shape);
    }
}
コード例 #11
0
ファイル: ALU.cpp プロジェクト: jamesh1999/Programming
//Perform the operation given by the CPU
void ALU::operation(int code, Register a, Register b)
{
	//Reset all flags that aren't required
	m_flags[1] = 0;
	m_flags[2] = 0;
	m_flags[3] = 0;

	//Check if unary operation
	if(!(code==0||code==1||code==4||code==9||code==13||code==16||code==17||code==18||code==19||code==20))
	{
		//Compare a and b if possible and set flags
		if(a.getValue()>b.getValue())
		{
			m_flags[1] = 1;
		}
		else if(a.getValue()==b.getValue())
		{
			m_flags[2] = 1;
		}
	}

	//Perform operation based on code (sets carry flag to 0 if it isn't set in the operation)
	if(code==0)
	{
		zero(a);
		m_flags[0] = 0;
	}
	else if(code==1)
	{
		one(a);
		m_flags[0] = 0;
	}
	else if(code==2)
	{
		add(a,b);
	}
	else if(code==3)
	{
		addc(a,b);
	}
	else if(code==4)
	{
		inc(a);
	}
	else if(code==5)
	{
		sub(a,b);
	}
	else if(code==6)
	{
		subc(a,b);
	}
	else if(code==7)
	{
		rsub(a,b);
	}
	else if(code==8)
	{
		rsubc(a,b);
	}
	else if(code==9)
	{
		dec(a);
	}
	else if(code==10)
	{
		mul(a,b);
	}
	else if(code==11)
	{
		random(a);
		m_flags[0] = 0;
	}
	else if(code==16)
	{
		shl(a);
	}
	else if(code==17)
	{
		shlc(a);
	}
	else if(code==18)
	{
		shr(a);
	}
	else if(code==19)
	{
		shrc(a);
	}
	else if(code==20)
	{
		not(a);
		m_flags[0] = 0;
	}
	else if(code==21)
	{
		and(a,b);
		m_flags[0] = 0;
	}
	else if(code==22)
	{
		nand(a,b);
		m_flags[0] = 0;
	}
	else if(code==23)
	{
		or(a,b);
		m_flags[0] = 0;
	}
	else if(code==24)
	{
		nor(a,b);
		m_flags[0] = 0;
	}
	else if(code==25)
	{
		xor(a,b);
		m_flags[0] = 0;
	}
	else if(code==26)
	{
		xnor(a,b);
		m_flags[0] = 0;
	}
	else if(code==27)
	{
		bclr(a,b);
		m_flags[0] = 0;
	}
	else if(code==31)
	{
		m_flags[0] = 0;
	}

	//Check if output is 0 and set flag accordingly
	if(a.getValue())
	{
		m_flags[3]=1;
	}
}
コード例 #12
0
  std::vector<pcl::PointIndices>
  SegmenterLight::processPointCloudV (pcl::PointCloud<pcl::PointXYZRGB>::Ptr &pcl_cloud)
  {
    surface::View view;
    view.width = pcl_cloud->width;
    view.height = pcl_cloud->height;
    
    pcl::PointCloud<pcl::PointXYZRGBL>::Ptr result (new pcl::PointCloud<pcl::PointXYZRGBL>);
    pcl::copyPointCloud (*pcl_cloud, *result);

    // calcuate normals
    view.normals.reset (new pcl::PointCloud<pcl::Normal>);
    surface::ZAdaptiveNormals::Parameter za_param;
    za_param.adaptive = true;
    surface::ZAdaptiveNormals nor (za_param);
    nor.setInputCloud (pcl_cloud);
    nor.compute ();
    nor.getNormals (view.normals);

    // adaptive clustering
    surface::ClusterNormalsToPlanes::Parameter param;
    param.adaptive = true;
    if(detail == 1) {
      param.epsilon_c = 0.58;
      param.omega_c = -0.002;
    } else if (detail == 2) {
      param.epsilon_c = 0.62;
      param.omega_c = 0.0;
    } 
    surface::ClusterNormalsToPlanes clusterNormals (param);
    clusterNormals.setInputCloud (pcl_cloud);
    clusterNormals.setView (&view);
    clusterNormals.setPixelCheck (true, 5);
    clusterNormals.compute ();

    // model abstraction
    if(!fast) {
      pcl::on_nurbs::SequentialFitter::Parameter nurbsParams;
      nurbsParams.order = 3;
      nurbsParams.refinement = 0;
      nurbsParams.iterationsQuad = 0;
      nurbsParams.iterationsBoundary = 0;
      nurbsParams.iterationsAdjust = 0;
      nurbsParams.iterationsInterior = 3;
      nurbsParams.forceBoundary = 100.0;
      nurbsParams.forceBoundaryInside = 300.0;
      nurbsParams.forceInterior = 1.0;
      nurbsParams.stiffnessBoundary = 0.1;
      nurbsParams.stiffnessInterior = 0.1;
      nurbsParams.resolution = 16;
      surface::SurfaceModeling::Parameter sfmParams;
      sfmParams.nurbsParams = nurbsParams;
      sfmParams.sigmaError = 0.003;
      sfmParams.kappa1 = 0.008;
      sfmParams.kappa2 = 1.0;
      sfmParams.planePointsFixation = 8000;
      sfmParams.z_max = 0.01;
      surface::SurfaceModeling surfModeling (sfmParams);
      Eigen::Matrix4d pose = Eigen::Matrix4d::Identity ();
      surfModeling.setIntrinsic (525., 525., 320., 240.);
      surfModeling.setExtrinsic (pose);
      surfModeling.setInputCloud (pcl_cloud);
      surfModeling.setView (&view);
      surfModeling.compute ();
    }

    // contour detector
    surface::ContourDetector contourDet;
    contourDet.setInputCloud(pcl_cloud);
    contourDet.setView(&view);
    contourDet.computeContours();
    
    // relations
    surface::StructuralRelationsLight stRel;
    stRel.setInputCloud(pcl_cloud);
    stRel.setView(&view);
    stRel.computeRelations();
 
    // init svm model
    std::string svmStructuralModel;
    std::string svmStructuralScaling;
    if(!fast) {
      svmStructuralModel = "PP-Trainingsset.txt.scaled.model";
      svmStructuralScaling = "param.txt";
    } else {
      svmStructuralModel = "PP-Trainingsset.txt.scaled.model.fast";
      svmStructuralScaling = "param.txt.fast";
    }
    
    // svm classification
    svm::SVMPredictorSingle svm_structural(model_path, svmStructuralModel);
    svm_structural.setScaling(true, model_path, svmStructuralScaling);
    svm_structural.classify(&view, 1);
    
    // graph cut
    gc::GraphCut graphCut;
    #ifdef DEBUG
      graphCut.printResults(true);
    #endif
    if(graphCut.init(&view))
      graphCut.process();

    std::vector<pcl::PointIndices> results;
    results.resize (view.graphCutGroups.size ());
    for (unsigned i = 0; i < view.graphCutGroups.size (); i++)
      for (unsigned j = 0; j < view.graphCutGroups[i].size (); j++)
        for (unsigned k = 0; k < view.surfaces[view.graphCutGroups[i][j]]->indices.size (); k++)
          results[i].indices.push_back(view.surfaces[view.graphCutGroups[i][j]]->indices[k]);
    return results;
  }
コード例 #13
0
ファイル: Poly3D.cpp プロジェクト: Chang-Liu-0520/nodal-dg
//---------------------------------------------------------
void Poly3D::SortPoints(const DVec& cent)
//---------------------------------------------------------
{
  // Sort the points by angle from cent which is
  // a point in the plane of the polygon.  This
  // is done in a counter-clockwise direction.

  // If less than 2 points, no need to sort
  if (m_N < 2) {
    return;
  }
  
  // create local cartesian axis
  DVec ref1,ref2,nor,axis1,axis2,vI,vJ,tmp;

  // wrap DM with DMat for utility routines
  int Nr=m_xyz.num_rows(), Nc=m_xyz.num_cols();
  DMat t_xyz; t_xyz.borrow(Nr, Nc, m_xyz.data());
  
  t_xyz.get_col(1) - cent;   ref1 /= ref1.norm(); 


  // get two lines in the plane
  ref1 = t_xyz.get_col(1) - cent;   ref1 /= ref1.norm(); 
  ref2 = t_xyz.get_col(2) - cent;   ref2 /= ref2.norm();

  // normal to the plane (norm = ref1 X ref2)
  nor(1) = ref1(2)*ref2(3) - ref1(3)*ref2(2);
  nor(2) = ref1(3)*ref2(1) - ref1(1)*ref2(3);
  nor(3) = ref1(1)*ref2(2) - ref1(2)*ref2(1);

  nor /= nor.norm();

  // axis definition
  axis1 = ref1;

  // axis2 = norm x axis1
  axis2(1) = nor(2)*axis1(3) - nor(3)*axis1(2);
  axis2(2) = nor(3)*axis1(1) - nor(1)*axis1(3);
  axis2(3) = nor(1)*axis1(2) - nor(2)*axis1(1);

  double costhetaI,sinthetaI, costhetaJ,sinthetaJ, thetaI,thetaJ;

  for (int i=1; i<=m_N; ++i) {
    for (int j=(i+1); j<=m_N; ++j) {
      vI = t_xyz.get_col(i) - cent;
      vJ = t_xyz.get_col(j) - cent;

      costhetaI = vI.inner(axis1);
      sinthetaI = vI.inner(axis2);

      costhetaJ = vJ.inner(axis1);
      sinthetaJ = vJ.inner(axis2);

      thetaI = atan2(sinthetaI, costhetaI);
      thetaJ = atan2(sinthetaJ, costhetaJ);
      
      // sort  minimum angle difference first
      if (thetaJ < thetaI) 
      {
        // swap I and J
      //t_xyz(All, [i j]) = t_xyz(All, [j i]);

        tmp = t_xyz.get_col(i);               // copy column i
        t_xyz.set_col(i, t_xyz.get_col(j));   // overwrite col i
        t_xyz.set_col(j, tmp);                // overwrite col j
      }
    }
  } 
}
コード例 #14
0
void execution(int index){
    if(test==1) printf("enter EX, with index=%d\n",index);

    if(index==0 || index==34){ //NOP or HALT
        return;
    }
    /**R-type instructions**/
    else if(index==1){
        add(RS,RT,RD);
    }
    else if(index==2){
        addu(RS,RT,RD);
    }
    else if(index==3){
        sub(RS,RT,RD);
    }
    else if(index==4){
        and(RS,RT,RD);
    }
    else if(index==5){
        or(RS,RT,RD);
    }
    else if(index==6){
        xor(RS,RT,RD);
    }
    else if(index==7){
        nor(RS,RT,RD);
    }
    else if(index==8){
        nand(RS,RT,RD);
    }
    else if(index==9){
        slt(RS,RT,RD);
    }
    else if(index==10){
        sll(RT,RD,SHAMT);
    }
    else if(index==11){
        srl(RT,RD,SHAMT);
    }
    else if(index==12){
        sra(RT,RD,SHAMT);
    }
    /**J-type instructions**/
    /*else if(index==13){
        jr(RS);
    }
    else if(index==14){
        jj(C);
    }
    else if(index==15){
        jal(C);
    }*/
    /**I-type instructions**/
    else if(index==16){
        addi(RS,RT,C);
    }
    else if(index==17){
        addiu(RS,RT,C);
    }
    else if(index==18){
        lw(RS,RT,signedC);
    }
    else if(index==19){
        lh(RS,RT,signedC);
    }
    else if(index==20){
        lhu(RS,RT,C);
    }
    else if(index==21){
        lb(RS,RT,signedC);
    }
    else if(index==22){
        lbu(RS,RT,C);
    }
    else if(index==23){
        sw(RS,RT,signedC);
    }
    else if(index==24){
        sh(RS,RT,signedC);
    }
    else if(index==25){
        sb(RS,RT,signedC);
    }
    else if(index==26){
        lui(RT,C);
    }
    else if(index==27){
        andi(RS,RT,C);
    }
    else if(index==28){
        or(RS,RT,C);
    }
    else if(index==29){
        nor(RS,RT,C);
    }
    else if(index==30){
        slti(RS,RT,C);
    }
    /*else if(index==31){
        beq(RS,RT,signedC);
    }
    else if(index==32){
        bne(RS,RT,signedC);
    }
    else if(index==33){
        bgtz(RS,signedC);
    }*/
    else{
        if(test==1) printf("this is error instruction or is done in ID\n");
    }
    EX_prev=index;
    DM_index=index;
}
コード例 #15
0
ファイル: out.c プロジェクト: SayaliSalunke/project
/* finds the value of every led saves it in data structure and in Array (used for drawing screen) */
void findOutput(){ 
	int i, n1, n2, value;
	output * optr;
	node * nptr;
	for(i = 0; i < c.li; i++) {
		init(&s);		
		MakeStack(i);
		while(!empty(&s)) {
			nptr = pop(&s);
			switch(nptr->type) {
				case INPUT :
					PutValue(nptr, value);
					break;
			
				case OUTPUT :	
					GetInputs(&n1, &n2, nptr->ptr);
					/* Calculating Output */
					optr = nptr->ptr;
					switch(optr->type) {
						case NAND :
							value = nand(n1, n2);
							break;
	
						case XNOR :
							value = xnor(n1, n2);
							break;

						case NOR :
							value = nor(n1, n2);
							break;

						case AND :
							value = and(n1, n2);
							break;

						case OR :
							value = or(n1, n2);
							break;
					
						case XOR :
							value = xor(n1, n2);
							break;

						case NOT :
							value = not(n1);
							break;

						default :
						break;
						
					PutValue(nptr, value);
					}
					break;
		
				case SWITCH :
					value = GetValue(nptr->ptr); 
					break;

				case LED :
					PutValue(nptr, value);
					break;
			}
		}
	}
	ChangeOnscreen();	
}
コード例 #16
0
ファイル: controller.c プロジェクト: happypandaface/icmm
void controlCamera()
{
	// Set the camera
	GLfloat up[3] = {0.0f, 1.0f, 0.0f};
	if (keysDown & mKey)
	{
		up[0] = sin(controlled->angle);
		up[1] = 0.0f;
		up[2] = -cos(controlled->angle);
	}
	
	float height = -1.0f;
	if (keysDown & mKey)
		height = -150.0f;
	
	GLfloat f[3] = {sin(controlled->angle), 0.0f, -cos(controlled->angle)};
	if (keysDown & mKey)
	{
		f[0] = 0.0f;
		f[1] = -1.0f;
		f[2] = 0.0f;
	}
	
	GLfloat fNor[3];
	nor(f, fNor);
	
	GLfloat s[3];
	crs(fNor, up, s);
	GLfloat sNor[3];
	nor(s, sNor);
	
	GLfloat u[3];
	crs(sNor, fNor, u);
	
	GLfloat camMat[4][4];
	
	camMat[0][0] = s[0];
	camMat[1][0] = s[1];
	camMat[2][0] = s[2];
	camMat[3][0] = 0.0f;
	
	camMat[0][1] = u[0];
	camMat[1][1] = u[1];
	camMat[2][1] = u[2];
	camMat[3][1] = 0.0f;
	
	camMat[0][2] = -f[0];
	camMat[1][2] = -f[1];
	camMat[2][2] = -f[2];
	camMat[3][2] = 0.0f;
	
	camMat[0][3] = 0.0f;
	camMat[1][3] = 0.0f;
	camMat[2][3] = 0.0f;
	camMat[3][3] = 1.0f;
	
	glLoadIdentity();
	glMultMatrixf(camMat[0]);
	glTranslated(-controlled->pos.x*CREATURE_WIDTH*2, height, -controlled->pos.y*CREATURE_HEIGHT*2);
	
	//gluLookAt(	x, 1.0f, z,
	//		x+lx, 1.0f,  z+lz,
	//		0.0f, 1.0f,  0.0f);
}
コード例 #17
0
ファイル: logic.c プロジェクト: raymondluu/LogicGates
int main(void) {
    bit a;
    a = 0x00;
	
	bit b;
	b = 0x00;
	
	bit a1;
	a1 = 0x01;
	
	bit b1;
	b1 = 0x01;

	printf("\nAND GATE\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, and(a, b));
	printf("%d   %d   %d\n",a, b1, and(a, b1));
	printf("%d   %d   %d\n",a1, b, and(a1, b));
	printf("%d   %d   %d\n",a1, b1, and(a1, b1));
	
	printf("\nOR GATE\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, or(a, b));
	printf("%d   %d   %d\n",a, b1, or(a, b1));
	printf("%d   %d   %d\n",a1, b, or(a1, b));
	printf("%d   %d   %d\n",a1, b1, or(a1, b1));
	
	printf("\nNOT GATE\n");
	printf("a   r\n");
	printf("-----------\n");
    printf("%d   %d\n",a, not(a));
	printf("%d   %d\n",a1, not(a1));
	
	printf("\nXOR GATE\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, xor(a, b));
	printf("%d   %d   %d\n",a, b1, xor(a, b1));
	printf("%d   %d   %d\n",a1, b, xor(a1, b));
	printf("%d   %d   %d\n",a1, b1, xor(a1, b1));
	
	printf("\nNOR GATE\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, nor(a, b));
	printf("%d   %d   %d\n",a, b1, nor(a, b1));
	printf("%d   %d   %d\n",a1, b, nor(a1, b));
	printf("%d   %d   %d\n",a1, b1, nor(a1, b1));
	
	printf("\nNAND GATE\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, nand(a, b));
	printf("%d   %d   %d\n",a, b1, nand(a, b1));
	printf("%d   %d   %d\n",a1, b, nand(a1, b));
	printf("%d   %d   %d\n",a1, b1, nand(a1, b1));
	
		printf("\n~(~(a)|~(b))\n");
	printf("a   b   r\n");
	printf("-----------\n");
    printf("%d   %d   %d\n",a, b, not(or(not(a), not(b))));
	printf("%d   %d   %d\n",a, b1, not(or(not(a), not(b1))));
	printf("%d   %d   %d\n",a1, b, not(or(not(a1), not(b))));
	printf("%d   %d   %d\n",a1, b1, not(or(not(a1), not(b1))));
}
コード例 #18
0
ファイル: StlFile.cpp プロジェクト: wheelium-m/collisiondepth
void StlFile::DaeReadFile(const char * filename){
  
  TiXmlDocument doc(filename);
  doc.LoadFile();
  
  TiXmlElement * lgeo=doc.RootElement()->FirstChildElement("library_geometries");
  
  TiXmlElement * geo=lgeo->FirstChildElement("geometry");
  TiXmlElement * mesh=geo->FirstChildElement("mesh");
  
  TiXmlElement *input=mesh->FirstChildElement("vertices")->FirstChildElement("input");
  
  const char * position_name=0;
  const char * normals_name=0;
  const char * position_char_data=0;
  const char * normals_char_data=0;
  const char * pdata;
  
  while(input&&(!position_name||!normals_name)){
    if(strcmp(input->Attribute("semantic"), "POSITION")==0){
      position_name = input->Attribute("source");
    }
    else if(strcmp(input->Attribute("semantic"), "NORMAL")==0){
      normals_name = input->Attribute("source");
    }
    input=input->NextSiblingElement("input");
  }
  
  if(!position_name||!normals_name){
    cout<<"Incomplete information in the DAE file"<<endl;
    return;
  }
  position_name+=1;
  normals_name+=1;
  
  TiXmlElement * source=mesh->FirstChildElement("source");
  
  while(source&&(!position_char_data||!normals_char_data)){
    if(strcmp(source->Attribute("id"), position_name)==0){
      position_char_data=source->FirstChildElement("float_array")->GetText(); 
    }
    else if(strcmp(source->Attribute("id"), normals_name)==0){
      normals_char_data=source->FirstChildElement("float_array")->GetText();
      
    }
    source=source->NextSiblingElement("source");
  }
  
  TiXmlElement * triangles = mesh->FirstChildElement("triangles");
  
  TiXmlElement * p = triangles->FirstChildElement("p");
  
  TiXmlElement * t_input = triangles->FirstChildElement("input");
  
  int offset=0;
  int num_attr=0;
  while(t_input){
    if(strcmp(t_input->Attribute("semantic"), "VERTEX")==0)
      offset=num_attr;   
    num_attr++;
    t_input=t_input->NextSiblingElement("input");
  }
  
  pdata=p->GetText();

  vector<float> vertex_points, normal_points;
  vector<int> vector_pdata, order;
  vector<Point> vertices;
  istringstream pos(position_char_data);
  istringstream nor(normals_char_data);
  istringstream pd(pdata);

  copy(istream_iterator<float>(pos),
       istream_iterator<float>(),
       back_inserter<vector<float> >(vertex_points));
  copy(istream_iterator<float>(nor),
       istream_iterator<float>(),
       back_inserter<vector<float> >(normal_points));
  copy(istream_iterator<int>(pd),
       istream_iterator<int>(),
       back_inserter<vector<int> >(vector_pdata));
  for(int i = offset; i < vector_pdata.size()/num_attr; i+=num_attr){
    order.push_back(vector_pdata[i]);
  }
  int count=0;
  while(count<=normal_points.size()-3){
    normals.push_back(Point(normal_points[count++], normal_points[count++], normal_points[count++]));
  }
  count=0;
  while(count<=vertex_points.size()-3){
    vertices.push_back(Point(vertex_points[count++],vertex_points[count++],vertex_points[count++]));
  }
  count=0;
  while(count<=order.size()-3){
    this->triangles.push_back(Triangle(vertices[order[count++]],vertices[order[count++]],vertices[vector_pdata[count++]]));
  }
  numTriangles=this->triangles.size();
}
コード例 #19
0
ファイル: main.c プロジェクト: yangshun2532/myMemory
int exe(FILE* program)  //program指向存有待执行程序机器码的文件
{

     char* tmp_instru=(char*)malloc(33*sizeof(char)); //读机器码
     programTail=programHead;
     while(fscanf(program,"%s",tmp_instru)!=EOF)
     {
         instru=0;
         int i=0;
         unsigned j=1;
         for(i=31;i>=0;i--)
         {
            if(tmp_instru[i]=='1')
            {
                instru+=j;
                j*=2;
            }
            else
            {
                j*=2;
            }
         }//将机器码转为unsi
         unsigned char* tmp_R=&instru;
         for(i=0;i<4;i++)
         {
             writeMymemory(programTail+i,tmp_R+i);//装载指令
         }
         programTail+=4;//最后一条指令的下一条指令的地址,用来判断程序是否执行完
     }
     pcShort=programHead;
     pc=pcShort;
     while(pcShort!=programTail)
    {
        instru=0;   //指令寄存器清零
    unsigned char* tmp_R=&instru;
    unsigned short addr=addrToMyAddr(pc);
    int i;
    for(i=0;i<4;i++)
    {
        readMymemory(addr+i,tmp_R+i);//取指令
    }
    unsigned tmp=instru>>26;//得到指令op

    //printf("the op is :  %u\n",tmp);

    unsigned numRs=0,numRt=0,numRd=0,numFs=0,numFt=0,numFd=0,tmp_fuc=0;
    switch(tmp)
    {
    case 0x00000023:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=lw(pc);
        break;
    case 0x0000002B:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=sw(pc);
        break;
    case 0x00000008:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=addi(pc);
        break;
    case 0x00000009:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=addiu(pc);
        break;
    case 0x0000000A:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=slti(pc);
        break;
    case 0x0000000B:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=sltiu(pc);
        break;
    case 0x0000000C:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=andi(pc);
        break;
    case 0x0000000D:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=ori(pc);
        break;
    case 0x0000000E:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=xori(pc);
        break;
    case 0x00000024:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=lbu(pc);
        break;
    case 0x00000020:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=lb(pc);
        break;
    case 0x00000028:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=sb(pc);
        break;
    case 0x0000000F:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=lui(pc);
        break;
    case 0x00000004:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=beq(pc);
        break;
    case 0x00000005:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        //printf("%u,%u,%u,%u\n",numRt,numRs,*RS1,*RS2);
        lig=instru<<16>>16;
       // printf("%u\n",lig);
        pc=bne(pc);
        break;
    case 0x00000006:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=blez(pc);
        break;
    case 0x00000007:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=bgtz(pc);
        break;
    case 0x00000001:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        lig=instru<<16>>16;
        pc=bltz(pc);
        break;
    case 0x00000002:
        pc=j(pc);
        break;
    case 0x00000003:
        pc=jal(pc);
        break;
    case 0x00000000:
        numRs=instru<<6>>27;
        numRt=instru<<11>>27;
        numRd=instru<<16>>27;
        RS1=myRegister+numRt;
        RS2=myRegister+numRs;
        RD=myRegister+numRd;
        tmp_fuc=instru%64;
        switch(tmp_fuc)
        {
        case 32:
            pc=add(pc);
            break;
        case 33:
            pc=addu(pc);
            break;
        case 34:
            pc=sub(pc);
            break;
        case 35:
            pc=subu(pc);
            break;
        case 24:
            pc=mul(pc);
            break;
        case 25:
            pc=mulu(pc);
            break;
        case 26:
            pc=myDiv(pc);
            break;
        case 27:
            pc=divu(pc);
            break;
        case 42:
            pc=slt(pc);
            break;
        case 43:
            pc=sltu(pc);
            break;
        case 36:
            pc=myAnd(pc);
            break;
        case 37:
            pc=myOr(pc);
            break;
        case 39:
            pc=nor(pc);
            break;
        case 40:
            pc=myXor(pc);
            break;
        case 8:
            pc=jr(pc);
            break;
        case 9:
            pc=jalr(pc);
            break;
        case 0:
            pc=nop(pc);
            break;
        case 16:
            pc=mfhi(pc);
            break;
        case 18:
            pc=mflo(pc);
            break;
        default:
            break;
        }
        break;
    case 0x00000010:
        numRt=instru<<11>>27;
        numRd=instru<<16>>27;
        RS1=myRegister+numRt;
        if(numRd==14)
        {
            pc=mfepc(pc);
        }
        else if(numRd==13)
        {
            pc=mfco(pc);
        }
        else return -1;
        break;
    case 0x00000031:
        numRs=instru<<6>>27;
        numFt=instru<<11>>27;
        RS2=myRegister+numRs;
        FS1=myFloatReg+numFt;
        lig=instru<<16>>16;
        pc=lwc1(pc);


            //printf("/********\nL.S %u %u\n****************/\n",numFt,numRs);

        break;
    case 0x0000001F:
        numRs=instru<<6>>27;
        numFt=instru<<11>>27;
        RS2=myRegister+numRs;
        FS1=myFloatReg+numFt;
        lig=instru<<16>>16;
        pc=S_D(pc);


            //printf("/********\nL.D %u %u\n****************/\n",numFt,numRs);

        break;
    case 0x0000001E:
        numRs=instru<<6>>27;
        numFt=instru<<11>>27;
        RS2=myRegister+numRs;
        FS1=myFloatReg+numFt;
        lig=instru<<16>>16;
        //printf("/********\nS.D %u %u\n****************/\n",numFt,numRs);
        pc=S_D(pc);
        break;

    case 0x00000039:
        numRs=instru<<6>>27;
        numFt=instru<<11>>27;
        RS2=myRegister+numRs;
        FS1=myFloatReg+numFt;
        lig=instru<<16>>16;
        //printf("/********\nS.S %u %u\n****************/\n",numFt,numRs);
        pc=swc1(pc);
        break;
    case 0x00000011:
        numFt=instru<<11>>27;
        numFs=instru<<16>>27;
        numFd=instru<<21>>27;
        FS1=myFloatReg+numFt;
        FS2=myFloatReg+numFs;
        FD=myFloatReg+numFd;
        numRs=instru<<6>>27;
        tmp_fuc=instru%64;
        //printf("%u %u\n",tmp_fuc,numRs);
        if(numRs==0)
        {
            switch(tmp_fuc)
            {
            case 0:
                pc=add_s(pc);
                break;
            case 1:
                pc=sub_s(pc);
                break;
            case 2:
                pc=mul_s(pc);
            case 3:
                pc=div_s(pc);
            default:
                break;
            }
        }
        else if(numRs==1)
        {
            switch(tmp_fuc)
            {
            case 0:
                pc=add_d(pc);
                //printf("/****************\nADD.D %u %u %u\n*****************/\n",numFd,numFt,numFs);
                break;
            case 1:
                pc=sub_d(pc);
                break;
            case 2:
                pc=mul_d(pc);
            case 3:
                pc=div_d(pc);
            default:
                break;
            }
        }
        default:break;
    }
    pcShort=pc%0x00010000;
    //printf("%u %u\n",pc,pcShort);
    //printf("%u %u\n",pcShort,programTail);
    }
    return 0;
}
コード例 #20
0
ファイル: encode_op.c プロジェクト: occho/cpu
int encode_op(char *opcode, char *op_data)
{
	int rd,rs,rt,imm,funct,shaft,target;
	char tmp[256];
	const char *fi = "%s %d";
	const char *fg = "%s %%g%d";
	const char *ff = "%s %%f%d";
	const char *fl = "%s %s";
	const char *fgi = "%s %%g%d, %d";
	const char *fgl = "%s %%g%d, %s";
	const char *fgg = "%s %%g%d, %%g%d";
	const char *fggl = "%s %%g%d, %%g%d, %s";
	const char *fggi = "%s %%g%d, %%g%d, %d";
	const char *fggg = "%s %%g%d, %%g%d, %%g%d";
	const char *fff = "%s %%f%d, %%f%d";
	const char *fgf = "%s %%g%d, %%f%d";
	const char *ffg = "%s %%f%d, %%g%d";
	const char *fffl = "%s %%f%d, %%f%d, %s";
	const char *ffff = "%s %%f%d, %%f%d, %%f%d";
	const char *ffgi = "%s %%f%d, %%g%d, %d";
	const char *ffgg = "%s %%f%d, %%g%d, %%g%d";
	char lname[256];

	shaft = funct = target = 0;

	if(strcmp(opcode, "mvhi") == 0){
		if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3)
		    return mvhi(rs,0,imm);
	}
	if(strcmp(opcode, "mvlo") == 0){
		if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3)
		    return mvlo(rs,0,imm);
	}
	if(strcmp(opcode, "add") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return add(rs,rt,rd,0);
	}
	if(strcmp(opcode, "nor") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return nor(rs,rt,rd,0);
	}
	if(strcmp(opcode, "sub") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return sub(rs,rt,rd,0);
	}
	if(strcmp(opcode, "mul") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return mul(rs,rt,rd,0);
	}
	if(strcmp(opcode, "addi") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return addi(rs,rt,imm);
	}
	if(strcmp(opcode, "subi") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return subi(rs,rt,imm);
	}
	if(strcmp(opcode, "muli") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return muli(rs,rt,imm);
	}
	if(strcmp(opcode, "input") == 0){
		if(sscanf(op_data, fg, tmp, &rd) == 2)
		    return input(0,0,rd,0);
	}
	if(strcmp(opcode, "inputw") == 0){
		if(sscanf(op_data, fg, tmp, &rd) == 2)
		    return inputw(0,0,rd,0);
	}
	if(strcmp(opcode, "inputf") == 0){
		if(sscanf(op_data, ff, tmp, &rd) == 2)
		    return inputf(0,0,rd,0);
	}
	if(strcmp(opcode, "output") == 0){
		if(sscanf(op_data, fg, tmp, &rs) == 2)
		    return output(rs,0,0,0);
	}
	if(strcmp(opcode, "outputw") == 0){
		if(sscanf(op_data, fg, tmp, &rs) == 2)
		    return outputw(rs,0,0,0);
	}
	if(strcmp(opcode, "outputf") == 0){
		if(sscanf(op_data, ff, tmp, &rs) == 2)
		    return outputf(rs,0,0,0);
	}
	if(strcmp(opcode, "and") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return _and(rs,rt,rd,0);
	}
	if(strcmp(opcode, "or") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return _or(rs,rt,rd,0);
	}
	if(strcmp(opcode, "sll") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return sll(rs,rt,rd,0);
	}
	if(strcmp(opcode, "srl") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return srl(rs,rt,rd,0);
	}
	if(strcmp(opcode, "slli") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return slli(rs,rt,imm);
	}
	if(strcmp(opcode, "srli") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return srli(rs,rt,imm);
	}
	if(strcmp(opcode, "b") == 0){
		if(sscanf(op_data, fg, tmp, &rs) == 2)
		    return b(rs,0,0,0);
	}
	if(strcmp(opcode, "jmp") == 0){
		if(sscanf(op_data, fl, tmp, lname) == 2) {
			strcpy(label_name[label_cnt],lname);
		    return jmp(label_cnt++);
		}
	}
	if(strcmp(opcode, "jeq") == 0){
		if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return jeq(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "jne") == 0){
		if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return jne(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "jlt") == 0){
		if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return jlt(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "jle") == 0){
		if(sscanf(op_data, fggl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return jle(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "call") == 0){
		if(sscanf(op_data, fl, tmp, lname) == 2)  {
			strcpy(label_name[label_cnt],lname);
		    return call(label_cnt++);
		}
	}
	if(strcmp(opcode, "callR") == 0){
		if(sscanf(op_data, fg, tmp, &rs) == 2)
		    return callr(rs,0,0,0);
	}
	if(strcmp(opcode, "return") == 0){
		    return _return(0);
	}
	if(strcmp(opcode, "ld") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return ld(rs,rt,rd,0);
	}
	if(strcmp(opcode, "ldi") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return ldi(rs,rt,imm);
	}
	if(strcmp(opcode, "ldlr") == 0){
		if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3)
		    return ldlr(rs,0,imm);
	}
	if(strcmp(opcode, "fld") == 0){
		if(sscanf(op_data, ffgg, tmp, &rd, &rs,&rt) == 4)
		    return fld(rs,rt,rd,0);
	}
	if(strcmp(opcode, "st") == 0){
		if(sscanf(op_data, fggg, tmp, &rd, &rs,&rt) == 4)
		    return st(rs,rt,rd,0);
	}
	if(strcmp(opcode, "sti") == 0){
		if(sscanf(op_data, fggi, tmp, &rt, &rs, &imm) == 4)
		    return sti(rs,rt,imm);
	}
	if(strcmp(opcode, "stlr") == 0){
		if(sscanf(op_data, fgi, tmp, &rs, &imm) == 3)
		    return stlr(rs,0,imm);
	}
	if(strcmp(opcode, "fst") == 0){
		if(sscanf(op_data, ffgg, tmp, &rd, &rs,&rt) == 4)
		    return fst(rs,rt,rd,0);
	}
	if(strcmp(opcode, "fadd") == 0){
		if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4)
		    return fadd(rs,rt,rd,0);
	}
	if(strcmp(opcode, "fsub") == 0){
		if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4)
		    return fsub(rs,rt,rd,0);
	}
	if(strcmp(opcode, "fmul") == 0){
		if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4)
		    return fmul(rs,rt,rd,0);
	}
	if(strcmp(opcode, "fdiv") == 0){
		if(sscanf(op_data, ffff, tmp, &rd, &rs, &rt) == 4)
		    return fdiv(rs,rt,rd,0);
	}
	if(strcmp(opcode, "fsqrt") == 0){
		if(sscanf(op_data, fff, tmp, &rd, &rs) == 3)
		    return fsqrt(rs,0,rd,0);
	}
	if(strcmp(opcode, "fabs") == 0){
		if(sscanf(op_data, fff, tmp, &rd, &rs) == 3)
		    return _fabs(rs,0,rd,0);
	}
	if(strcmp(opcode, "fmov") == 0){
		if(sscanf(op_data, fff, tmp, &rd, &rs) == 3)
		    return fmov(rs,0,rd,0);
	}
	if(strcmp(opcode, "fneg") == 0){
		if(sscanf(op_data, fff, tmp, &rd, &rs) == 3)
		    return fneg(rs,0,rd,0);
	}
	if(strcmp(opcode, "fldi") == 0){
		if(sscanf(op_data, ffgi, tmp, &rt, &rs, &imm) == 4)
		    return fldi(rs,rt,imm);
	}
	if(strcmp(opcode, "fsti") == 0){
		if(sscanf(op_data, ffgi, tmp, &rt, &rs, &imm) == 4)
		    return fsti(rs,rt,imm);
	}
	if(strcmp(opcode, "fjeq") == 0){
		if(sscanf(op_data, fffl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return fjeq(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "fjlt") == 0){
		if(sscanf(op_data, fffl, tmp, &rs, &rt, lname) == 4) {
			strcpy(label_name[label_cnt],lname);
		    return fjlt(rs,rt,label_cnt++);
		}
	}
	if(strcmp(opcode, "halt") == 0){
		    return halt(0,0,0,0);
	}
	if(strcmp(opcode, "setL") == 0){
		if(sscanf(op_data, fgl, tmp, &rd, lname) == 3) {
			strcpy(label_name[label_cnt],lname);
		    return setl(0,rd,label_cnt++);
		}
	}
	if(strcmp(opcode, "padd") == 0){
		if(sscanf(op_data, fgi, tmp, &rt, &imm) == 3) {
		    return padd(0,rt,imm);
		}
	}
	if(strcmp(opcode, "link") == 0){
		if(sscanf(op_data, fi, tmp, &imm) == 2) {
		    return link(0,0,imm);
		}
	}
	if(strcmp(opcode, "movlr") == 0){
		return movlr(0,0,0,0);
	}
	if(strcmp(opcode, "btmplr") == 0){
		return btmplr(0,0,0,0);
	}
	/*
	if(strcmp(opcode, "padd") == 0){
		if(sscanf(op_data, fgg, tmp, &rd, &rt) == 3) {
		    return padd(0,rt,d,0);
		}
	}
	*/

	return -1;
}