Internals: Cleanup of InitArray stuff. No functional change intended.
This commit is contained in:
parent
748fa4cb80
commit
9a722ccf62
|
|
@ -1344,7 +1344,7 @@ void AstIfaceRefDType::dumpSmall(std::ostream& str) const {
|
||||||
void AstInitArray::dump(std::ostream& str) const {
|
void AstInitArray::dump(std::ostream& str) const {
|
||||||
this->AstNode::dump(str);
|
this->AstNode::dump(str);
|
||||||
int n = 0;
|
int n = 0;
|
||||||
const AstInitArray::KeyItemMap& mapr = map();
|
const auto& mapr = map();
|
||||||
for (const auto& itr : mapr) {
|
for (const auto& itr : mapr) {
|
||||||
if (n++ > 5) {
|
if (n++ > 5) {
|
||||||
str << " ...";
|
str << " ...";
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,15 @@ class EmitCConstInit VL_NOT_FINAL : public EmitCBaseVisitor {
|
||||||
// METHODS
|
// METHODS
|
||||||
VL_DEBUG_FUNC; // Declare debug()
|
VL_DEBUG_FUNC; // Declare debug()
|
||||||
|
|
||||||
|
uint32_t tabModulus(AstNodeDType* dtypep) {
|
||||||
|
const uint32_t elemBytes = dtypep->widthTotalBytes();
|
||||||
|
return dtypep->isString() ? 1 // String
|
||||||
|
: elemBytes <= 2 ? 8 // CData, SData
|
||||||
|
: elemBytes <= 4 ? 4 // IData
|
||||||
|
: elemBytes <= 8 ? 2 // QData
|
||||||
|
: 1;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// VISITORS
|
// VISITORS
|
||||||
virtual void visit(AstInitArray* nodep) override {
|
virtual void visit(AstInitArray* nodep) override {
|
||||||
|
|
@ -41,12 +50,7 @@ protected:
|
||||||
= VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
= VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
||||||
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
|
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
|
||||||
const uint32_t size = dtypep->elementsConst();
|
const uint32_t size = dtypep->elementsConst();
|
||||||
const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes();
|
const uint32_t tabMod = tabModulus(dtypep->subDTypep());
|
||||||
const uint32_t tabMod = dtypep->subDTypep()->isString() ? 1 // String
|
|
||||||
: elemBytes <= 2 ? 8 // CData, SData
|
|
||||||
: elemBytes <= 4 ? 4 // IData
|
|
||||||
: elemBytes <= 8 ? 2 // QData
|
|
||||||
: 1;
|
|
||||||
VL_RESTORER(m_inUnpacked);
|
VL_RESTORER(m_inUnpacked);
|
||||||
VL_RESTORER(m_unpackedWord);
|
VL_RESTORER(m_unpackedWord);
|
||||||
m_inUnpacked = true;
|
m_inUnpacked = true;
|
||||||
|
|
|
||||||
|
|
@ -629,7 +629,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) {
|
||||||
emitSetVarConstant(varNameProtected + "[__Vi]", VN_AS(initarp->defaultp(), Const));
|
emitSetVarConstant(varNameProtected + "[__Vi]", VN_AS(initarp->defaultp(), Const));
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
}
|
}
|
||||||
const AstInitArray::KeyItemMap& mapr = initarp->map();
|
const auto& mapr = initarp->map();
|
||||||
for (const auto& itr : mapr) {
|
for (const auto& itr : mapr) {
|
||||||
AstNode* const valuep = itr.second->valuep();
|
AstNode* const valuep = itr.second->valuep();
|
||||||
emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]",
|
emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]",
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
||||||
virtual void visit(AstInitArray* nodep) override {
|
virtual void visit(AstInitArray* nodep) override {
|
||||||
putfs(nodep, "'{");
|
putfs(nodep, "'{");
|
||||||
int comma = 0;
|
int comma = 0;
|
||||||
const AstInitArray::KeyItemMap& mapr = nodep->map();
|
const auto& mapr = nodep->map();
|
||||||
for (const auto& itr : mapr) {
|
for (const auto& itr : mapr) {
|
||||||
if (comma++) putbs(", ");
|
if (comma++) putbs(", ");
|
||||||
puts(cvtToStr(itr.first));
|
puts(cvtToStr(itr.first));
|
||||||
|
|
|
||||||
|
|
@ -163,12 +163,12 @@ class EmitXmlFileVisitor final : public AstNVisitor {
|
||||||
}
|
}
|
||||||
virtual void visit(AstInitArray* nodep) override {
|
virtual void visit(AstInitArray* nodep) override {
|
||||||
puts("<initarray>\n");
|
puts("<initarray>\n");
|
||||||
const AstInitArray::KeyItemMap& map = nodep->map();
|
const auto& mapr = nodep->map();
|
||||||
for (AstInitArray::KeyItemMap::const_iterator it = map.begin(); it != map.end(); ++it) {
|
for (const auto& itr : mapr) {
|
||||||
puts("<inititem index=\"");
|
puts("<inititem index=\"");
|
||||||
puts(cvtToStr(it->first));
|
puts(cvtToStr(itr.first));
|
||||||
puts("\">\n");
|
puts("\">\n");
|
||||||
iterateChildren(it->second);
|
iterateChildren(itr.second);
|
||||||
puts("</inititem>\n");
|
puts("</inititem>\n");
|
||||||
}
|
}
|
||||||
puts("</initarray>\n");
|
puts("</initarray>\n");
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ module t (/*AUTOARG*/
|
||||||
else if (cyc==20) begin
|
else if (cyc==20) begin
|
||||||
e <= 'h11; // Unknown
|
e <= 'h11; // Unknown
|
||||||
end
|
end
|
||||||
else if (cyc==20) begin
|
else if (cyc==21) begin
|
||||||
`checks(e.name, ""); // Unknown
|
`checks(e.name, ""); // Unknown
|
||||||
end
|
end
|
||||||
else if (cyc==99) begin
|
else if (cyc==99) begin
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue