Fix misc string handling issues.

This commit is contained in:
Wilson Snyder 2014-11-28 20:24:42 -05:00
parent 2e5f5010f7
commit ce4dfb4296
4 changed files with 10 additions and 6 deletions

View File

@ -2219,6 +2219,7 @@ private:
TREEOPV("AstExtend {$lhsp.castExtend}", "replaceExtend(nodep, nodep->lhsp()->castExtend()->lhsp())");
TREEOPV("AstExtendS{$lhsp.castExtendS}", "replaceExtend(nodep, nodep->lhsp()->castExtendS()->lhsp())");
TREEOPV("AstReplicate{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs
TREEOPV("AstReplicateN{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs
// Next rule because AUTOINST puts the width of bits in
// to pins, even when the widths are exactly the same across the hierarchy.
TREEOPV("AstSel{operandSelExtend(nodep)}", "DONE");

View File

@ -1392,9 +1392,6 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
if (varp->isIO() && modp->isTop() && optSystemC()) {
// System C top I/O doesn't need loading, as the lower level subinst code does it.
}
else if (varp->basicp() && varp->basicp()->keyword() == AstBasicDTypeKwd::STRING) {
// Constructor deals with it
}
else if (varp->isParam()) {
if (!varp->valuep()) nodep->v3fatalSrc("No init for a param?");
// If a simple CONST value we initialize it using an enum
@ -1413,6 +1410,9 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
varp->v3fatalSrc("InitArray under non-arrayed var");
}
}
else if (varp->basicp() && varp->basicp()->keyword() == AstBasicDTypeKwd::STRING) {
// Constructor deals with it
}
else {
int vects = 0;
// This isn't very robust and may need cleanup for other data types

View File

@ -708,7 +708,9 @@ private:
// However a later operation may have changed the node->signed w/o changing
// the number's sign. So we don't: nodep->dtypeChgSigned(nodep->num().isSigned());
if (vup && vup->c()->prelim()) {
if (nodep->num().sized()) {
if (nodep->num().isString()) {
nodep->dtypeSetString();
} else if (nodep->num().sized()) {
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().width());
} else {
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().widthMin());

View File

@ -72,8 +72,9 @@ class WidthCommitVisitor : public AstNVisitor {
public:
// METHODS
static AstConst* newIfConstCommitSize (AstConst* nodep) {
if ((nodep->dtypep()->width() != nodep->num().width())
|| !nodep->num().sized()) { // Need to force the number rrom unsized to sized
if (((nodep->dtypep()->width() != nodep->num().width())
|| !nodep->num().sized())
&& !nodep->num().isString()) { // Need to force the number rrom unsized to sized
V3Number num (nodep->fileline(), nodep->dtypep()->width());
num.opAssign(nodep->num());
num.isSigned(nodep->isSigned());