For / allow 64-bit addressing.
This commit is contained in:
parent
1d2a7b2f41
commit
b71eb76252
|
|
@ -1320,16 +1320,16 @@ IData VL_SSCANF_INX(int, const std::string& ld, const char* formatp, ...) VL_MT_
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_WRITEMEM_Q(bool hex, int width, int depth, int array_lsb, int,
|
void VL_WRITEMEM_Q(bool hex, int width, QData depth, int array_lsb, int,
|
||||||
QData filename, const void* memp, IData start,
|
QData filename, const void* memp, QData start,
|
||||||
IData end) VL_MT_SAFE {
|
QData end) VL_MT_SAFE {
|
||||||
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
||||||
return VL_WRITEMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
return VL_WRITEMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_WRITEMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
void VL_WRITEMEM_W(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
WDataInP filenamep, const void* memp, IData start,
|
WDataInP filenamep, const void* memp, QData start,
|
||||||
IData end) VL_MT_SAFE {
|
QData end) VL_MT_SAFE {
|
||||||
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
||||||
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
||||||
std::string filenames(filenamez);
|
std::string filenames(filenamez);
|
||||||
|
|
@ -1356,13 +1356,13 @@ const char* memhFormat(int nBits) {
|
||||||
|
|
||||||
void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
||||||
int width, // Width of each array row
|
int width, // Width of each array row
|
||||||
int depth, // Number of rows
|
QData depth, // Number of rows
|
||||||
int array_lsb, // Index of first row. Valid row addresses
|
int array_lsb, // Index of first row. Valid row addresses
|
||||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||||
const std::string& filename, // Output file name
|
const std::string& filename, // Output file name
|
||||||
const void* memp, // Array state
|
const void* memp, // Array state
|
||||||
IData start, // First array row address to write
|
QData start, // First array row address to write
|
||||||
IData end // Last address to write, or ~0 when not specified
|
QData end // Last address to write, or ~0 when not specified
|
||||||
) VL_MT_SAFE {
|
) VL_MT_SAFE {
|
||||||
if (VL_UNLIKELY(!hex)) {
|
if (VL_UNLIKELY(!hex)) {
|
||||||
VL_FATAL_MT(filename.c_str(), 0, "",
|
VL_FATAL_MT(filename.c_str(), 0, "",
|
||||||
|
|
@ -1371,11 +1371,11 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate row address limits
|
// Calculate row address limits
|
||||||
size_t row_min = array_lsb;
|
QData row_min = array_lsb;
|
||||||
size_t row_max = row_min + depth - 1;
|
QData row_max = row_min + depth - 1;
|
||||||
|
|
||||||
// Normalize the last address argument: ~0 => row_max
|
// Normalize the last address argument: ~0 => row_max
|
||||||
size_t nend = (end == ~0u) ? row_max : end;
|
QData nend = (end == ~VL_ULL(0)) ? row_max : end;
|
||||||
|
|
||||||
// Bounds check the write address range
|
// Bounds check the write address range
|
||||||
if (VL_UNLIKELY((start < row_min) || (start > row_max)
|
if (VL_UNLIKELY((start < row_min) || (start > row_max)
|
||||||
|
|
@ -1390,8 +1390,8 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate row offset range
|
// Calculate row offset range
|
||||||
size_t row_start = start - row_min;
|
QData row_start = start - row_min;
|
||||||
size_t row_end = nend - row_min;
|
QData row_end = nend - row_min;
|
||||||
|
|
||||||
// Bail out on possible 32-bit size_t overflow
|
// Bail out on possible 32-bit size_t overflow
|
||||||
if (VL_UNLIKELY(row_end + 1 == 0)) {
|
if (VL_UNLIKELY(row_end + 1 == 0)) {
|
||||||
|
|
@ -1406,7 +1406,7 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t row_offset = row_start; row_offset <= row_end; ++row_offset) {
|
for (QData row_offset = row_start; row_offset <= row_end; ++row_offset) {
|
||||||
if (width <= 8) {
|
if (width <= 8) {
|
||||||
const CData* datap = &(reinterpret_cast<const CData*>(memp))[row_offset];
|
const CData* datap = &(reinterpret_cast<const CData*>(memp))[row_offset];
|
||||||
fprintf(fp, memhFormat(width), VL_MASK_I(width) & *datap);
|
fprintf(fp, memhFormat(width), VL_MASK_I(width) & *datap);
|
||||||
|
|
@ -1506,14 +1506,14 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||||
return read_count;
|
return read_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int,
|
void VL_READMEM_Q(bool hex, int width, QData depth, int array_lsb, int,
|
||||||
QData filename, void* memp, IData start, IData end) VL_MT_SAFE {
|
QData filename, void* memp, QData start, QData end) VL_MT_SAFE {
|
||||||
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
||||||
return VL_READMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
return VL_READMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
void VL_READMEM_W(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
WDataInP filenamep, void* memp, IData start, IData end) VL_MT_SAFE {
|
WDataInP filenamep, void* memp, QData start, QData end) VL_MT_SAFE {
|
||||||
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
||||||
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
||||||
std::string filenames(filenamez);
|
std::string filenames(filenamez);
|
||||||
|
|
@ -1522,13 +1522,13 @@ void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||||
|
|
||||||
void VL_READMEM_N(bool hex, // Hex format, else binary
|
void VL_READMEM_N(bool hex, // Hex format, else binary
|
||||||
int width, // Width of each array row
|
int width, // Width of each array row
|
||||||
int depth, // Number of rows
|
QData depth, // Number of rows
|
||||||
int array_lsb, // Index of first row. Valid row addresses
|
int array_lsb, // Index of first row. Valid row addresses
|
||||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||||
const std::string& filename, // Input file name
|
const std::string& filename, // Input file name
|
||||||
void* memp, // Array state
|
void* memp, // Array state
|
||||||
IData start, // First array row address to read
|
QData start, // First array row address to read
|
||||||
IData end // Last row address to read
|
QData end // Last row address to read
|
||||||
) VL_MT_SAFE {
|
) VL_MT_SAFE {
|
||||||
FILE* fp = fopen(filename.c_str(), "r");
|
FILE* fp = fopen(filename.c_str(), "r");
|
||||||
if (VL_UNLIKELY(!fp)) {
|
if (VL_UNLIKELY(!fp)) {
|
||||||
|
|
@ -1538,7 +1538,7 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Prep for reading
|
// Prep for reading
|
||||||
IData addr = start;
|
QData addr = start;
|
||||||
int linenum = 1;
|
int linenum = 1;
|
||||||
bool innum = false;
|
bool innum = false;
|
||||||
bool ignore_to_eol = false;
|
bool ignore_to_eol = false;
|
||||||
|
|
@ -1588,12 +1588,12 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
|
||||||
} else {
|
} else {
|
||||||
needinc = true;
|
needinc = true;
|
||||||
// printf(" Value width=%d @%x = %c\n", width, addr, c);
|
// printf(" Value width=%d @%x = %c\n", width, addr, c);
|
||||||
if (VL_UNLIKELY(addr >= static_cast<IData>(depth + array_lsb)
|
if (VL_UNLIKELY(addr >= static_cast<QData>(depth + array_lsb)
|
||||||
|| addr < static_cast<IData>(array_lsb))) {
|
|| addr < static_cast<QData>(array_lsb))) {
|
||||||
VL_FATAL_MT(filename.c_str(), linenum, "",
|
VL_FATAL_MT(filename.c_str(), linenum, "",
|
||||||
"$readmem file address beyond bounds of array");
|
"$readmem file address beyond bounds of array");
|
||||||
} else {
|
} else {
|
||||||
int entry = addr - array_lsb;
|
QData entry = addr - array_lsb;
|
||||||
QData shift = hex ? VL_ULL(4) : VL_ULL(1);
|
QData shift = hex ? VL_ULL(4) : VL_ULL(1);
|
||||||
// Shift value in
|
// Shift value in
|
||||||
if (width <= 8) {
|
if (width <= 8) {
|
||||||
|
|
@ -1637,7 +1637,7 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
|
||||||
|
|
||||||
// Final checks
|
// Final checks
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (VL_UNLIKELY(end != VL_UL(0xffffffff) && addr != (end + 1))) {
|
if (VL_UNLIKELY(end != ~VL_ULL(0) && addr != (end + 1))) {
|
||||||
VL_FATAL_MT(filename.c_str(), linenum, "",
|
VL_FATAL_MT(filename.c_str(), linenum, "",
|
||||||
"$readmem file ended before specified ending-address");
|
"$readmem file ended before specified ending-address");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -630,20 +630,20 @@ extern void VL_FCLOSE_I(IData fdi);
|
||||||
extern IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
extern IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||||
void* memp, IData fpi, IData start, IData count);
|
void* memp, IData fpi, IData start, IData count);
|
||||||
|
|
||||||
extern void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
extern void VL_READMEM_W(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
WDataInP filenamep, void* memp, IData start, IData end);
|
WDataInP filenamep, void* memp, QData start, QData end);
|
||||||
extern void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int fnwords,
|
extern void VL_READMEM_Q(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
QData filename, void* memp, IData start, IData end);
|
QData filename, void* memp, QData start, QData end);
|
||||||
inline void VL_READMEM_I(bool hex, int width, int depth, int array_lsb, int fnwords,
|
inline void VL_READMEM_I(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
IData filename, void* memp, IData start, IData end) VL_MT_SAFE {
|
IData filename, void* memp, QData start, QData end) VL_MT_SAFE {
|
||||||
VL_READMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
VL_READMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
||||||
|
|
||||||
extern void VL_WRITEMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
extern void VL_WRITEMEM_W(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
WDataInP filenamep, const void* memp, IData start, IData end);
|
WDataInP filenamep, const void* memp, QData start, QData end);
|
||||||
extern void VL_WRITEMEM_Q(bool hex, int width, int depth, int array_lsb, int fnwords,
|
extern void VL_WRITEMEM_Q(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
QData filename, const void* memp, IData start, IData end);
|
QData filename, const void* memp, QData start, QData end);
|
||||||
inline void VL_WRITEMEM_I(bool hex, int width, int depth, int array_lsb, int fnwords,
|
inline void VL_WRITEMEM_I(bool hex, int width, QData depth, int array_lsb, int fnwords,
|
||||||
IData filename, const void* memp, IData start, IData end) VL_MT_SAFE {
|
IData filename, const void* memp, QData start, QData end) VL_MT_SAFE {
|
||||||
VL_WRITEMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
VL_WRITEMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
||||||
|
|
||||||
extern void VL_WRITEF(const char* formatp, ...);
|
extern void VL_WRITEF(const char* formatp, ...);
|
||||||
|
|
|
||||||
|
|
@ -312,12 +312,12 @@ extern std::string VL_TOLOWER_NN(const std::string& ld);
|
||||||
extern std::string VL_TOUPPER_NN(const std::string& ld);
|
extern std::string VL_TOUPPER_NN(const std::string& ld);
|
||||||
|
|
||||||
extern IData VL_FOPEN_NI(const std::string& filename, IData mode) VL_MT_SAFE;
|
extern IData VL_FOPEN_NI(const std::string& filename, IData mode) VL_MT_SAFE;
|
||||||
extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb,
|
extern void VL_READMEM_N(bool hex, int width, QData depth, int array_lsb,
|
||||||
const std::string& filename,
|
const std::string& filename,
|
||||||
void* memp, IData start, IData end) VL_MT_SAFE;
|
void* memp, QData start, QData end) VL_MT_SAFE;
|
||||||
extern void VL_WRITEMEM_N(bool hex, int width, int depth, int array_lsb,
|
extern void VL_WRITEMEM_N(bool hex, int width, QData depth, int array_lsb,
|
||||||
const std::string& filename,
|
const std::string& filename,
|
||||||
const void* memp, IData start, IData end) VL_MT_SAFE;
|
const void* memp, QData start, QData end) VL_MT_SAFE;
|
||||||
extern IData VL_SSCANF_INX(int lbits, const std::string& ld,
|
extern IData VL_SSCANF_INX(int lbits, const std::string& ld,
|
||||||
const char* formatp, ...) VL_MT_SAFE;
|
const char* formatp, ...) VL_MT_SAFE;
|
||||||
extern void VL_SFORMAT_X(int obits_ignored, std::string& output,
|
extern void VL_SFORMAT_X(int obits_ignored, std::string& output,
|
||||||
|
|
|
||||||
|
|
@ -428,9 +428,11 @@ public:
|
||||||
iterateAndNextNull(nodep->filenamep());
|
iterateAndNextNull(nodep->filenamep());
|
||||||
putbs(", ");
|
putbs(", ");
|
||||||
iterateAndNextNull(nodep->memp());
|
iterateAndNextNull(nodep->memp());
|
||||||
putbs(","); if (nodep->lsbp()) { iterateAndNextNull(nodep->lsbp()); }
|
putbs(",");
|
||||||
|
if (nodep->lsbp()) { iterateAndNextNull(nodep->lsbp()); }
|
||||||
else puts(cvtToStr(array_lsb));
|
else puts(cvtToStr(array_lsb));
|
||||||
putbs(","); if (nodep->msbp()) { iterateAndNextNull(nodep->msbp()); } else puts("~0");
|
putbs(",");
|
||||||
|
if (nodep->msbp()) { iterateAndNextNull(nodep->msbp()); } else puts("~VL_ULL(0)");
|
||||||
puts(");\n");
|
puts(");\n");
|
||||||
}
|
}
|
||||||
virtual void visit(AstFClose* nodep) {
|
virtual void visit(AstFClose* nodep) {
|
||||||
|
|
@ -438,7 +440,7 @@ public:
|
||||||
iterateAndNextNull(nodep->filep());
|
iterateAndNextNull(nodep->filep());
|
||||||
puts("); ");
|
puts("); ");
|
||||||
iterateAndNextNull(nodep->filep()); // For safety, so user doesn't later WRITE with it.
|
iterateAndNextNull(nodep->filep()); // For safety, so user doesn't later WRITE with it.
|
||||||
puts("=0;\n");
|
puts(" = 0;\n");
|
||||||
}
|
}
|
||||||
virtual void visit(AstFFlush* nodep) {
|
virtual void visit(AstFFlush* nodep) {
|
||||||
if (!nodep->filep()) {
|
if (!nodep->filep()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue