From fff0ebb5f3d2af30d02ea7dbcfc9e8128b001475 Mon Sep 17 00:00:00 2001 From: Glen Gibb Date: Thu, 10 Apr 2014 17:54:52 -0400 Subject: [PATCH] Internals: Add AstReplicate dtype init. Signed-off-by: Wilson Snyder --- src/V3AstNodes.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 6b8173b7d..501d8f498 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -4158,14 +4158,20 @@ struct AstConcat : public AstNodeBiop { virtual int instrCount() const { return widthInstrs()*2; } }; struct AstReplicate : public AstNodeBiop { - // Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp() - AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : AstNodeBiop(fl, lhsp, rhsp) { - if (AstConst* constp=rhsp->castConst()) { - dtypeSetLogicSized(lhsp->width()*constp->toUInt(), lhsp->width()*constp->toUInt(), AstNumeric::UNSIGNED); +private: + void init() { + if (lhsp()) { + if (AstConst* constp=rhsp()->castConst()) { + dtypeSetLogicSized(lhsp()->width()*constp->toUInt(), lhsp()->width()*constp->toUInt(), AstNumeric::UNSIGNED); + } } } +public: + // Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp() + AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp) + : AstNodeBiop(fl, lhsp, rhsp) { init(); } AstReplicate(FileLine* fl, AstNode* lhsp, uint32_t repCount) - : AstNodeBiop(fl, lhsp, new AstConst(fl, repCount)) {} + : AstNodeBiop(fl, lhsp, new AstConst(fl, repCount)) { init(); } ASTNODE_NODE_FUNCS(Replicate, REPLICATE) virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opRepl(lhs,rhs); } virtual string emitVerilog() { return "%f{%r{%k%l}}"; }