Suppress width warnings between constant strings and wider vectors.

This commit is contained in:
Wilson Snyder 2008-09-22 19:36:08 -04:00
parent daf7f42138
commit f197dd29cb
6 changed files with 53 additions and 0 deletions

View File

@ -3,6 +3,11 @@ Revision history for Verilator
The contributors that suggested a given feature are shown in []. [by ...]
indicates the contributor was also the author of the fix; Thanks!
* Verilator 3.67**
*** Suppress width warnings between constant strings and wider vectors.
[Rodney Sinclair]
* Verilator 3.671 2008/09/19
** SystemC uint64_t pins are now the default instead of sc_bv<64>.

View File

@ -45,6 +45,7 @@ void V3Number::init (FileLine* fileline, int swidth) {
m_fileline = fileline;
m_signed = false;
m_autoExtend = false;
m_fromString = false;
width(swidth);
for (int i=0; i<words(); i++) m_value[i]=m_valueX[i] = 0;
}
@ -52,6 +53,7 @@ void V3Number::init (FileLine* fileline, int swidth) {
V3Number::V3Number(VerilogString, FileLine* fileline, const string& str) {
// Create a number using a verilog string as the value, thus 8 bits per character.
init(fileline, str.length()*8);
m_fromString = true;
for (unsigned pos=0; pos<str.length(); ++pos) {
int topos = str.length()-1-pos;
for (int bit=0; bit<8; ++bit) {

View File

@ -34,6 +34,7 @@ class V3Number {
int m_width; // Width as specified/calculated.
bool m_sized:1; // True if the user specified the width, else we track it.
bool m_signed:1; // True if signed value
bool m_fromString:1; // True if from string
bool m_autoExtend:1; // True if SystemVerilog extend-to-any-width
FileLine* m_fileline;
vector<uint32_t> m_value; // The Value, with bit 0 being in bit 0 of this vector (unless X/Z)
@ -124,6 +125,7 @@ public:
int minWidth() const; // Minimum width that can represent this number (~== log2(num)+1)
bool sized() const { return m_sized; }
bool autoExtend() const { return m_autoExtend; }
bool isFromString() const { return m_fromString; }
bool isSigned() const { return m_signed; } // Only correct for parsing of numbers from strings, otherwise not used (use AstConst::isSigned())
bool isNegative() const { return bitIs1(width()-1); }
bool isFourState() const { for (int i=0;i<words();i++) {if (m_valueX[i]) return true;} return false; }

View File

@ -911,6 +911,13 @@ void WidthVisitor::widthCheck (AstNode* nodep, const char* side,
if (expWidthMin==0) expWidthMin = expWidth;
bool bad = widthBad(underp,expWidth,expWidthMin);
if (bad && fixAutoExtend(underp/*ref*/,expWidth)) bad=false; // Changes underp
if (underp->castConst() && underp->castConst()->num().isFromString()
&& expWidth > underp->width()
&& (((expWidth - underp->width()) % 8) == 0)) { // At least it's character sized
// reg [31:0] == "foo" we'll consider probably fine.
// Maybe this should be a special warning? Not for now.
ignoreWarn = true;
}
if (bad && !ignoreWarn) {
if (debug()>4) nodep->backp()->dumpTree(cout," back: ");
nodep->v3warn(WIDTH,"Operator "<<nodep->typeName()

View File

@ -0,0 +1,18 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("./driver.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003-2007 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# General Public License or the Perl Artistic License.
compile (
v_flags2 => [],
);
execute (
check_finished=>1,
);
ok(1);
1;

View File

@ -0,0 +1,19 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2008-2008 by Wilson Snyder.
module t (/*AUTOARG*/);
reg [4*8:1] strg;
initial begin
strg = "CHK";
if (strg != "CHK") $stop;
if (strg == "JOE") $stop;
$write("String = %s = %x\n", strg, strg);
$write("*-* All Finished *-*\n");
$finish;
end
endmodule