Fix DPI import of null C-string (#5179).
This commit is contained in:
parent
4695967185
commit
ad2862ce3f
1
Changes
1
Changes
|
|
@ -72,6 +72,7 @@ Verilator 5.025 devel
|
|||
* Fix SystemC BITS_PER_DIGIT in VL_ASSIGN_SBW (#5170). [Bartłomiej Chmiel, Antmicro Ltd.]
|
||||
* Fix non-constant replication in concats (#5171). [Arkadiusz Kozdra, Antmicro Ltd.]
|
||||
* Fix table optimization when applied on real data type (#5172) (#5173). [Arthur Rosa]
|
||||
* Fix DPI import of null C-string (#5179).
|
||||
|
||||
|
||||
Verilator 5.024 2024-04-05
|
||||
|
|
|
|||
|
|
@ -219,6 +219,10 @@ static inline QData VL_CVT_Q_D(double lhs) VL_PURE {
|
|||
return u.q;
|
||||
}
|
||||
// clang-format on
|
||||
// Return string from DPI char*
|
||||
static inline std::string VL_CVT_N_CSTR(const char* lhsp) VL_PURE {
|
||||
return lhsp ? std::string{lhsp} : ""s;
|
||||
}
|
||||
|
||||
// Return double from lhs (numeric) unsigned
|
||||
double VL_ITOR_D_W(int lbits, WDataInP const lwp) VL_PURE;
|
||||
|
|
|
|||
|
|
@ -305,6 +305,9 @@ struct TaskDpiUtils final {
|
|||
if (portp->basicp() && portp->basicp()->keyword() == VBasicDTypeKwd::CHANDLE) {
|
||||
frstmt = "VL_CVT_VP_Q(" + frName;
|
||||
ket = ")";
|
||||
} else if (portp->basicp() && portp->basicp()->keyword() == VBasicDTypeKwd::STRING) {
|
||||
frstmt = "VL_CVT_N_CSTR(" + frName;
|
||||
ket = ")";
|
||||
} else if ((portp->basicp() && portp->basicp()->isDpiPrimitive())) {
|
||||
frstmt = frName;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ module t (/*AUTOARG*/
|
|||
|
||||
import "DPI-C" pure function int dpii_f_strlen(input string i);
|
||||
|
||||
import "DPI-C" function string dpii_f_null();
|
||||
|
||||
import "DPI-C" function void dpii_f_void();
|
||||
|
||||
// Try a task
|
||||
|
|
@ -242,6 +244,7 @@ module t (/*AUTOARG*/
|
|||
`endif
|
||||
if (dpii_f_strlen(string6) != 6) $stop;
|
||||
|
||||
if (dpii_f_null() != "") $stop;
|
||||
dpii_f_void();
|
||||
dpii_t_void();
|
||||
dpii_t_void_context();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ extern short int dpii_f_shortint(short int i);
|
|||
extern long long dpii_f_longint(long long i);
|
||||
extern void* dpii_f_chandle(void* i);
|
||||
extern const char* dpii_f_string(const char* i);
|
||||
extern const char* dpii_f_null();
|
||||
extern double dpii_f_real(double i);
|
||||
extern float dpii_f_shortreal(float i);
|
||||
|
||||
|
|
@ -113,6 +114,7 @@ short int dpii_f_shortint(short int i) { return ~i; }
|
|||
long long dpii_f_longint(long long i) { return ~i; }
|
||||
void* dpii_f_chandle(void* i) { return i; }
|
||||
const char* dpii_f_string(const char* i) { return i; }
|
||||
const char* dpii_f_null() { return nullptr; }
|
||||
double dpii_f_real(double i) { return i + 1.5; }
|
||||
float dpii_f_shortreal(float i) { return i + 1.5f; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue