int _mon_check_mcd() {
    PLI_INT32 status;

    PLI_UINT32 mcd;
    PLI_BYTE8* filename = (PLI_BYTE8*)"obj_dir/t_vpi_var/mcd_open.tmp";
    mcd = vpi_mcd_open(filename);
    CHECK_RESULT_NZ(mcd);

    {   // Check it got written
        FILE* fp = fopen(filename,"r");
        CHECK_RESULT_NZ(fp);
        fclose(fp);
    }

    status = vpi_mcd_printf(mcd, (PLI_BYTE8*)"hello %s", "vpi_mcd_printf");
    CHECK_RESULT(status, strlen("hello vpi_mcd_printf"));

    status = vpi_mcd_flush(mcd);
    CHECK_RESULT(status, 0);

    status = vpi_mcd_close(mcd);
    CHECK_RESULT(status, 0);

    status = vpi_flush();
    CHECK_RESULT(status, 0);

    return 0;
}
Exemple #2
0
static void set_handle_to_value(vpiHandle sig, const char*val)
{
      size_t width = strlen(val);
      size_t vv_count = (width+31)/32;

      s_vpi_value value;

      value.value.vector = calloc(vv_count, sizeof(s_vpi_vecval));
      int idx;
      for (idx = 0 ; idx < width ; idx += 1) {
	    int word = idx / 32;
	    int bit = idx % 32;
	    char src = val[width-idx-1];
	    PLI_INT32 amask = 0;
	    PLI_INT32 bmask = 0;
	    switch (src) {
		case '0':
		  continue;
		case '1':
		  amask = 1;
		  bmask = 0;
		  break;
		case 'x':
		  amask = 1;
		  bmask = 1;
		  break;
		case 'z':
		  amask = 0;
		  bmask = 1;
		  break;
	    }

	    s_vpi_vecval*vp = value.value.vector+word;

	    vp->aval |= amask << bit;
	    vp->bval |= bmask << bit;
      }

      if (vpi_get(vpiSize, sig) != width) {
	    vpi_printf("ERROR: %s is %d bits, got %zu from server\n",
		       vpi_get_str(vpiName, sig), vpi_get(vpiSize, sig), width);
	    vpi_flush();
      }

      assert(vpi_get(vpiSize, sig) == width);
      assert(vpi_get(vpiType, sig) == vpiReg);

      value.format = vpiVectorVal;
      vpi_put_value(sig, &value, 0, vpiNoDelay);

      free(value.value.vector);
}