From 02f3beb8dbfb059b234a52c46d906da45fe4bbe0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 30 Mar 2011 21:31:29 -0400 Subject: [PATCH] Add V3Number rotate functions; unused as yet --- bin/verilator | 2 +- src/V3Inline.cpp | 2 +- src/V3Number.cpp | 35 ++++++++++++++++++++++++++++++++++- src/V3Number.h | 3 +++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/bin/verilator b/bin/verilator index 9ca26cae8..d8f9b631e 100755 --- a/bin/verilator +++ b/bin/verilator @@ -617,7 +617,7 @@ appropriate `begin_keywords. Specify the extensions that should be used for finding modules. If for example module I is referenced, look in I.I. Note +libext+ is -fairly standard across Verilog tools. +fairly standard across Verilog tools. Defaults to .v and .sv. =item --lint-only diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 73111ae34..60f2fa4f4 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -184,7 +184,7 @@ private: // user2p is either a const or a var. AstConst* exprconstp = nodep->user2p()->castNode()->castConst(); AstVarRef* exprvarrefp = nodep->user2p()->castNode()->castVarRef(); - UINFO(1,"connectto: "<user2p()->castNode()<user2p()->castNode()<v3fatalSrc("Unknown interconnect type; pinReconnectSimple should have cleared up\n"); } diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 49443e7c1..83f5de8e4 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -1011,6 +1011,30 @@ V3Number& V3Number::opLteS (const V3Number& lhs, const V3Number& rhs) { return opGteS(rhs,lhs); } +V3Number& V3Number::opRotR (const V3Number& lhs, const V3Number& rhs) { + // L(lhs) bit return + if (rhs.isFourState()) return setAllBitsX(); + setZero(); + uint32_t rhsval = rhs.toUInt(); + for (int bit=0; bitwidth(); bit++) { + setBit(bit,lhs.bitIs((bit + rhsval) % this->width())); + } + return *this; +} + +V3Number& V3Number::opRotL (const V3Number& lhs, const V3Number& rhs) { + // L(lhs) bit return + if (rhs.isFourState()) return setAllBitsX(); + setZero(); + uint32_t rhsval = rhs.toUInt(); + for (int bit=0; bitwidth(); bit++) { + if (bit >= (int)rhsval) { + setBit(bit,lhs.bitIs((bit - rhsval) % this->width())); + } + } + return *this; +} + V3Number& V3Number::opShiftR (const V3Number& lhs, const V3Number& rhs) { // L(lhs) bit return if (rhs.isFourState()) return setAllBitsX(); @@ -1038,8 +1062,8 @@ V3Number& V3Number::opShiftRS (const V3Number& lhs, const V3Number& rhs) { V3Number& V3Number::opShiftL (const V3Number& lhs, const V3Number& rhs) { // L(lhs) bit return if (rhs.isFourState()) return setAllBitsX(); - uint32_t rhsval = rhs.toUInt(); setZero(); + uint32_t rhsval = rhs.toUInt(); for (int bit=0; bitwidth(); bit++) { if (bit >= (int)rhsval) { setBit(bit,lhs.bitIs(bit - rhsval)); @@ -1051,6 +1075,15 @@ V3Number& V3Number::opShiftL (const V3Number& lhs, const V3Number& rhs) { //====================================================================== // Ops - Arithmetic +V3Number& V3Number::opAbsS (const V3Number& lhs) { + // op i, L(lhs) bit return + if (lhs.isFourState()) return setAllBitsX(); + if (lhs.isNegative()) { + return opUnaryMin(lhs); + } else { + return opAssign(lhs); + } +} V3Number& V3Number::opUnaryMin (const V3Number& lhs) { // op i, L(lhs) bit return if (lhs.isFourState()) return setAllBitsX(); diff --git a/src/V3Number.h b/src/V3Number.h index c0175b78f..138e752a5 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -202,6 +202,7 @@ public: V3Number& opLogNot (const V3Number& lhs); V3Number& opLogAnd (const V3Number& lhs, const V3Number& rhs); V3Number& opLogOr (const V3Number& lhs, const V3Number& rhs); + V3Number& opAbsS (const V3Number& lhs); V3Number& opUnaryMin(const V3Number& lhs); V3Number& opAdd (const V3Number& lhs, const V3Number& rhs); V3Number& opSub (const V3Number& lhs, const V3Number& rhs); @@ -218,6 +219,8 @@ public: V3Number& opXor (const V3Number& lhs, const V3Number& rhs); V3Number& opXnor (const V3Number& lhs, const V3Number& rhs); V3Number& opOr (const V3Number& lhs, const V3Number& rhs); + V3Number& opRotR (const V3Number& lhs, const V3Number& rhs); + V3Number& opRotL (const V3Number& lhs, const V3Number& rhs); V3Number& opShiftR (const V3Number& lhs, const V3Number& rhs); V3Number& opShiftRS (const V3Number& lhs, const V3Number& rhs); // Arithmetic w/carry V3Number& opShiftL (const V3Number& lhs, const V3Number& rhs);