[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  Schedule::Load
  SVN::S4
  Synopsys-modes
  SystemPerl
  Verilog-Pli
  Voneline
  Vregs
General Info
  Papers

Issue #398

DPI-C issue with 64 bit data types when compiled on a 64-bit linux machine

Added by Mike Denio 7 months ago. Updated 7 months ago.

Status:Closed Start date:10/07/2011
Priority:Normal Due date:
Assignee:Wilson Snyder % Done:

0%

Category:TranslationError
Target version:-

Description

The following import statement has a problem.

import "DPI-C" task CMRead64(input int regnum, input int address, output bit [63:0] rdata);

It converts to the following code in Vtb.cpp:

void Vtb::__Vdpiimwrap_v__DOT__GDPI__DOT__CMRead64_TOP(IData regnum, IData address, QData& rdata) {
    VL_DEBUG_IF(VL_PRINTF("    Vtb::__Vdpiimwrap_v__DOT__GDPI__DOT__CMRead64_TOP\n"); );
    // Body
    int regnum__Vcvt;
    regnum__Vcvt = regnum;
    int address__Vcvt;
    address__Vcvt = address;
    svBitVecVal rdata__Vcvt [2];
    CMRead64(regnum__Vcvt, address__Vcvt, rdata__Vcvt);
    rdata = rdata__Vcvt;
}

The code declares rdata as “QData&”, and then at the bottom does “rdata = rdata__Vcvt”. This assignment is illegal since “rdata__Vcvt” is a pointer to an array of ints, not an immediate 64-bit value (long unsigned int).

I think the coding should be similar to the following:

void Vtb::__Vdpiimwrap_v__DOT__GDPI__DOT__CMRead64_TOP(IData regnum, IData address, WData (& rdata)[2]) {
    VL_DEBUG_IF(VL_PRINTF("    Vtb::__Vdpiimwrap_v__DOT__GDPI__DOT__CMRead64_TOP\n"); );
    // Body
    int regnum__Vcvt;
    regnum__Vcvt = regnum;
    int address__Vcvt;
    address__Vcvt = address;
    svBitVecVal rdata__Vcvt [2];
    CMRead64(regnum__Vcvt, address__Vcvt, rdata__Vcvt);
    VL_ASSIGN_W(64,rdata, rdata__Vcvt);
}

History

Updated by Mike Denio 7 months ago

Now that I posted it, my proposed solution won't work because the caller is expecting to pass in a type of QData. Code that reads the two int array values and constructs the 64-bit value would suffice.

Updated by Wilson Snyder 7 months ago

  • Status changed from New to Resolved
  • Assignee set to Wilson Snyder

VL_SET_QW is the function you were looking for, it was missing a test to use it; thanks for the report.

Fixed in git towards 3.822.

Updated by Wilson Snyder 7 months ago

  • Status changed from Resolved to Closed

In 3.822.

Also available in: Atom