mirror of
https://github.com/verilator/verilator.git
synced 2025-05-03 22:16:53 +00:00
Internals: Use dtype functions; changes to integer to match spec
This commit is contained in:
parent
f1546abf09
commit
7caafb4014
@ -29,6 +29,7 @@
|
||||
#include "V3Global.h"
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
|
||||
#include "V3Ast__gen_classes.h" // From ./astgen
|
||||
// Things like:
|
||||
@ -934,8 +935,11 @@ public:
|
||||
bool isAllOnesV(); // Verilog width rules apply
|
||||
|
||||
// METHODS - data type changes especially for initial creation
|
||||
void dtypeChgBool() { numeric(AstNumeric::UNSIGNED); width(1,1); }
|
||||
void dtypeChgLogicBool() { numeric(AstNumeric::UNSIGNED); width(1,1); }
|
||||
void dtypeChgDouble() { numeric(AstNumeric::DOUBLE); }
|
||||
void dtypeChgSigned32() { numeric(AstNumeric::SIGNED); width(VL_WORDSIZE,VL_WORDSIZE); }
|
||||
void dtypeChgUInt32() { numeric(AstNumeric::UNSIGNED); width(VL_WORDSIZE,VL_WORDSIZE); }
|
||||
void dtypeChgUInt64() { numeric(AstNumeric::UNSIGNED); width(VL_QUADSIZE,VL_QUADSIZE); }
|
||||
|
||||
// METHODS - dump and error
|
||||
void v3errorEnd(ostringstream& str) const;
|
||||
@ -1319,6 +1323,7 @@ struct AstNodeDType : public AstNode {
|
||||
AstNodeDType(FileLine* fl) : AstNode(fl) {}
|
||||
ASTNODE_BASE_FUNCS(NodeDType)
|
||||
// Accessors
|
||||
virtual void dump(ostream& str);
|
||||
virtual AstBasicDType* basicp() const = 0; // (Slow) recurse down to find basic data type
|
||||
virtual AstNodeDType* skipRefp() const = 0; // recurses over typedefs to next non-typeref type
|
||||
virtual int widthAlignBytes() const = 0; // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this)
|
||||
|
@ -510,7 +510,7 @@ void AstNode::dump(ostream& os) {
|
||||
}
|
||||
|
||||
void AstArrayDType::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
this->AstNodeDType::dump(str);
|
||||
if (isPacked()) str<<" [PACKED]";
|
||||
}
|
||||
void AstArraySel::dump(ostream& str) {
|
||||
@ -522,7 +522,7 @@ void AstAttrOf::dump(ostream& str) {
|
||||
str<<" ["<<attrType().ascii()<<"]";
|
||||
}
|
||||
void AstBasicDType::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
this->AstNodeDType::dump(str);
|
||||
str<<" ["<<keyword().ascii()<<"]";
|
||||
if (implicit()) str<<" [IMPLICIT]";
|
||||
}
|
||||
@ -566,7 +566,7 @@ void AstRange::dump(ostream& str) {
|
||||
if (littleEndian()) str<<" [LITTLE]";
|
||||
}
|
||||
void AstRefDType::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
this->AstNodeDType::dump(str);
|
||||
if (defp()) { str<<" -> "; defp()->dump(str); }
|
||||
else { str<<" -> UNLINKED"; }
|
||||
}
|
||||
@ -580,6 +580,9 @@ void AstVarXRef::dump(ostream& str) {
|
||||
else if (varp()) { varp()->dump(str); }
|
||||
else { str<<"UNLINKED"; }
|
||||
}
|
||||
void AstNodeDType::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
}
|
||||
void AstNodeModule::dump(ostream& str) {
|
||||
this->AstNode::dump(str);
|
||||
str<<" L"<<level();
|
||||
|
@ -301,6 +301,7 @@ public:
|
||||
virtual int widthTotalBytes() const; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,...
|
||||
AstBasicDTypeKwd keyword() const { return m_keyword; } // Avoid using - use isSomething accessors instead
|
||||
bool isBitLogic() const { return keyword().isBitLogic(); }
|
||||
bool isDouble() const { return keyword().isDouble(); }
|
||||
bool isOpaque() const { return keyword().isOpaque(); }
|
||||
bool isSloppy() const { return keyword().isSloppy(); }
|
||||
bool isZeroInit() const { return keyword().isZeroInit(); }
|
||||
@ -445,14 +446,17 @@ struct AstArraySel : public AstNodeSel {
|
||||
private:
|
||||
unsigned m_start;
|
||||
unsigned m_length;
|
||||
void init(AstNode* fromp) {
|
||||
if (fromp) widthSignedFrom(fromp);
|
||||
}
|
||||
public:
|
||||
AstArraySel(FileLine* fl, AstNode* fromp, AstNode* bitp)
|
||||
:AstNodeSel(fl, fromp, bitp), m_start(0), m_length(1) {
|
||||
if (fromp) widthSignedFrom(fromp);
|
||||
init(fromp);
|
||||
}
|
||||
AstArraySel(FileLine* fl, AstNode* fromp, int bit)
|
||||
:AstNodeSel(fl, fromp, new AstConst(fl,bit)), m_start(0), m_length(1) {
|
||||
if (fromp) widthSignedFrom(fromp);
|
||||
init(fromp);
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(ArraySel, ARRAYSEL)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) {
|
||||
@ -1301,7 +1305,7 @@ struct AstSenGate : public AstNodeSenItem {
|
||||
// AND as applied to a sensitivity list and a gating expression
|
||||
// Performing this gating is optional; it may be removed by later optimizations
|
||||
AstSenGate(FileLine* fl, AstSenItem* sensesp, AstNode* rhsp) : AstNodeSenItem(fl) {
|
||||
dtypeChgBool(); addOp1p(sensesp); setOp2p(rhsp);
|
||||
dtypeChgLogicBool(); addOp1p(sensesp); setOp2p(rhsp);
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(SenGate, SENGATE)
|
||||
virtual string emitVerilog() { return "(%l) %f&& (%r)"; }
|
||||
@ -2197,7 +2201,8 @@ struct AstChangeXor : public AstNodeBiComAsv {
|
||||
// Children: VARREF
|
||||
AstChangeXor(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
|
||||
: AstNodeBiComAsv(fl, lhsp, rhsp) {
|
||||
width(32,32); }
|
||||
dtypeChgUInt32(); // Always used on, and returns word entities
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(ChangeXor, CHANGEXOR)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opChangeXor(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f^ %r)"; }
|
||||
@ -2455,7 +2460,7 @@ private:
|
||||
bool m_dpiExport; // Is for dpiExport
|
||||
public:
|
||||
AstScopeName(FileLine* fl) : AstNodeMath(fl), m_dpiExport(false) {
|
||||
width(64,64); }
|
||||
dtypeChgUInt64(); }
|
||||
ASTNODE_NODE_FUNCS(ScopeName, SCOPENAME)
|
||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||
virtual bool same(AstNode* samep) const { return m_dpiExport==samep->castScopeName()->m_dpiExport; }
|
||||
@ -2516,7 +2521,7 @@ public:
|
||||
|
||||
struct AstTime : public AstNodeTermop {
|
||||
AstTime(FileLine* fl) : AstNodeTermop(fl) {
|
||||
width(64,64); }
|
||||
dtypeChgUInt64(); }
|
||||
ASTNODE_NODE_FUNCS(Time, TIME)
|
||||
virtual string emitVerilog() { return "%f$time"; }
|
||||
virtual string emitC() { return "VL_TIME_%nq()"; }
|
||||
@ -2592,7 +2597,7 @@ struct AstNegateD : public AstNodeUniop {
|
||||
};
|
||||
struct AstRedAnd : public AstNodeUniop {
|
||||
AstRedAnd(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(RedAnd, REDAND)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRedAnd(lhs); }
|
||||
virtual string emitVerilog() { return "%f(& %l)"; }
|
||||
@ -2602,7 +2607,7 @@ struct AstRedAnd : public AstNodeUniop {
|
||||
};
|
||||
struct AstRedOr : public AstNodeUniop {
|
||||
AstRedOr(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(RedOr, REDOR)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRedOr(lhs); }
|
||||
virtual string emitVerilog() { return "%f(| %l)"; }
|
||||
@ -2612,7 +2617,7 @@ struct AstRedOr : public AstNodeUniop {
|
||||
};
|
||||
struct AstRedXor : public AstNodeUniop {
|
||||
AstRedXor(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(RedXor, REDXOR)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRedXor(lhs); }
|
||||
virtual string emitVerilog() { return "%f(^ %l)"; }
|
||||
@ -2626,7 +2631,7 @@ struct AstRedXor : public AstNodeUniop {
|
||||
struct AstRedXnor : public AstNodeUniop {
|
||||
// AstRedXnors are replaced with AstRedXors in V3Const.
|
||||
AstRedXnor(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(RedXnor, REDXNOR)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRedXnor(lhs); }
|
||||
virtual string emitVerilog() { return "%f(~^ %l)"; }
|
||||
@ -2638,7 +2643,7 @@ struct AstRedXnor : public AstNodeUniop {
|
||||
|
||||
struct AstLogNot : public AstNodeUniop {
|
||||
AstLogNot(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LogNot, LOGNOT)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opLogNot(lhs); }
|
||||
virtual string emitVerilog() { return "%f(! %l)"; }
|
||||
@ -2710,7 +2715,7 @@ struct AstUnsigned : public AstNodeUniop {
|
||||
struct AstRToIS : public AstNodeUniop {
|
||||
// $rtoi(lhs)
|
||||
AstRToIS(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
width(32,32); }
|
||||
dtypeChgSigned32(); }
|
||||
ASTNODE_NODE_FUNCS(RToIS, RTOIS)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRToIS(lhs); }
|
||||
virtual string emitVerilog() { return "%f$rtoi(%l)"; }
|
||||
@ -2721,7 +2726,7 @@ struct AstRToIS : public AstNodeUniop {
|
||||
};
|
||||
struct AstRToIRoundS : public AstNodeUniop {
|
||||
AstRToIRoundS(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
width(32,32); }
|
||||
dtypeChgSigned32(); }
|
||||
ASTNODE_NODE_FUNCS(RToIRoundS, RTOIROUNDS)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRToIRoundS(lhs); }
|
||||
virtual string emitVerilog() { return "%f$rtoi_rounded(%l)"; }
|
||||
@ -2743,7 +2748,7 @@ struct AstIToRD : public AstNodeUniop {
|
||||
};
|
||||
struct AstRealToBits : public AstNodeUniop {
|
||||
AstRealToBits(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
width(64,64); }
|
||||
dtypeChgUInt64(); }
|
||||
ASTNODE_NODE_FUNCS(RealToBits, REALTOBITS)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opRealToBits(lhs); }
|
||||
virtual string emitVerilog() { return "%f$realtobits(%l)"; }
|
||||
@ -2788,7 +2793,7 @@ struct AstCountOnes : public AstNodeUniop {
|
||||
struct AstIsUnknown : public AstNodeUniop {
|
||||
// True if any unknown bits
|
||||
AstIsUnknown(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(IsUnknown, ISUNKNOWN)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opIsUnknown(lhs); }
|
||||
virtual string emitVerilog() { return "%f$isunknown(%l)"; }
|
||||
@ -2799,7 +2804,7 @@ struct AstIsUnknown : public AstNodeUniop {
|
||||
struct AstOneHot : public AstNodeUniop {
|
||||
// True if only single bit set in vector
|
||||
AstOneHot(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(OneHot, ONEHOT)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opOneHot(lhs); }
|
||||
virtual string emitVerilog() { return "%f$onehot(%l)"; }
|
||||
@ -2811,7 +2816,7 @@ struct AstOneHot : public AstNodeUniop {
|
||||
struct AstOneHot0 : public AstNodeUniop {
|
||||
// True if only single bit, or no bits set in vector
|
||||
AstOneHot0(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(OneHot0, ONEHOT0)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opOneHot0(lhs); }
|
||||
virtual string emitVerilog() { return "%f$onehot0(%l)"; }
|
||||
@ -2865,7 +2870,7 @@ public:
|
||||
struct AstCvtPackString : public AstNodeUniop {
|
||||
// Convert to Verilator Packed Pack (aka Pack)
|
||||
AstCvtPackString(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) {
|
||||
width(64,64); } // Really, width should be dtypep -> STRING
|
||||
dtypeChgUInt64(); } // Really, width should be dtypep -> STRING
|
||||
ASTNODE_NODE_FUNCS(CvtPackString, CVTPACKSTRING)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) { V3ERROR_NA; }
|
||||
virtual string emitVerilog() { return "%f$_CAST(%l)"; }
|
||||
@ -2990,7 +2995,7 @@ struct AstSqrtD : public AstNodeUniop {
|
||||
|
||||
struct AstLogOr : public AstNodeBiop {
|
||||
AstLogOr(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LogOr, LOGOR)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLogOr(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f|| %r)"; }
|
||||
@ -3003,7 +3008,7 @@ struct AstLogOr : public AstNodeBiop {
|
||||
};
|
||||
struct AstLogAnd : public AstNodeBiop {
|
||||
AstLogAnd(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LogAnd, LOGAND)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLogAnd(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f&& %r)"; }
|
||||
@ -3016,7 +3021,7 @@ struct AstLogAnd : public AstNodeBiop {
|
||||
};
|
||||
struct AstLogIf : public AstNodeBiop {
|
||||
AstLogIf(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LogIf, LOGIF)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { V3ERROR_NA; }
|
||||
virtual string emitVerilog() { return "%k(%l %f-> %r)"; }
|
||||
@ -3029,7 +3034,7 @@ struct AstLogIf : public AstNodeBiop {
|
||||
};
|
||||
struct AstLogIff : public AstNodeBiCom {
|
||||
AstLogIff(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LogIff, LOGIFF)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { V3ERROR_NA; }
|
||||
virtual string emitVerilog() { return "%k(%l %f<-> %r)"; }
|
||||
@ -3090,7 +3095,7 @@ struct AstXnor : public AstNodeBiComAsv {
|
||||
};
|
||||
struct AstEq : public AstNodeBiCom {
|
||||
AstEq(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Eq, EQ)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opEq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f== %r)"; }
|
||||
@ -3102,7 +3107,7 @@ struct AstEq : public AstNodeBiCom {
|
||||
};
|
||||
struct AstEqD : public AstNodeBiCom {
|
||||
AstEqD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(EqD, EQD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opEqD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f== %r)"; }
|
||||
@ -3116,7 +3121,7 @@ struct AstEqD : public AstNodeBiCom {
|
||||
};
|
||||
struct AstNeq : public AstNodeBiCom {
|
||||
AstNeq(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Neq, NEQ)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opNeq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f!= %r)"; }
|
||||
@ -3128,7 +3133,7 @@ struct AstNeq : public AstNodeBiCom {
|
||||
};
|
||||
struct AstNeqD : public AstNodeBiCom {
|
||||
AstNeqD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(NeqD, NEQD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opNeqD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f!= %r)"; }
|
||||
@ -3142,7 +3147,7 @@ struct AstNeqD : public AstNodeBiCom {
|
||||
};
|
||||
struct AstLt : public AstNodeBiop {
|
||||
AstLt(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Lt, LT)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLt(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f< %r)"; }
|
||||
@ -3154,7 +3159,7 @@ struct AstLt : public AstNodeBiop {
|
||||
};
|
||||
struct AstLtD : public AstNodeBiop {
|
||||
AstLtD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LtD, LTD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLtD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f< %r)"; }
|
||||
@ -3168,7 +3173,7 @@ struct AstLtD : public AstNodeBiop {
|
||||
};
|
||||
struct AstLtS : public AstNodeBiop {
|
||||
AstLtS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LtS, LTS)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLtS(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f< %r)"; }
|
||||
@ -3181,7 +3186,7 @@ struct AstLtS : public AstNodeBiop {
|
||||
};
|
||||
struct AstGt : public AstNodeBiop {
|
||||
AstGt(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Gt, GT)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGt(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f> %r)"; }
|
||||
@ -3193,7 +3198,7 @@ struct AstGt : public AstNodeBiop {
|
||||
};
|
||||
struct AstGtD : public AstNodeBiop {
|
||||
AstGtD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(GtD, GTD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGtD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f> %r)"; }
|
||||
@ -3207,7 +3212,7 @@ struct AstGtD : public AstNodeBiop {
|
||||
};
|
||||
struct AstGtS : public AstNodeBiop {
|
||||
AstGtS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(GtS, GTS)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGtS(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f> %r)"; }
|
||||
@ -3220,7 +3225,7 @@ struct AstGtS : public AstNodeBiop {
|
||||
};
|
||||
struct AstGte : public AstNodeBiop {
|
||||
AstGte(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Gte, GTE)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGte(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f>= %r)"; }
|
||||
@ -3232,7 +3237,7 @@ struct AstGte : public AstNodeBiop {
|
||||
};
|
||||
struct AstGteD : public AstNodeBiop {
|
||||
AstGteD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(GteD, GTED)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGteD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f>= %r)"; }
|
||||
@ -3246,7 +3251,7 @@ struct AstGteD : public AstNodeBiop {
|
||||
};
|
||||
struct AstGteS : public AstNodeBiop {
|
||||
AstGteS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(GteS, GTES)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opGteS(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f>= %r)"; }
|
||||
@ -3259,7 +3264,7 @@ struct AstGteS : public AstNodeBiop {
|
||||
};
|
||||
struct AstLte : public AstNodeBiop {
|
||||
AstLte(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(Lte, LTE)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLte(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f<= %r)"; }
|
||||
@ -3271,7 +3276,7 @@ struct AstLte : public AstNodeBiop {
|
||||
};
|
||||
struct AstLteD : public AstNodeBiop {
|
||||
AstLteD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LteD, LTED)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLteD(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f<= %r)"; }
|
||||
@ -3285,7 +3290,7 @@ struct AstLteD : public AstNodeBiop {
|
||||
};
|
||||
struct AstLteS : public AstNodeBiop {
|
||||
AstLteS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(LteS, LTES)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opLteS(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f<= %r)"; }
|
||||
@ -3536,7 +3541,7 @@ struct AstPowS : public AstNodeBiop {
|
||||
};
|
||||
struct AstEqCase : public AstNodeBiCom {
|
||||
AstEqCase(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(EqCase, EQCASE)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opCaseEq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f=== %r)"; }
|
||||
@ -3548,7 +3553,7 @@ struct AstEqCase : public AstNodeBiCom {
|
||||
};
|
||||
struct AstNeqCase : public AstNodeBiCom {
|
||||
AstNeqCase(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiCom(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(NeqCase, NEQCASE)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opCaseNeq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f!== %r)"; }
|
||||
@ -3561,7 +3566,7 @@ struct AstNeqCase : public AstNodeBiCom {
|
||||
struct AstEqWild : public AstNodeBiop {
|
||||
// Note wildcard operator rhs differs from lhs
|
||||
AstEqWild(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(EqWild, EQWILD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opWildEq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f==? %r)"; }
|
||||
@ -3573,7 +3578,7 @@ struct AstEqWild : public AstNodeBiop {
|
||||
};
|
||||
struct AstNeqWild : public AstNodeBiop {
|
||||
AstNeqWild(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) {
|
||||
dtypeChgBool(); }
|
||||
dtypeChgLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(NeqWild, NEQWILD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opWildNeq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f!=? %r)"; }
|
||||
|
@ -240,10 +240,10 @@ private:
|
||||
virtual void visit(AstRealToBits* nodep, AstNUser* vup) { visit_Ou64_Lr(nodep,vup); }
|
||||
|
||||
// Widths: Constant, terminal
|
||||
virtual void visit(AstTime* nodep, AstNUser*) { nodep->numeric(AstNumeric::UNSIGNED); nodep->width(64,64); }
|
||||
virtual void visit(AstTime* nodep, AstNUser*) { nodep->dtypeChgUInt64(); }
|
||||
virtual void visit(AstTimeD* nodep, AstNUser*) { nodep->dtypeChgDouble(); }
|
||||
virtual void visit(AstTestPlusArgs* nodep, AstNUser*) { nodep->numeric(AstNumeric::UNSIGNED); nodep->width(32,32); }
|
||||
virtual void visit(AstScopeName* nodep, AstNUser* vup) { nodep->width(64,1); } // A pointer, but not that it matters
|
||||
virtual void visit(AstTestPlusArgs* nodep, AstNUser*) { nodep->dtypeChgSigned32(); }
|
||||
virtual void visit(AstScopeName* nodep, AstNUser* vup) { nodep->dtypeChgUInt64(); } // A pointer, but not that it matters
|
||||
|
||||
// Special cases. So many....
|
||||
virtual void visit(AstNodeCond* nodep, AstNUser* vup) {
|
||||
@ -280,7 +280,7 @@ private:
|
||||
nodep->expr1p()->iterateAndNext(*this,WidthVP(width,mwidth,FINAL).p());
|
||||
nodep->expr2p()->iterateAndNext(*this,WidthVP(width,mwidth,FINAL).p());
|
||||
// Error report and change sizes for suboperands of this node.
|
||||
widthCheckReduce(nodep,"Conditional Expression",nodep->condp(),1,0);
|
||||
widthCheckReduce(nodep,"Conditional Test",nodep->condp(),1,0);
|
||||
widthCheck(nodep,"Conditional True",nodep->expr1p(),width,mwidth);
|
||||
widthCheck(nodep,"Conditional False",nodep->expr2p(),width,mwidth);
|
||||
}
|
||||
@ -377,7 +377,7 @@ private:
|
||||
AstConst* widthConstp = nodep->widthp()->castConst();
|
||||
if (!widthConstp) {
|
||||
nodep->v3error("Width of bit extract isn't a constant");
|
||||
nodep->dtypeChgBool(); return;
|
||||
nodep->dtypeChgLogicBool(); return;
|
||||
}
|
||||
int width = nodep->widthConst();
|
||||
nodep->width(width,width);
|
||||
@ -537,8 +537,7 @@ private:
|
||||
}
|
||||
virtual void visit(AstRand* nodep, AstNUser* vup) {
|
||||
if (vup->c()->prelim()) {
|
||||
nodep->numeric(AstNumeric::SIGNED); // Says the spec
|
||||
nodep->width(32,32); // Says the spec
|
||||
nodep->dtypeChgSigned32(); // Says the spec
|
||||
}
|
||||
}
|
||||
virtual void visit(AstUCFunc* nodep, AstNUser* vup) {
|
||||
@ -558,8 +557,7 @@ private:
|
||||
if (vup->c()->prelim()) {
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
checkCvtUS(nodep->lhsp());
|
||||
nodep->numeric(AstNumeric::UNSIGNED); // If want otherwise use a dpi import
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32();
|
||||
}
|
||||
}
|
||||
virtual void visit(AstPow* nodep, AstNUser* vup) {
|
||||
@ -829,7 +827,7 @@ private:
|
||||
widthCheckReduce(nodep,"Disable",nodep->disablep(),1,1); // it's like an if() condition.
|
||||
}
|
||||
widthCheckReduce(nodep,"Property",nodep->propp(),1,1); // it's like an if() condition.
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
}
|
||||
|
||||
//--------------------
|
||||
@ -1017,7 +1015,7 @@ private:
|
||||
nodep->filep()->iterateAndNext(*this,WidthVP(32,32,BOTH).p());
|
||||
nodep->strgp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
if (vup->c()->prelim()) {
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32(); // Spec says integer return
|
||||
}
|
||||
widthCheck(nodep,"file_descriptor",nodep->filep(),32,32);
|
||||
}
|
||||
@ -1025,7 +1023,7 @@ private:
|
||||
nodep->filep()->iterateAndNext(*this,WidthVP(32,32,BOTH).p());
|
||||
nodep->exprsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
if (vup->c()->prelim()) {
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32(); // Spec says integer return
|
||||
}
|
||||
widthCheck(nodep,"file_descriptor",nodep->filep(),32,32);
|
||||
}
|
||||
@ -1033,7 +1031,7 @@ private:
|
||||
nodep->fromp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
nodep->exprsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
if (vup->c()->prelim()) {
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32(); // Spec says integer return
|
||||
}
|
||||
}
|
||||
virtual void visit(AstSysIgnore* nodep, AstNUser* vup) {
|
||||
@ -1041,8 +1039,7 @@ private:
|
||||
}
|
||||
virtual void visit(AstSystemF* nodep, AstNUser*) {
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
nodep->numeric(AstNumeric::UNSIGNED);
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32(); // Spec says integer return
|
||||
}
|
||||
virtual void visit(AstSystemT* nodep, AstNUser*) {
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
@ -1055,8 +1052,7 @@ private:
|
||||
}
|
||||
virtual void visit(AstValuePlusArgs* nodep, AstNUser* vup) {
|
||||
nodep->exprsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
nodep->numeric(AstNumeric::UNSIGNED);
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32(); // Spec says integer return
|
||||
}
|
||||
virtual void visit(AstUCStmt* nodep, AstNUser*) {
|
||||
// TOP LEVEL NODE
|
||||
@ -1165,7 +1161,7 @@ private:
|
||||
UINFO(5," FTASK "<<nodep<<endl);
|
||||
if (nodep->doingWidth()) {
|
||||
nodep->v3error("Unsupported: Recursive function or task call");
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
nodep->didWidth(true);
|
||||
return;
|
||||
}
|
||||
@ -1320,8 +1316,7 @@ private:
|
||||
if (vup->c()->prelim()) { // First stage evaluation
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
checkCvtD(nodep->lhsp());
|
||||
nodep->numeric(AstNumeric::SIGNED);
|
||||
nodep->width(32,32);
|
||||
nodep->dtypeChgSigned32();
|
||||
}
|
||||
}
|
||||
void visit_Ou64_Lr(AstNodeUniop* nodep, AstNUser* vup) {
|
||||
@ -1330,8 +1325,7 @@ private:
|
||||
if (vup->c()->prelim()) { // First stage evaluation
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
checkCvtD(nodep->lhsp());
|
||||
nodep->numeric(AstNumeric::UNSIGNED);
|
||||
nodep->width(64,64);
|
||||
nodep->dtypeChgUInt64();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1348,7 +1342,7 @@ private:
|
||||
nodep->op1p()->iterateAndNext(*this,WidthVP(1,0,BOTH).p());
|
||||
spliceCvtCmpD0(nodep->op1p());
|
||||
}
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
if (vup->c()->final()) {
|
||||
widthCheckReduce(nodep,"LHS",nodep->op1p(),1,1);
|
||||
}
|
||||
@ -1362,7 +1356,7 @@ private:
|
||||
spliceCvtCmpD0(nodep->lhsp());
|
||||
spliceCvtCmpD0(nodep->rhsp());
|
||||
}
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
if (vup->c()->final()) {
|
||||
widthCheckReduce(nodep,"LHS",nodep->lhsp(),1,1);
|
||||
widthCheckReduce(nodep,"RHS",nodep->rhsp(),1,1);
|
||||
@ -1377,7 +1371,7 @@ private:
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||
}
|
||||
if (!realok) checkCvtUS(nodep->lhsp());
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
}
|
||||
void visit_cmp_O1_DSreplace(AstNodeBiop* nodep, AstNUser* vup) {
|
||||
// CALLER: AstEq, AstGt, ..., AstLtS
|
||||
@ -1403,7 +1397,7 @@ private:
|
||||
}
|
||||
int width = max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
int ewidth = max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
if (vup->c()->final()) {
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(width,ewidth,FINAL).p());
|
||||
nodep->rhsp()->iterateAndNext(*this,WidthVP(width,ewidth,FINAL).p());
|
||||
@ -1431,7 +1425,7 @@ private:
|
||||
}
|
||||
int width = max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
int ewidth = max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
nodep->dtypeChgBool();
|
||||
nodep->dtypeChgLogicBool();
|
||||
if (vup->c()->final()) {
|
||||
nodep->lhsp()->iterateAndNext(*this,WidthVP(width,ewidth,FINAL).p());
|
||||
nodep->rhsp()->iterateAndNext(*this,WidthVP(width,ewidth,FINAL).p());
|
||||
|
@ -110,13 +110,13 @@ private:
|
||||
} else if (rhs > 0) {
|
||||
AstNode* newp = new AstSub(lhsp->fileline(), lhsp,
|
||||
new AstConst(lhsp->fileline(), AstConst::Unsized32(), rhs));
|
||||
// We must make sure sub gets sign of original value
|
||||
// We must make sure sub gets sign of original value, not from the constant
|
||||
newp->numericFrom(lhsp);
|
||||
return newp;
|
||||
} else { // rhs < 0;
|
||||
AstNode* newp = new AstAdd(lhsp->fileline(), lhsp,
|
||||
new AstConst(lhsp->fileline(), AstConst::Unsized32(), -rhs));
|
||||
// We must make sure sub gets sign of original value
|
||||
// We must make sure sub gets sign of original value, not from the constant
|
||||
newp->numericFrom(lhsp);
|
||||
return newp;
|
||||
}
|
||||
|
@ -94,7 +94,11 @@ V3Global v3Global;
|
||||
//######################################################################
|
||||
// V3 Class -- top level
|
||||
|
||||
AstNetlist* V3Global::makeNetlist() { return new AstNetlist(); }
|
||||
AstNetlist* V3Global::makeNetlist() {
|
||||
AstNetlist* newp = new AstNetlist();
|
||||
return newp;
|
||||
}
|
||||
|
||||
void V3Global::checkTree() { rootp()->checkTree(); }
|
||||
|
||||
void V3Global::clear() {
|
||||
|
Loading…
Reference in New Issue
Block a user