mirror of
https://github.com/verilator/verilator.git
synced 2025-04-15 09:06:53 +00:00
Fix DPI bit vector compile errors, bug347.
This commit is contained in:
parent
9558e14479
commit
fb85679068
2
Changes
2
Changes
@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
**** Fix DPI undeclared svBitVecVal compile error, bug346. [Chandan Egbert]
|
||||
|
||||
**** Fix DPI bit vector compile errors, bug347. [Chandan Egbert]
|
||||
|
||||
**** Fix CDCRSTLOGIC report showing endpoint flops without resets.
|
||||
|
||||
**** Fix compiler warnings on SPARC, bug288. [Ahmed El-Mahmoudy]
|
||||
|
@ -605,7 +605,7 @@ private:
|
||||
return new AstCStmt(portp->fileline(), stmt);
|
||||
}
|
||||
|
||||
AstNode* createAssignDpiToInternal(AstVarScope* portvscp, const string& frName) {
|
||||
AstNode* createAssignDpiToInternal(AstVarScope* portvscp, const string& frName, bool cvt) {
|
||||
// Create assignment from DPI temporary into internal format
|
||||
AstVar* portp = portvscp->varp();
|
||||
string stmt;
|
||||
@ -614,6 +614,8 @@ private:
|
||||
stmt += "VL_CVT_VP_Q(";
|
||||
ket += ")";
|
||||
}
|
||||
if (!cvt
|
||||
&& portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1) stmt += "*"; // it's a svBitVecVal
|
||||
stmt += frName;
|
||||
stmt += ket;
|
||||
// Use a AstCMath, as we want V3Clean to mask off bits that don't make sense.
|
||||
@ -680,7 +682,7 @@ private:
|
||||
argnodesp = argnodesp->addNextNull(refp);
|
||||
|
||||
if (portp->isInput()) {
|
||||
dpip->addStmtsp(createAssignDpiToInternal(outvscp, portp->name()));
|
||||
dpip->addStmtsp(createAssignDpiToInternal(outvscp, portp->name(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -795,7 +797,7 @@ private:
|
||||
if (AstVar* portp = stmtp->castVar()) {
|
||||
if (portp->isIO() && (portp->isOutput() || portp->isFuncReturn())) {
|
||||
AstVarScope* portvscp = portp->user2p()->castNode()->castVarScope(); // Remembered when we created it earlier
|
||||
cfuncp->addStmtsp(createAssignDpiToInternal(portvscp,portp->name()+"__Vcvt"));
|
||||
cfuncp->addStmtsp(createAssignDpiToInternal(portvscp,portp->name()+"__Vcvt",true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ module t;
|
||||
function int dpix_int123(); dpix_int123 = 32'h123; endfunction
|
||||
|
||||
export "DPI-C" function dpix_f_bit;
|
||||
export "DPI-C" function dpix_f_bit15;
|
||||
export "DPI-C" function dpix_f_int;
|
||||
export "DPI-C" function dpix_f_byte;
|
||||
export "DPI-C" function dpix_f_shortint;
|
||||
@ -30,6 +31,7 @@ module t;
|
||||
export "DPI-C" function dpix_f_chandle;
|
||||
|
||||
function bit dpix_f_bit (bit i); dpix_f_bit = ~i; endfunction
|
||||
function bit [14:0] dpix_f_bit15 (bit [14:0] i); dpix_f_bit15 = ~i; endfunction
|
||||
function int dpix_f_int (int i); dpix_f_int = ~i; endfunction
|
||||
function byte dpix_f_byte (byte i); dpix_f_byte = ~i; endfunction
|
||||
function shortint dpix_f_shortint(shortint i); dpix_f_shortint = ~i; endfunction
|
||||
|
@ -123,8 +123,11 @@ int dpix_run_tests() {
|
||||
CHECK_RESULT (int, o, 0x458UL);
|
||||
#endif
|
||||
|
||||
svBitVecVal vec10[1] = {0x10};
|
||||
|
||||
CHECK_RESULT (int, dpix_f_bit(1), 0x0);
|
||||
CHECK_RESULT (int, dpix_f_bit(0), 0x1);
|
||||
CHECK_RESULT (int, dpix_f_bit15(vec10) & 0x7fUL, 0x6f);
|
||||
// Simulators disagree over the next three's sign extension unless we mask the upper bits
|
||||
CHECK_RESULT (int, dpix_f_int(1) & 0xffffffffUL, 0xfffffffeUL);
|
||||
CHECK_RESULT (int, dpix_f_byte(1) & 0xffUL, 0xfe);
|
||||
|
Loading…
Reference in New Issue
Block a user