From 817039157387b2d0d4d68e5ec35eca00a22e1edc Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 28 Nov 2018 19:59:10 -0500 Subject: [PATCH] Internals: Fix spacing of comments. No functional change. --- bin/verilator | 18 +- bin/verilator_coverage | 8 +- bin/verilator_difftree | 18 +- bin/verilator_gantt | 4 +- bin/verilator_profcfunc | 6 +- include/verilated.cpp | 386 +++++++++++++------------- include/verilated.h | 224 +++++++-------- include/verilated.v | 2 +- include/verilated_cov.cpp | 20 +- include/verilated_cov.h | 6 +- include/verilated_cov_key.h | 2 +- include/verilated_dpi.cpp | 24 +- include/verilated_dpi.h | 4 +- include/verilated_heavy.h | 4 +- include/verilated_imp.h | 24 +- include/verilated_lxt2_c.cpp | 6 +- include/verilated_lxt2_c.h | 8 +- include/verilated_save.cpp | 21 +- include/verilated_save.h | 2 +- include/verilated_sc.h | 4 +- include/verilated_sym_props.h | 4 +- include/verilated_syms.h | 4 +- include/verilated_unordered_set_map.h | 8 +- include/verilated_vcd_c.h | 2 +- include/verilated_vpi.cpp | 112 ++++---- include/verilated_vpi.h | 5 +- include/verilatedos.h | 40 +-- nodist/dot_importer | 6 +- nodist/dot_pruner | 6 +- nodist/git_untabify | 4 +- nodist/install_test | 4 +- nodist/vtree_importer | 6 +- 32 files changed, 499 insertions(+), 493 deletions(-) diff --git a/bin/verilator b/bin/verilator index c343f45f1..c8cfc041b 100755 --- a/bin/verilator +++ b/bin/verilator @@ -30,7 +30,7 @@ use IO::File; use Pod::Usage; use strict; -use vars qw ($Debug @Opt_Verilator_Sw); +use vars qw($Debug @Opt_Verilator_Sw); ####################################################################### ####################################################################### @@ -57,7 +57,7 @@ foreach my $sw (@ARGV) { push @Opt_Verilator_Sw, $sw; } -Getopt::Long::config ("no_auto_abbrev","pass_through"); +Getopt::Long::config("no_auto_abbrev","pass_through"); if (! GetOptions ( # Major operating modes "help" => \&usage, @@ -108,7 +108,7 @@ if ($opt_gdb) { ." -ex 'bt'"); } else { # Normal, non gdb - run (verilator_bin()." ".join(' ',@quoted_sw)); + run(verilator_bin()." ".join(' ',@quoted_sw)); } #---------------------------------------------------------------------- @@ -3784,7 +3784,7 @@ expression as the next statement. For example: task foo; output sig; ... endtask always @* begin - foo(bus_we_select_from[2]); // Will get TASKNSVAR error + foo(bus_we_select_from[2]); // Will get TASKNSVAR error end Change this to: @@ -4152,12 +4152,12 @@ trace file if you want all data to land in the same output file. ... Verilated::traceEverOn(true); VerilatedVcdC* tfp = new VerilatedVcdC; - topp->trace (tfp, 99); - tfp->open ("obj_dir/t_trace_ena_cc/simx.vcd"); + topp->trace(tfp, 99); + tfp->open("obj_dir/t_trace_ena_cc/simx.vcd"); ... while (sc_time_stamp() < sim_time && !Verilated::gotFinish()) { main_time += #; - tfp->dump (main_time); + tfp->dump(main_time); } tfp->close(); } @@ -4188,8 +4188,8 @@ trace file if you want all data to land in the same output file. ... Verilated::traceEverOn(true); VerilatedVcdSc* tfp = new VerilatedVcdSc; - topp->trace (tfp, 99); - tfp->open ("obj_dir/t_trace_ena_cc/simx.vcd"); + topp->trace(tfp, 99); + tfp->open("obj_dir/t_trace_ena_cc/simx.vcd"); ... sc_start(1); ... diff --git a/bin/verilator_coverage b/bin/verilator_coverage index 4263827dc..de5a902ae 100755 --- a/bin/verilator_coverage +++ b/bin/verilator_coverage @@ -31,7 +31,7 @@ use Pod::Usage; use Cwd qw(abs_path getcwd); use strict; -use vars qw ($Debug @Opt_Verilator_Sw); +use vars qw($Debug @Opt_Verilator_Sw); ####################################################################### ####################################################################### @@ -54,7 +54,7 @@ foreach my $sw (@ARGV) { push @Opt_Verilator_Sw, $sw; } -Getopt::Long::config ("no_auto_abbrev","pass_through"); +Getopt::Long::config("no_auto_abbrev","pass_through"); if (! GetOptions ( # Major operating modes "help" => \&usage, @@ -67,8 +67,8 @@ if (! GetOptions ( } # Normal, non gdb -run (verilator_coverage_bin() - ." ".join(' ',@Opt_Verilator_Sw)); +run(verilator_coverage_bin() + ." ".join(' ',@Opt_Verilator_Sw)); #---------------------------------------------------------------------- diff --git a/bin/verilator_difftree b/bin/verilator_difftree index e687f6292..301929e18 100755 --- a/bin/verilator_difftree +++ b/bin/verilator_difftree @@ -10,7 +10,7 @@ use Getopt::Long; use IO::File; use Pod::Usage; use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== @@ -37,7 +37,7 @@ my $Opt_B; my $Opt_Lineno = 1; autoflush STDOUT 1; autoflush STDERR 1; -Getopt::Long::config ("no_auto_abbrev"); +Getopt::Long::config("no_auto_abbrev"); if (! GetOptions ( "help" => \&usage, "debug" => \&debug, @@ -54,9 +54,9 @@ defined $Opt_B or die "%Error: No new diff filename\n"; -e $Opt_B or die "%Error: No new diff filename found: $Opt_B\n"; if (-d $Opt_A && -d $Opt_B) { - diff_dir ($Opt_A, $Opt_B); + diff_dir($Opt_A, $Opt_B); } elsif (-f $Opt_A && -f $Opt_B) { - diff_file ($Opt_A, $Opt_B); + diff_file($Opt_A, $Opt_B); } else { die "%Error: Mix of files and dirs\n"; } @@ -85,8 +85,8 @@ sub diff_dir { diff_file($a,$b); $any = 1; } - $any or warn ("%Warning: No .tree files found that have similar base names:\n " - .join("\n ", sort keys %files),"\n"); + $any or warn("%Warning: No .tree files found that have similar base names:\n " + .join("\n ", sort keys %files),"\n"); } sub diff_file { @@ -103,8 +103,8 @@ sub diff_file { my $verCvt = (($vera < 0x3900 && $verb >= 0x3900) || ($vera >= 0x3900 && $verb < 0x3900)); - filter ($a, $tmp_a, $verCvt); - filter ($b, $tmp_b, $verCvt); + filter($a, $tmp_a, $verCvt); + filter($b, $tmp_b, $verCvt); system("diff -u $tmp_a $tmp_b"); unlink $tmp_a; unlink $tmp_b; @@ -169,7 +169,7 @@ sub filter { sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub debug { diff --git a/bin/verilator_gantt b/bin/verilator_gantt index aeb55a8c0..47c699bcc 100755 --- a/bin/verilator_gantt +++ b/bin/verilator_gantt @@ -9,7 +9,7 @@ use warnings; use Getopt::Long; use IO::File; use Pod::Usage; -use vars qw ($Debug); +use vars qw($Debug); $Debug = 0; my $Opt_File; @@ -44,7 +44,7 @@ exit(0); sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub parameter { diff --git a/bin/verilator_profcfunc b/bin/verilator_profcfunc index 60f785291..a65f1b3de 100755 --- a/bin/verilator_profcfunc +++ b/bin/verilator_profcfunc @@ -11,7 +11,7 @@ use IO::File; use Pod::Usage; eval { use Data::Dumper; $Data::Dumper::Indent = 1; }; # Debug, ok if missing use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== @@ -23,7 +23,7 @@ $Debug = 0; my $Opt_File; autoflush STDOUT 1; autoflush STDERR 1; -Getopt::Long::config ("no_auto_abbrev"); +Getopt::Long::config("no_auto_abbrev"); if (! GetOptions ( "help" => \&usage, "debug" => \&debug, @@ -40,7 +40,7 @@ profcfunc($Opt_File); sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub debug { diff --git a/include/verilated.cpp b/include/verilated.cpp index 95631a5d8..08e5675ea 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -37,7 +37,7 @@ # include // mkdir #endif -#define VL_VALUE_STRING_MAX_WIDTH 8192 ///< Max static char array for VL_VALUE_STRING +#define VL_VALUE_STRING_MAX_WIDTH 8192 ///< Max static char array for VL_VALUE_STRING //=========================================================================== // Global variables @@ -58,7 +58,7 @@ VerilatedImp VerilatedImp::s_s; //=========================================================================== // User definable functions -#ifndef VL_USER_FINISH // Define this to override this function +#ifndef VL_USER_FINISH ///< Define this to override this function void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE { if (0 && hier) {} VL_PRINTF("- %s:%d: Verilog $finish\n", filename, linenum); // Not VL_PRINTF_MT, already on main thread @@ -71,7 +71,7 @@ void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE } #endif -#ifndef VL_USER_STOP // Define this to override this function +#ifndef VL_USER_STOP ///< Define this to override this function void vl_stop(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE { Verilated::gotFinish(true); Verilated::flushCall(); @@ -79,7 +79,7 @@ void vl_stop(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE { } #endif -#ifndef VL_USER_FATAL // Define this to override this function +#ifndef VL_USER_FATAL ///< Define this to override this function void vl_fatal(const char* filename, int linenum, const char* hier, const char* msg) VL_MT_UNSAFE { if (0 && hier) {} Verilated::gotFinish(true); @@ -158,7 +158,7 @@ vluint64_t _vl_dbg_sequence_number() VL_MT_SAFE { vluint32_t VL_THREAD_ID() VL_MT_SAFE { #ifdef VL_THREADED // Alternative is to use std::this_thread::get_id, but that returns a hard-to-read number and is very slow - static std::atomic s_nextId (0); + static std::atomic s_nextId(0); static VL_THREAD_LOCAL vluint32_t t_myId = ++s_nextId; return t_myId; #else @@ -202,7 +202,7 @@ Verilated::Serialized::Serialized() { s_calcUnusedSigs = false; s_gotFinish = false; s_assertOn = true; - s_fatalOnVpiError = true; // retains old default behaviour + s_fatalOnVpiError = true; // retains old default behaviour } Verilated::NonSerialized::NonSerialized() { @@ -277,8 +277,8 @@ WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp) VL_MT_SAFE { IData VL_RAND_RESET_I(int obits) VL_MT_SAFE { if (Verilated::randReset()==0) return 0; IData data = ~0; - if (Verilated::randReset()!=1) { // if 2, randomize - data = VL_RANDOM_I(obits); + if (Verilated::randReset()!=1) { // if 2, randomize + data = VL_RANDOM_I(obits); } if (obits<32) data &= VL_MASK_I(obits); return data; @@ -286,8 +286,8 @@ IData VL_RAND_RESET_I(int obits) VL_MT_SAFE { QData VL_RAND_RESET_Q(int obits) VL_MT_SAFE { if (Verilated::randReset()==0) return 0; QData data = VL_ULL(~0); - if (Verilated::randReset()!=1) { // if 2, randomize - data = VL_RANDOM_Q(obits); + if (Verilated::randReset()!=1) { // if 2, randomize + data = VL_RANDOM_Q(obits); } if (obits<64) data &= VL_MASK_Q(obits); return data; @@ -328,10 +328,10 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, WDataInP lwp, WDataInP rwp, boo int words = VL_WORDS_I(lbits); for (int i=0; i> VL_ULL(32)) - (t >> VL_ULL(32)); } t = un[j+vw] - k; - un[j+vw] = t; - owp[j] = qhat; // Save quotient digit + un[j+vw] = t; + owp[j] = qhat; // Save quotient digit if (t < 0) { // Over subtracted; correct by adding back @@ -417,14 +417,14 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, WDataInP lwp, WDataInP rwp, boo } } - if (is_modulus) { // modulus - // Need to reverse normalization on copy to output - for (int i=0; i> s) | (shift_mask & (un[i+1] << (32-s))); - } - for (int i=vw; i> s) | (shift_mask & (un[i+1] << (32-s))); + } + for (int i=vw; i0; lsb-=4) { // Skip leading zeros + for (; lsb>0; lsb-=4) { // Skip leading zeros if (VL_BITRSHIFT_W(bcd, lsb) & 0xf) break; } for (; lsb>=0; lsb-=4) { @@ -572,17 +572,17 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA pctp = pos; inPct = true; widthSet = false; - width = 0; - } else if (!inPct) { // Normal text - // Fast-forward to next escape and add to output - const char *ep = pos; - while (ep[0] && ep[0]!='%') ep++; - if (ep != pos) { - output.append(pos, ep-pos); - pos += ep-pos-1; - } - } else { // Format character - inPct = false; + width = 0; + } else if (!inPct) { // Normal text + // Fast-forward to next escape and add to output + const char *ep = pos; + while (ep[0] && ep[0]!='%') ep++; + if (ep != pos) { + output.append(pos, ep-pos); + pos += ep-pos-1; + } + } else { // Format character + inPct = false; char fmt = pos[0]; switch (fmt) { case '0': case '1': case '2': case '3': case '4': @@ -597,17 +597,17 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA case '%': output += '%'; break; - case 'N': { // "C" string with name of module, add . if needed - const char* cstrp = va_arg(ap, const char*); - if (VL_LIKELY(*cstrp)) { output += cstrp; output += '.'; } - break; - } - case 'S': { // "C" string - const char* cstrp = va_arg(ap, const char*); - output += cstrp; - break; - } - case '@': { // Verilog/C++ string + case 'N': { // "C" string with name of module, add . if needed + const char* cstrp = va_arg(ap, const char*); + if (VL_LIKELY(*cstrp)) { output += cstrp; output += '.'; } + break; + } + case 'S': { // "C" string + const char* cstrp = va_arg(ap, const char*); + output += cstrp; + break; + } + case '@': { // Verilog/C++ string va_arg(ap, int); // # bits is ignored const std::string* cstrp = va_arg(ap, const std::string*); output += *cstrp; @@ -649,12 +649,12 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } case 's': for (; lsb>=0; --lsb) { - lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; - output += (charval==0)?' ':charval; - } - break; - case 'd': { // Signed decimal + lsb = (lsb / 8) * 8; // Next digit + IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; + output += (charval==0)?' ':charval; + } + break; + case 'd': { // Signed decimal int digits; std::string append; if (lbits <= VL_QUADSIZE) { @@ -673,16 +673,16 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } int needmore = width-digits; if (needmore>0) { - if (pctp && pctp[0] && pctp[1]=='0') { //%0 - output.append(needmore,'0'); // Pre-pad zero - } else { - output.append(needmore,' '); // Pre-pad spaces - } - } - output += append; - break; - } - case '#': { // Unsigned decimal + if (pctp && pctp[0] && pctp[1]=='0') { // %0 + output.append(needmore, '0'); // Pre-pad zero + } else { + output.append(needmore, ' '); // Pre-pad spaces + } + } + output += append; + break; + } + case '#': { // Unsigned decimal int digits; std::string append; if (lbits <= VL_QUADSIZE) { @@ -694,16 +694,16 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } int needmore = width-digits; if (needmore>0) { - if (pctp && pctp[0] && pctp[1]=='0') { //%0 - output.append(needmore,'0'); // Pre-pad zero - } else { - output.append(needmore,' '); // Pre-pad spaces - } - } - output += append; - break; - } - case 't': { // Time + if (pctp && pctp[0] && pctp[1]=='0') { // %0 + output.append(needmore, '0'); // Pre-pad zero + } else { + output.append(needmore, ' '); // Pre-pad spaces + } + } + output += append; + break; + } + case 't': { // Time int digits; if (VL_TIME_MULTIPLIER==1) { digits=sprintf(tmp,"%" VL_PRI64 "u",ld); @@ -714,9 +714,9 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } else { VL_FATAL_MT(__FILE__,__LINE__,"","Unsupported VL_TIME_MULTIPLIER"); } - int needmore = width-digits; - if (needmore>0) output.append(needmore,' '); // Pre-pad spaces - output += tmp; + int needmore = width-digits; + if (needmore>0) output.append(needmore, ' '); // Pre-pad spaces + output += tmp; break; } case 'b': @@ -725,9 +725,9 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } break; case 'o': - for (; lsb>=0; --lsb) { - lsb = (lsb / 3) * 3; // Next digit - // Octal numbers may span more than one wide word, + for (; lsb>=0; --lsb) { + lsb = (lsb / 3) * 3; // Next digit + // Octal numbers may span more than one wide word, // so we need to grab each bit separately and check for overrun // Octal is rare, so we'll do it a slow simple way output += ('0' @@ -752,19 +752,19 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA output += static_cast((lwp[i] >> 8) & 0xff); output += static_cast((lwp[i] >> 16) & 0xff); output += static_cast((lwp[i] >> 24) & 0xff); - output += "\0\0\0\0"; // No tristate - } - break; - case 'v': // Strength; assume always strong - for (lsb=lbits-1; lsb>=0; --lsb) { + output += "\0\0\0\0"; // No tristate + } + break; + case 'v': // Strength; assume always strong + for (lsb=lbits-1; lsb>=0; --lsb) { if (VL_BITRSHIFT_W(lwp, lsb) & 1) output += "St1 "; else output += "St0 "; - } - break; - case 'x': - for (; lsb>=0; --lsb) { - lsb = (lsb / 4) * 4; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; + } + break; + case 'x': + for (; lsb>=0; --lsb) { + lsb = (lsb / 4) * 4; // Next digit + IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; output += "0123456789abcdef"[charval]; } break; @@ -772,10 +772,10 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA std::string msg = std::string("Unknown _vl_vsformat code: ")+pos[0]; VL_FATAL_MT(__FILE__,__LINE__,"",msg.c_str()); break; - } // switch - } - } // switch - } + } // switch + } + } // switch + } } } @@ -795,9 +795,9 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp, const std: ungetc(data,fp); return data; } else { - if (floc < 0) return EOF; - floc = floc & ~7; // Align to closest character - if (fromp == NULL) { + if (floc < 0) return EOF; + floc = floc & ~7; // Align to closest character + if (fromp == NULL) { return fstr[fstr.length()-1 - (floc>>3)]; } else { return VL_BITRSHIFT_W(fromp, floc) & 0xff; @@ -818,9 +818,9 @@ static inline void _vl_vsss_read(FILE* fp, int& floc, WDataInP fromp, const std: while (1) { int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c==EOF || isspace(c)) break; - if (acceptp!=NULL // String - allow anything - && NULL==strchr(acceptp, c)) break; - if (acceptp!=NULL) c = tolower(c); // Non-strings we'll simplify + if (acceptp // String - allow anything + && NULL==strchr(acceptp, c)) break; + if (acceptp) c = tolower(c); // Non-strings we'll simplify *cp++ = c; _vl_vsss_advance(fp, floc); } @@ -837,9 +837,9 @@ static inline void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, // Read in base "2^^baseLog2" digits from strp[posstart..posend-1] into owp of size obits. int lsb = 0; for (int i=0, pos=static_cast(posend)-1; i=static_cast(posstart); --pos) { - switch (tolower (strp[pos])) { - case 'x': case 'z': case '?': //FALLTHRU - case '0': lsb += baseLog2; break; + switch (tolower (strp[pos])) { + case 'x': case 'z': case '?': // FALLTHRU + case '0': lsb += baseLog2; break; case '1': _vl_vsss_setbit(owp,obits,lsb, baseLog2, 1); lsb+=baseLog2; break; case '2': _vl_vsss_setbit(owp,obits,lsb, baseLog2, 2); lsb+=baseLog2; break; case '3': _vl_vsss_setbit(owp,obits,lsb, baseLog2, 3); lsb+=baseLog2; break; @@ -876,15 +876,15 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf //VL_DBG_MSGF("_vlscan fmt='"<=0; --lsb) { - lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; - if (!start || charval) { - *destp++ = (charval==0)?' ':charval; - start = false; // Drop leading 0s - } + lsb = (lsb / 8) * 8; // Next digit + IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; + if (!start || charval) { + *destp++ = (charval==0)?' ':charval; + start = false; // Drop leading 0s + } } - *destp = '\0'; // Terminate + *destp = '\0'; // Terminate // Drop trailing spaces if (!start) while (isspace(*(destp-1)) && destp>destoutp) *--destp = '\0'; } @@ -1277,15 +1277,15 @@ const char* memhFormat(int nBits) { } void VL_WRITEMEM_N( - bool hex, // Hex format, else binary - int width, // Width of each array row - int depth, // Number of rows + bool hex, // Hex format, else binary + int width, // Width of each array row + int depth, // Number of rows int array_lsb, // Index of first row. Valid row addresses // // range from array_lsb up to (array_lsb + depth - 1) const std::string& filename, // Output file name const void* memp, // Array state - IData start, // First array row address to write - IData end // Last address to write + IData start, // First array row address to write + IData end // Last address to write ) VL_MT_SAFE { if (VL_UNLIKELY(!hex)) { VL_FATAL_MT(filename.c_str(), 0, "", @@ -1381,15 +1381,15 @@ void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords, } void VL_READMEM_N( - bool hex, // Hex format, else binary - int width, // Width of each array row - int depth, // Number of rows + bool hex, // Hex format, else binary + int width, // Width of each array row + int depth, // Number of rows int array_lsb, // Index of first row. Valid row addresses // // range from array_lsb up to (array_lsb + depth - 1) const std::string& filename, // Input file name - void* memp, // Array state - IData start, // First array row address to read - IData end // Last row address to read + void* memp, // Array state + IData start, // First array row address to read + IData end // Last row address to read ) VL_MT_SAFE { FILE* fp = fopen(filename.c_str(), "r"); if (VL_UNLIKELY(!fp)) { @@ -1519,9 +1519,9 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M for (const char* posp = ld.c_str(); !done && *posp; ++posp) { if (!inPct && posp[0]=='%') { inPct = true; - } else if (!inPct) { // Normal text - prefix += *posp; - } else { // Format character + } else if (!inPct) { // Normal text + prefix += *posp; + } else { // Format character switch (tolower(*posp)) { case '%': prefix += *posp; @@ -1552,18 +1552,18 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M case 'o': _vl_vsss_based(rwp,rbits, 3, dp, 0, strlen(dp)); break; - case 'h': //FALLTHRU + case 'h': // FALLTHRU case 'x': - _vl_vsss_based(rwp,rbits, 4, dp, 0, strlen(dp)); - break; - case 's': // string/no conversion - for (int i=0, lsb=0, posp=static_cast(strlen(dp))-1; i=0; --posp) { - _vl_vsss_setbit(rwp,rbits,lsb, 8, dp[posp]); lsb+=8; - } - break; - case 'e': //FALLTHRU - Unsupported - case 'f': //FALLTHRU - Unsupported - case 'g': //FALLTHRU - Unsupported + _vl_vsss_based(rwp,rbits, 4, dp, 0, strlen(dp)); + break; + case 's': // string/no conversion + for (int i=0, lsb=0, posp=static_cast(strlen(dp))-1; i=0; --posp) { + _vl_vsss_setbit(rwp,rbits,lsb, 8, dp[posp]); lsb+=8; + } + break; + case 'e': // FALLTHRU - Unsupported + case 'f': // FALLTHRU - Unsupported + case 'g': // FALLTHRU - Unsupported default: // Other simulators simply return 0 in these cases and don't error out return 0; } @@ -1577,9 +1577,9 @@ IData VL_VALUEPLUSARGS_INN(int, const std::string& ld, std::string& rdr) VL_MT_S for (const char* posp = ld.c_str(); !done && *posp; ++posp) { if (!inPct && posp[0]=='%') { inPct = true; - } else if (!inPct) { // Normal text - prefix += *posp; - } else { // Format character + } else if (!inPct) { // Normal text + prefix += *posp; + } else { // Format character switch (tolower(*posp)) { case '%': prefix += *posp; @@ -1602,8 +1602,8 @@ const char* vl_mc_scan_plusargs(const char* prefixp) VL_MT_SAFE { const std::string& match = VerilatedImp::argPlusMatch(prefixp); static VL_THREAD_LOCAL char outstr[VL_VALUE_STRING_MAX_WIDTH]; if (match.empty()) return NULL; - strncpy(outstr, match.c_str()+strlen(prefixp)+1, // +1 to skip the "+" - VL_VALUE_STRING_MAX_WIDTH); + strncpy(outstr, match.c_str()+strlen(prefixp)+1, // +1 to skip the "+" + VL_VALUE_STRING_MAX_WIDTH); outstr[VL_VALUE_STRING_MAX_WIDTH-1] = '\0'; return outstr; } @@ -1620,13 +1620,13 @@ std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) VL_MT_SAFE { char* destp = destout; int len = 0; for (; lsb>=0; --lsb) { - lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; - if (!start || charval) { - *destp++ = (charval==0)?' ':charval; - len++; - start = false; // Drop leading 0s - } + lsb = (lsb / 8) * 8; // Next digit + IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; + if (!start || charval) { + *destp++ = (charval==0)?' ':charval; + len++; + start = false; // Drop leading 0s + } } return std::string(destout, len); } @@ -2001,9 +2001,9 @@ void VerilatedScope::exportInsert(int finalize, const char* namep, void* cb) VL_ } else { if (VL_UNLIKELY(funcnum >= m_funcnumMax)) { VL_FATAL_MT(__FILE__,__LINE__,"","Internal: Bad funcnum vs. pre-finalize maximum"); - } - if (VL_UNLIKELY(!m_callbacksp)) { // First allocation - m_callbacksp = new void* [m_funcnumMax]; + } + if (VL_UNLIKELY(!m_callbacksp)) { // First allocation + m_callbacksp = new void* [m_funcnumMax]; memset(m_callbacksp, 0, m_funcnumMax*sizeof(void*)); } m_callbacksp[funcnum] = cb; diff --git a/include/verilated.h b/include/verilated.h index 939bddc3d..104deea52 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -26,7 +26,7 @@ #ifndef _VERILATED_H_ -#define _VERILATED_H_ 1 ///< Header Guard +#define _VERILATED_H_ 1 ///< Header Guard #include "verilatedos.h" @@ -48,8 +48,8 @@ //============================================================================= // Switches -#if VM_TRACE // Verilator tracing requested -# define WAVES 1 // Set backward compatibility flag +#if VM_TRACE // Verilator tracing requested +# define WAVES 1 // Set backward compatibility flag #endif //========================================================================= @@ -158,7 +158,7 @@ class VL_SCOPED_CAPABILITY VerilatedLockGuard { } }; -#else // !VL_THREADED +#else // !VL_THREADED /// Empty non-threaded mutex to avoid #ifdefs in consuming code class VerilatedMutex { @@ -175,7 +175,7 @@ public: ~VerilatedLockGuard() {} }; -#endif // VL_THREADED +#endif // VL_THREADED /// Remember the calling thread at construction time, and make sure later calls use same thread class VerilatedAssertOneThread { @@ -196,7 +196,7 @@ public: } } static void fatal_different() VL_MT_SAFE; -#else // !VL_THREADED || !VL_DEBUG +#else // !VL_THREADED || !VL_DEBUG public: void check() {} #endif @@ -208,11 +208,11 @@ public: class VerilatedModule { VL_UNCOPYABLE(VerilatedModule); private: - const char* m_namep; ///< Module name + const char* m_namep; ///< Module name public: - explicit VerilatedModule(const char* namep); ///< Create module with given hierarchy name + explicit VerilatedModule(const char* namep); ///< Create module with given hierarchy name ~VerilatedModule(); - const char* name() const { return m_namep; } ///< Return name of module + const char* name() const { return m_namep; } ///< Return name of module }; //========================================================================= @@ -336,9 +336,9 @@ class Verilated { static VerilatedVoidCb s_flushCb; ///< Flush callback function - static struct Serialized { // All these members serialized/deserialized - // Fast path - int s_debug; ///< See accessors... only when VL_DEBUG set + static struct Serialized { // All these members serialized/deserialized + // Fast path + int s_debug; ///< See accessors... only when VL_DEBUG set bool s_calcUnusedSigs; ///< Waves file on, need all signals calculated bool s_gotFinish; ///< A $finish statement executed bool s_assertOn; ///< Assertions are enabled @@ -470,7 +470,7 @@ public: public: // METHODS - INTERNAL USE ONLY (but public due to what uses it) // Internal: Create a new module name by concatenating two strings - static const char* catName(const char* n1, const char* n2); // Returns static data + static const char* catName(const char* n1, const char* n2); // Returns static data // Internal: Throw signal assertion static void overWidthError(const char* signame) VL_MT_SAFE; @@ -491,7 +491,7 @@ public: static int exportFuncNum(const char* namep) VL_MT_SAFE; static size_t serializedSize() VL_PURE { return sizeof(s_s); } - static void* serializedPtr() VL_MT_UNSAFE { return &s_s; } // Unsafe, for Serialize only + static void* serializedPtr() VL_MT_UNSAFE { return &s_s; } // Unsafe, for Serialize only #ifdef VL_THREADED /// Set the mtaskId, called when an mtask starts static void mtaskId(vluint32_t id) VL_MT_SAFE { t_s.t_mtaskId = id; } @@ -562,15 +562,15 @@ extern void VL_PRINTF_MT(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; /// Print a debug message from internals with standard prefix, with printf style format extern void VL_DBG_MSGF(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; -extern IData VL_RANDOM_I(int obits); ///< Randomize a signal -extern QData VL_RANDOM_Q(int obits); ///< Randomize a signal -extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); ///< Randomize a signal +extern IData VL_RANDOM_I(int obits); ///< Randomize a signal +extern QData VL_RANDOM_Q(int obits); ///< Randomize a signal +extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); ///< Randomize a signal /// Init time only, so slow is fine -extern IData VL_RAND_RESET_I(int obits); ///< Random reset a signal -extern QData VL_RAND_RESET_Q(int obits); ///< Random reset a signal -extern WDataOutP VL_RAND_RESET_W(int obits, WDataOutP outwp); ///< Random reset a signal -extern WDataOutP VL_ZERO_RESET_W(int obits, WDataOutP outwp); ///< Zero reset a signal (slow - else use VL_ZERO_W) +extern IData VL_RAND_RESET_I(int obits); ///< Random reset a signal +extern QData VL_RAND_RESET_Q(int obits); ///< Random reset a signal +extern WDataOutP VL_RAND_RESET_W(int obits, WDataOutP outwp); ///< Random reset a signal +extern WDataOutP VL_ZERO_RESET_W(int obits, WDataOutP outwp); ///< Zero reset a signal (slow - else use VL_ZERO_W) #if VL_THREADED /// Return high-precision counter for profiling, or 0x0 if not available @@ -1191,7 +1191,7 @@ static inline int _VL_CMP_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { if (lwp[i] > rwp[i]) return 1; if (lwp[i] < rwp[i]) return -1; } - return(0); // == + return(0); // == } #define VL_LTS_IWW(obits,lbits,rbbits,lwp,rwp) (_VL_CMPS_W(lbits,lwp,rwp)<0) @@ -1202,8 +1202,8 @@ static inline int _VL_CMP_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { static inline IData VL_GTS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { // For lbits==32, this becomes just a single instruction, otherwise ~5. // GCC 3.3.4 sign extension bugs on AMD64 architecture force us to use quad logic - vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); //Q for gcc - vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); //Q for gcc + vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc + vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed > rhs_signed; } static inline IData VL_GTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { @@ -1213,8 +1213,8 @@ static inline IData VL_GTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PUR } static inline IData VL_GTES_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { - vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); //Q for gcc - vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); //Q for gcc + vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc + vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed >= rhs_signed; } static inline IData VL_GTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { @@ -1224,8 +1224,8 @@ static inline IData VL_GTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PU } static inline IData VL_LTS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { - vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); //Q for gcc - vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); //Q for gcc + vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc + vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed < rhs_signed; } static inline IData VL_LTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { @@ -1235,8 +1235,8 @@ static inline IData VL_LTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PUR } static inline IData VL_LTES_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { - vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); //Q for gcc - vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); //Q for gcc + vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc + vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed <= rhs_signed; } static inline IData VL_LTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { @@ -1251,13 +1251,13 @@ static inline int _VL_CMPS_W(int lbits, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { // We need to flip sense if negative comparison IData lsign = VL_SIGN_I(lbits,lwp[i]); IData rsign = VL_SIGN_I(lbits,rwp[i]); - if (!lsign && rsign) return 1; // + > - - if (lsign && !rsign) return -1; // - < + + if (!lsign && rsign) return 1; // + > - + if (lsign && !rsign) return -1; // - < + for (; i>=0; --i) { - if (lwp[i] > rwp[i]) return 1; - if (lwp[i] < rwp[i]) return -1; + if (lwp[i] > rwp[i]) return 1; + if (lwp[i] < rwp[i]) return -1; } - return(0); // == + return(0); // == } //========================================================================= @@ -1341,26 +1341,26 @@ static inline QData VL_MULS_QQQ(int,int lbits,int, QData lhs,QData rhs) VL_PURE static inline WDataOutP VL_MULS_WWW(int,int lbits,int, WDataOutP owp,WDataInP lwp,WDataInP rwp) VL_MT_SAFE { int words = VL_WORDS_I(lbits); // cppcheck-suppress variableScope - WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here + WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here // cppcheck-suppress variableScope WData rwstore[VL_MULS_MAX_WORDS]; WDataInP lwusp = lwp; WDataInP rwusp = rwp; IData lneg = VL_SIGN_I(lbits,lwp[words-1]); - if (lneg) { // Negate lhs - lwusp = lwstore; - VL_NEGATE_W(words, lwstore, lwp); - lwstore[words-1] &= VL_MASK_I(lbits); // Clean it + if (lneg) { // Negate lhs + lwusp = lwstore; + VL_NEGATE_W(words, lwstore, lwp); + lwstore[words-1] &= VL_MASK_I(lbits); // Clean it } IData rneg = VL_SIGN_I(lbits,rwp[words-1]); - if (rneg) { // Negate rhs - rwusp = rwstore; - VL_NEGATE_W(words, rwstore, rwp); - rwstore[words-1] &= VL_MASK_I(lbits); // Clean it + if (rneg) { // Negate rhs + rwusp = rwstore; + VL_NEGATE_W(words, rwstore, rwp); + rwstore[words-1] &= VL_MASK_I(lbits); // Clean it } VL_MUL_W(words,owp,lwusp,rwusp); owp[words-1] &= VL_MASK_I(lbits); // Clean. Note it's ok for the multiply to overflow into the sign bit - if ((lneg ^ rneg) & 1) { // Negate output (not using NEGATE, as owp==lwp) + if ((lneg ^ rneg) & 1) { // Negate output (not using NEGATE, as owp==lwp) QData carry = 0; for (int i=0; i(static_cast(~owp[i])); @@ -1404,7 +1404,7 @@ static inline WDataOutP VL_DIVS_WWW(int lbits, WDataOutP owp,WDataInP lwp,WDataI IData lsign = VL_SIGN_I(lbits,lwp[words-1]); IData rsign = VL_SIGN_I(lbits,rwp[words-1]); // cppcheck-suppress variableScope - WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here + WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here // cppcheck-suppress variableScope WData rwstore[VL_MULS_MAX_WORDS]; WDataInP ltup = lwp; @@ -1425,7 +1425,7 @@ static inline WDataOutP VL_MODDIVS_WWW(int lbits, WDataOutP owp,WDataInP lwp,WDa IData lsign = VL_SIGN_I(lbits,lwp[words-1]); IData rsign = VL_SIGN_I(lbits,rwp[words-1]); // cppcheck-suppress variableScope - WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here + WData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here // cppcheck-suppress variableScope WData rwstore[VL_MULS_MAX_WORDS]; WDataInP ltup = lwp; @@ -1488,12 +1488,12 @@ static inline IData VL_POWSS_III(int obits, int, int rbits, IData lhs, IData rhs, bool lsign, bool rsign) VL_MT_SAFE { if (VL_UNLIKELY(rhs==0)) return 1; if (rsign && VL_SIGN_I(rbits, rhs)) { - if (lhs==0) return 0; // "X" - else if (lhs==1) return 1; - else if (lsign && lhs==VL_MASK_I(obits)) { // -1 - if (rhs & 1) return VL_MASK_I(obits); // -1^odd=-1 - else return 1; // -1^even=1 - } + if (lhs==0) return 0; // "X" + else if (lhs==1) return 1; + else if (lsign && lhs==VL_MASK_I(obits)) { // -1 + if (rhs & 1) return VL_MASK_I(obits); // -1^odd=-1 + else return 1; // -1^even=1 + } return 0; } return VL_POW_III(obits, rbits, rbits, lhs, rhs); @@ -1502,12 +1502,12 @@ static inline QData VL_POWSS_QQQ(int obits, int, int rbits, QData lhs, QData rhs, bool lsign, bool rsign) VL_MT_SAFE { if (VL_UNLIKELY(rhs==0)) return 1; if (rsign && VL_SIGN_I(rbits, rhs)) { - if (lhs==0) return 0; // "X" - else if (lhs==1) return 1; - else if (lsign && lhs==VL_MASK_I(obits)) { // -1 - if (rhs & 1) return VL_MASK_I(obits); // -1^odd=-1 - else return 1; // -1^even=1 - } + if (lhs==0) return 0; // "X" + else if (lhs==1) return 1; + else if (lsign && lhs==VL_MASK_I(obits)) { // -1 + if (rhs & 1) return VL_MASK_I(obits); // -1^odd=-1 + else return 1; // -1^even=1 + } return 0; } return VL_POW_QQQ(obits, rbits, rbits, lhs, rhs); @@ -1549,9 +1549,9 @@ static inline void _VL_INSERT_WI(int, WDataOutP owp, IData ld, int hbit, int lbi } else { int hword = VL_BITWORD_I(hbit); - int lword = VL_BITWORD_I(lbit); - if (hword==lword) { // know < 32 bits because above checks it - IData insmask = (VL_MASK_I(hoffset-loffset+1))<> 1) & VL_UL(0x55555555)) | ((ret & VL_UL(0x55555555)) << 1); // FALLTHRU - case 1: - ret = ((ret >> 2) & VL_UL(0x33333333)) | ((ret & VL_UL(0x33333333)) << 2); // FALLTHRU - case 2: - ret = ((ret >> 4) & VL_UL(0x0f0f0f0f)) | ((ret & VL_UL(0x0f0f0f0f)) << 4); // FALLTHRU - case 3: - ret = ((ret >> 8) & VL_UL(0x00ff00ff)) | ((ret & VL_UL(0x00ff00ff)) << 8); // FALLTHRU + case 0: + ret = ((ret >> 1) & VL_UL(0x55555555)) + | ((ret & VL_UL(0x55555555)) << 1); // FALLTHRU + case 1: + ret = ((ret >> 2) & VL_UL(0x33333333)) + | ((ret & VL_UL(0x33333333)) << 2); // FALLTHRU + case 2: + ret = ((ret >> 4) & VL_UL(0x0f0f0f0f)) + | ((ret & VL_UL(0x0f0f0f0f)) << 4); // FALLTHRU + case 3: + ret = ((ret >> 8) & VL_UL(0x00ff00ff)) + | ((ret & VL_UL(0x00ff00ff)) << 8); // FALLTHRU case 4: ret = ((ret >> 16) | (ret << 16)); } @@ -1895,17 +1899,17 @@ static inline WDataOutP VL_SHIFTL_WWI(int obits,int,int,WDataOutP owp,WDataInP l static inline WDataOutP VL_SHIFTL_WWW(int obits, int lbits, int rbits, WDataOutP owp, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - return VL_ZERO_W(obits, owp); - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + return VL_ZERO_W(obits, owp); + } } return VL_SHIFTL_WWI(obits,lbits,32,owp,lwp,rwp[0]); } static inline IData VL_SHIFTL_IIW(int obits,int,int rbits,IData lhs, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - return 0; - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + return 0; + } } return VL_CLEAN_II(obits,obits,lhs<>32 or more - return VL_ZERO_W(obits, owp); - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + return VL_ZERO_W(obits, owp); + } } return VL_SHIFTR_WWI(obits,lbits,32,owp,lwp,rwp[0]); } static inline IData VL_SHIFTR_IIW(int obits,int,int rbits,IData lhs, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - return 0; - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + return 0; + } } return VL_CLEAN_II(obits,obits,lhs>>rwp[0]); } @@ -1963,8 +1967,8 @@ static inline IData VL_SHIFTRS_III(int obits, int lbits, int, IData lhs, IData r // IEEE says signed if output signed, but bit position from lbits; // must use lbits for sign; lbits might != obits, // an EXTEND(SHIFTRS(...)) can became a SHIFTRS(...) within same 32/64 bit word length - IData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative - IData signext = ~(VL_MASK_I(lbits) >> rhs); // One with bits where we've shifted "past" + IData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative + IData signext = ~(VL_MASK_I(lbits) >> rhs); // One with bits where we've shifted "past" return (lhs >> rhs) | (sign & VL_CLEAN_II(obits,obits,signext)); } static inline QData VL_SHIFTRS_QQI(int obits, int lbits, int, QData lhs, IData rhs) VL_PURE { @@ -2012,9 +2016,9 @@ static inline WDataOutP VL_SHIFTRS_WWI(int obits, int lbits, int, static inline WDataOutP VL_SHIFTRS_WWW(int obits, int lbits, int rbits, WDataOutP owp, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - int lmsw = VL_WORDS_I(obits)-1; - IData sign = VL_SIGNONES_I(lbits,lwp[lmsw]); + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + int lmsw = VL_WORDS_I(obits)-1; + IData sign = VL_SIGNONES_I(lbits,lwp[lmsw]); for (int j=0; j <= lmsw; ++j) owp[j] = sign; owp[lmsw] &= VL_MASK_I(lbits); return owp; @@ -2025,20 +2029,20 @@ static inline WDataOutP VL_SHIFTRS_WWW(int obits, int lbits, int rbits, static inline IData VL_SHIFTRS_IIW(int obits, int lbits, int rbits, IData lhs, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - IData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative - return VL_CLEAN_II(obits,obits,sign); - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + IData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative + return VL_CLEAN_II(obits,obits,sign); + } } return VL_SHIFTRS_III(obits,lbits,32,lhs,rwp[0]); } static inline QData VL_SHIFTRS_QQW(int obits, int lbits, int rbits, QData lhs, WDataInP rwp) VL_MT_SAFE { for (int i=1; i < VL_WORDS_I(rbits); ++i) { - if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more - QData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative - return VL_CLEAN_QQ(obits,obits,sign); - } + if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more + QData sign = -(lhs >> (lbits-1)); // ffff_ffff if negative + return VL_CLEAN_QQ(obits,obits,sign); + } } return VL_SHIFTRS_QQI(obits,lbits,32,lhs,rwp[0]); } @@ -2063,8 +2067,8 @@ static inline QData VL_SHIFTRS_QQQ(int obits,int lbits,int rbits,QData lhs, QDat static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP lwp, IData rd) VL_MT_SAFE { int word = VL_BITWORD_I(rd); if (VL_UNLIKELY(rd > static_cast(lbits))) { - return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. - // We return all 1's as that's more likely to find bugs (?) than 0's. + return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. + // We return all 1's as that's more likely to find bugs (?) than 0's. } else { return (lwp[word]>>VL_BITBIT_I(rd)); } @@ -2080,7 +2084,7 @@ static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP lwp, IData lsb, IData width) VL_MT_SAFE { int msb = lsb+width-1; if (VL_UNLIKELY(msb>lbits)) { - return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. + return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. } else if (VL_BITWORD_I(msb)==VL_BITWORD_I(static_cast(lsb))) { return VL_BITRSHIFT_W(lwp, lsb); } else { @@ -2095,7 +2099,7 @@ static inline QData VL_SEL_QWII(int, int lbits, int, int, WDataInP lwp, IData lsb, IData width) VL_MT_SAFE { int msb = lsb+width-1; if (VL_UNLIKELY(msb>lbits)) { - return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. + return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. } else if (VL_BITWORD_I(msb)==VL_BITWORD_I(static_cast(lsb))) { return VL_BITRSHIFT_W(lwp, lsb); } else if (VL_BITWORD_I(msb)==1+VL_BITWORD_I(static_cast(lsb))) { @@ -2117,9 +2121,9 @@ static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int, WDataOutP owp, WDataInP lwp, IData lsb, IData width) VL_MT_SAFE { int msb = lsb+width-1; int word_shift = VL_BITWORD_I(lsb); - if (VL_UNLIKELY(msb>lbits)) { // Outside bounds, - for (int i=0; ilbits)) { // Outside bounds, + for (int i=0; i class VerilatedCoverItemSpec : public VerilatedCovImpItem { private: // MEMBERS - T* m_countp; ///< Count value + T* m_countp; ///< Count value public: // METHODS // cppcheck-suppress truncLongCastReturn @@ -431,12 +431,12 @@ void VerilatedCov::_insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9), A(10),A(11),A(12),A(13),A(14),A(15),A(16),A(17),A(18),A(19), A(20),A(21),A(22),A(23),A(24),A(25),A(26),A(27),A(28),A(29)) VL_MT_SAFE { const char* keyps[VerilatedCovImpBase::MAX_KEYS] - = {NULL,NULL,NULL, // filename,lineno,page - key0,key1,key2,key3,key4,key5,key6,key7,key8,key9, - key10,key11,key12,key13,key14,key15,key16,key17,key18,key19, - key20,key21,key22,key23,key24,key25,key26,key27,key28,key29}; + = {NULL,NULL,NULL, // filename,lineno,page + key0,key1,key2,key3,key4,key5,key6,key7,key8,key9, + key10,key11,key12,key13,key14,key15,key16,key17,key18,key19, + key20,key21,key22,key23,key24,key25,key26,key27,key28,key29}; const char* valps[VerilatedCovImpBase::MAX_KEYS] - = {NULL,NULL,NULL, // filename,lineno,page + = {NULL,NULL,NULL, // filename,lineno,page valp0,valp1,valp2,valp3,valp4,valp5,valp6,valp7,valp8,valp9, valp10,valp11,valp12,valp13,valp14,valp15,valp16,valp17,valp18,valp19, valp20,valp21,valp22,valp23,valp24,valp25,valp26,valp27,valp28,valp29}; diff --git a/include/verilated_cov.h b/include/verilated_cov.h index c557e7ee9..c738153fd 100644 --- a/include/verilated_cov.h +++ b/include/verilated_cov.h @@ -106,8 +106,8 @@ public: // much slower (nearly 2x) than having smaller versions also. However // there's not much more gain in having a version for each number of args. #define K(n) const char* key ## n -#define A(n) const char* key ## n, const char* valp ## n // Argument list -#define D(n) const char* key ## n = NULL, const char* valp ## n = NULL // Argument list +#define A(n) const char* key ## n, const char* valp ## n // Argument list +#define D(n) const char* key ## n = NULL, const char* valp ## n = NULL // Argument list static void _insertp(D(0),D(1),D(2),D(3),D(4),D(5),D(6),D(7),D(8),D(9)); static void _insertp(A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9) ,A(10),D(11),D(12),D(13),D(14),D(15),D(16),D(17),D(18),D(19)); @@ -129,4 +129,4 @@ public: static void zero() VL_MT_SAFE; }; -#endif // guard +#endif // Guard diff --git a/include/verilated_cov_key.h b/include/verilated_cov_key.h index 9cd05be4f..374090605 100644 --- a/include/verilated_cov_key.h +++ b/include/verilated_cov_key.h @@ -140,4 +140,4 @@ public: } }; -#endif // guard +#endif // guard diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 83e7104a4..f85d85f4d 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -147,7 +147,7 @@ void svPutPartselBit(svBitVecVal* dp, const svBitVecVal s, int lbit, int width) else { int hword = VL_BITWORD_I(hbit); int lword = VL_BITWORD_I(lbit); - if (hword==lword) { // know < 32 bits because above checks it + if (hword==lword) { // know < 32 bits because above checks it IData insmask = (VL_MASK_I(hoffset-loffset+1))< m_cb; ///< Lambda to execute when message received + vluint32_t m_mtaskId; ///< MTask that did enqueue + std::function m_cb; ///< Lambda to execute when message received public: // CONSTRUCTORS VerilatedMsg(const std::function& cb) @@ -103,9 +103,9 @@ public: while (m_depth) { // Wait for a message to be added to the queue // We don't use unique_lock as want to unlock with the message copy still in scope - m_mutex.lock(); - assert(!m_queue.empty()); // Otherwise m_depth is wrong - // Unfortunately to release the lock we need to copy the message + m_mutex.lock(); + assert(!m_queue.empty()); // Otherwise m_depth is wrong + // Unfortunately to release the lock we need to copy the message // (Or have the message be a pointer, but then new/delete cost on each message) // We assume messages are small, so copy auto it = m_queue.begin(); @@ -160,7 +160,7 @@ public: } } }; -#endif // VL_THREADED +#endif // VL_THREADED //====================================================================== // VerilatedImp @@ -174,7 +174,7 @@ class VerilatedImp { typedef std::map ExportNameMap; // MEMBERS - static VerilatedImp s_s; ///< Static Singleton; One and only static this + static VerilatedImp s_s; ///< Static Singleton; One and only static this // Nothing here is save-restored; users expected to re-register appropriately @@ -197,7 +197,7 @@ class VerilatedImp { std::vector m_fdps VL_GUARDED_BY(m_fdMutex); ///< File descriptors std::deque m_fdFree VL_GUARDED_BY(m_fdMutex); ///< List of free descriptors (SLOW - FOPEN/CLOSE only) -public: // But only for verilated*.cpp +public: // But only for verilated*.cpp // CONSTRUCTORS VerilatedImp() : m_argVecLoaded(false), m_exportNext(0) { @@ -282,7 +282,7 @@ private: } } -public: // But only for verilated*.cpp +public: // But only for verilated*.cpp // METHODS - scope name static void scopeInsert(const VerilatedScope* scopep) VL_MT_SAFE { // Slow ok - called once/scope at construction @@ -319,7 +319,7 @@ public: // But only for verilated*.cpp return &s_s.m_nameMap; } -public: // But only for verilated*.cpp +public: // But only for verilated*.cpp // METHODS - export names // Each function prototype is converted to a function number which we @@ -367,7 +367,7 @@ public: // But only for verilated*.cpp // We don't free up m_exportMap until the end, because we can't be sure // what other models are using the assigned funcnum's. -public: // But only for verilated*.cpp +public: // But only for verilated*.cpp // METHODS - file IO static IData fdNew(FILE* fp) VL_MT_SAFE { if (VL_UNLIKELY(!fp)) return 0; diff --git a/include/verilated_lxt2_c.cpp b/include/verilated_lxt2_c.cpp index 96f03781f..ddde7a821 100644 --- a/include/verilated_lxt2_c.cpp +++ b/include/verilated_lxt2_c.cpp @@ -51,9 +51,9 @@ protected: void* m_userthis; ///< Fake "this" for caller vluint32_t m_code; ///< Starting code number // CONSTRUCTORS - VerilatedLxt2CallInfo (VerilatedLxt2Callback_t icb, VerilatedLxt2Callback_t fcb, - VerilatedLxt2Callback_t changecb, - void* ut, vluint32_t code) + VerilatedLxt2CallInfo(VerilatedLxt2Callback_t icb, VerilatedLxt2Callback_t fcb, + VerilatedLxt2Callback_t changecb, + void* ut, vluint32_t code) : m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {}; ~VerilatedLxt2CallInfo() {} }; diff --git a/include/verilated_lxt2_c.h b/include/verilated_lxt2_c.h index 709d3a7f2..67accef26 100644 --- a/include/verilated_lxt2_c.h +++ b/include/verilated_lxt2_c.h @@ -139,10 +139,10 @@ public: void fullQuad(vluint32_t code, const vluint64_t newval, int bits) { chgQuad(code, newval, bits); } void fullArray(vluint32_t code, const vluint32_t* newval, int bits) { chgArray(code, newval, bits); } - void declTriBit (vluint32_t code, const char* name, int arraynum); - void declTriBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb); - void declTriQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb); - void declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb); + void declTriBit(vluint32_t code, const char* name, int arraynum); + void declTriBus(vluint32_t code, const char* name, int arraynum, int msb, int lsb); + void declTriQuad(vluint32_t code, const char* name, int arraynum, int msb, int lsb); + void declTriArray(vluint32_t code, const char* name, int arraynum, int msb, int lsb); void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri); void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits); void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits); diff --git a/include/verilated_save.cpp b/include/verilated_save.cpp index f884547cb..161952f04 100644 --- a/include/verilated_save.cpp +++ b/include/verilated_save.cpp @@ -32,7 +32,7 @@ # include #endif -#ifndef O_LARGEFILE // For example on WIN32 +#ifndef O_LARGEFILE // For example on WIN32 # define O_LARGEFILE 0 #endif #ifndef O_NONBLOCK @@ -43,8 +43,8 @@ #endif // CONSTANTS -static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n"; ///< Value of first bytes of each file -static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file +static const char* const VLTSAVE_HEADER_STR = "verilatorsave01\n"; ///< Value of first bytes of each file +static const char* const VLTSAVE_TRAILER_STR = "vltsaved"; ///< Value of last bytes of each file //============================================================================= //============================================================================= @@ -119,7 +119,7 @@ void VerilatedSave::open(const char* filenamep) VL_MT_UNSAFE_ONE { VL_DEBUG_IF(VL_DBG_MSGF("- save: opening save file %s\n",filenamep);); if (filenamep[0]=='|') { - assert(0); // Not supported yet. + assert(0); // Not supported yet. } else { // cppcheck-suppress duplicateExpression m_fd = ::open(filenamep, O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK|O_CLOEXEC @@ -142,7 +142,7 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE { VL_DEBUG_IF(VL_DBG_MSGF("- restore: opening restore file %s\n",filenamep);); if (filenamep[0]=='|') { - assert(0); // Not supported yet. + assert(0); // Not supported yet. } else { // cppcheck-suppress duplicateExpression m_fd = ::open(filenamep, O_CREAT|O_RDONLY|O_LARGEFILE|O_CLOEXEC @@ -200,7 +200,7 @@ void VerilatedSave::flush() VL_MT_UNSAFE_ONE { } } } - m_cp = m_bufp; // Reset buffer + m_cp = m_bufp; // Reset buffer } void VerilatedRestore::fill() VL_MT_UNSAFE_ONE { @@ -210,7 +210,7 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE { vluint8_t* rp = m_bufp; for (vluint8_t* sp=m_cp; sp < m_endp;) *rp++ = *sp++; // Overlaps m_endp = m_bufp + (m_endp - m_cp); - m_cp = m_bufp; // Reset buffer + m_cp = m_bufp; // Reset buffer // Read into buffer starting at m_endp while (1) { ssize_t remaining = (m_bufp+bufferSize() - m_endp); @@ -226,9 +226,10 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE { VL_FATAL_MT("",0,"",msg.c_str()); close(); break; - } - } else { // got==0, EOF - // Fill buffer from here to end with NULLs so reader's don't need to check eof each character. + } + } else { // got==0, EOF + // Fill buffer from here to end with NULLs so reader's don't + // need to check eof each character. while (m_endp < m_bufp+bufferSize()) *m_endp++ = '\0'; break; } diff --git a/include/verilated_save.h b/include/verilated_save.h index 09987ab51..d9e2f6c03 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -248,4 +248,4 @@ inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, std::string& r return os.read((void*)rhs.data(), len); } -#endif // guard +#endif // Guard diff --git a/include/verilated_sc.h b/include/verilated_sc.h index 054fc7f12..aab09739b 100644 --- a/include/verilated_sc.h +++ b/include/verilated_sc.h @@ -25,7 +25,7 @@ #ifndef _VERILATED_SC_H_ -#define _VERILATED_SC_H_ 1 ///< Header Guard +#define _VERILATED_SC_H_ 1 ///< Header Guard #include "verilatedos.h" @@ -50,4 +50,4 @@ public: //========================================================================= -#endif // guard +#endif // Guard diff --git a/include/verilated_sym_props.h b/include/verilated_sym_props.h index 0d4a0a6bd..ba6112eaa 100644 --- a/include/verilated_sym_props.h +++ b/include/verilated_sym_props.h @@ -30,7 +30,7 @@ #ifndef _VERILATED_SYM_PROPS_H_ -#define _VERILATED_SYM_PROPS_H_ 1 ///< Header Guard +#define _VERILATED_SYM_PROPS_H_ 1 ///< Header Guard #include "verilatedos.h" @@ -223,4 +223,4 @@ public: const char* name() const { return m_namep; } }; -#endif // Guard +#endif // Guard diff --git a/include/verilated_syms.h b/include/verilated_syms.h index 2678051fe..f46ea596e 100644 --- a/include/verilated_syms.h +++ b/include/verilated_syms.h @@ -29,7 +29,7 @@ #ifndef _VERILATED_SYMS_H_ -#define _VERILATED_SYMS_H_ 1 ///< Header Guard +#define _VERILATED_SYMS_H_ 1 ///< Header Guard #include "verilatedos.h" #include "verilated_heavy.h" @@ -63,4 +63,4 @@ public: ~VerilatedVarNameMap() {} }; -#endif // Guard +#endif // Guard diff --git a/include/verilated_unordered_set_map.h b/include/verilated_unordered_set_map.h index e3504a3d6..ef4afc47c 100644 --- a/include/verilated_unordered_set_map.h +++ b/include/verilated_unordered_set_map.h @@ -122,9 +122,9 @@ public: class iterator { protected: // MEMBERS - size_t m_bucketIdx; // Bucket this iterator points into. - typename Bucket::iterator m_bit; // Bucket-local iterator. - const vl_unordered_set* m_setp; // The containing set. + size_t m_bucketIdx; // Bucket this iterator points into + typename Bucket::iterator m_bit; // Bucket-local iterator + const vl_unordered_set* m_setp; // The containing set public: // CONSTRUCTORS @@ -469,7 +469,7 @@ private: // MEMBERS typedef vl_unordered_set MapSet; - MapSet m_set; // Wrap this vl_unordered_set which holds all state. + MapSet m_set; // Wrap this vl_unordered_set which holds all state. public: // CONSTRUCTORS diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 780c8e74a..c3f4afe89 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -40,7 +40,7 @@ class VerilatedVcdCallInfo; class VerilatedVcdFile { private: - int m_fd; ///< File descriptor we're writing to + int m_fd; ///< File descriptor we're writing to public: // METHODS VerilatedVcdFile() : m_fd(0) {} diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 992a2943b..882e63474 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -921,7 +921,7 @@ void VerilatedVpiError::selfTest() VL_MT_UNSAFE_ONE { vpiHandle vpi_register_cb(p_cb_data cb_data_p) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); // cppcheck-suppress nullPointer if (VL_UNLIKELY(!cb_data_p)) { _VL_VPI_WARNING(__FILE__, __LINE__, "%s : callback data pointer is null", VL_FUNC); @@ -963,7 +963,7 @@ PLI_INT32 vpi_remove_cb(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_remove_cb %p\n",object);); VerilatedVpiImp::assertOneCheck(); VerilatedVpioCb* vop = VerilatedVpioCb::castp(object); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!vop)) return 0; if (vop->cb_datap()->reason == cbAfterDelay) { VerilatedVpiImp::cbTimedRemove(vop); @@ -987,7 +987,7 @@ void vpi_get_systf_info(vpiHandle object, p_vpi_systf_data systf_data_p) { vpiHandle vpi_handle_by_name(PLI_BYTE8* namep, vpiHandle scope) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!namep)) return NULL; VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle_by_name %s %p\n",namep,scope);); VerilatedVpioScope* voScopep = VerilatedVpioScope::castp(scope); @@ -1024,7 +1024,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle_by_index %p %d\n",object, indx);); VerilatedVpiImp::assertOneCheck(); VerilatedVpioVar* varop = VerilatedVpioVar::castp(object); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_LIKELY(varop)) { if (varop->varp()->dims()<2) return 0; if (VL_LIKELY(varop->varp()->unpacked().left() >= varop->varp()->unpacked().right())) { @@ -1049,7 +1049,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle %d %p\n",type,object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); switch (type) { case vpiLeftRange: { VerilatedVpioVar* vop = VerilatedVpioVar::castp(object); @@ -1092,7 +1092,7 @@ vpiHandle vpi_handle_multi(PLI_INT32 type, vpiHandle refHandle1, vpiHandle refHa vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_iterate %d %p\n",type,object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); switch (type) { case vpiMemoryWord: { VerilatedVpioVar* vop = VerilatedVpioVar::castp(object); @@ -1130,7 +1130,7 @@ vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { vpiHandle vpi_scan(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_scan %p\n",object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); VerilatedVpio* vop = VerilatedVpio::castp(object); if (VL_UNLIKELY(!vop)) return NULL; return vop->dovpi_scan(); @@ -1142,7 +1142,7 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) { // Leave this in the header file - in many cases the compiler can constant propagate "object" VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get %d %p\n",property,object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); switch (property) { case vpiTimePrecision: { return VL_TIME_PRECISION; @@ -1185,7 +1185,7 @@ PLI_BYTE8 *vpi_get_str(PLI_INT32 property, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get_str %d %p\n",property,object);); VerilatedVpiImp::assertOneCheck(); VerilatedVpio* vop = VerilatedVpio::castp(object); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!vop)) return NULL; switch (property) { case vpiName: { @@ -1224,7 +1224,7 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { static VL_THREAD_LOCAL int outStrSz = sizeof(outStr)-1; VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get_value %p\n",object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!value_p)) return; if (VerilatedVpioVar* vop = VerilatedVpioVar::castp(object)) { // We used to presume vpiValue.format = vpiIntVal or if single bit vpiScalarVal @@ -1295,10 +1295,10 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { for (i=0; i>3]>>(i&7))&1; outStr[bits-i-1] = val?'1':'0'; - } - outStr[i]=0; // NULL terminate - return; - } + } + outStr[i] = '\0'; + return; + } default: _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(value_p->format), @@ -1345,10 +1345,10 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { } } outStr[chars-i-1] = '0' + (val&7); - } - outStr[i]=0; // NULL terminate - return; - } + } + outStr[i] = '\0'; + return; + } default: strcpy(outStr, "0"); _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", @@ -1404,10 +1404,10 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { } } outStr[chars-i-1] = "0123456789abcdef"[static_cast(val)]; - } - outStr[i]=0; // NULL terminate - return; - } + } + outStr[i] = '\0'; + return; + } default: _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(value_p->format), vop->fullname()); @@ -1436,10 +1436,10 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { char val = datap[bytes-i-1]; // other simulators replace [leading?] zero chars with spaces, replicate here. outStr[i] = val?val:' '; - } - outStr[i]=0; // NULL terminate - return; - } + } + outStr[i] = '\0'; + return; + } default: _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(value_p->format), vop->fullname()); @@ -1456,9 +1456,9 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { case VLVT_UINT32: value_p->value.integer = *(reinterpret_cast(vop->varDatap())); return; - case VLVT_WDATA: // FALLTHRU - case VLVT_UINT64: // FALLTHRU - default: + case VLVT_WDATA: // FALLTHRU + case VLVT_UINT64: // FALLTHRU + default: value_p->value.integer = 0; _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(value_p->format), vop->fullname()); @@ -1488,7 +1488,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value value_p, p_vpi_time time_p, PLI_INT32 flags) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_put_value %p %p\n",object, value_p);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!value_p)) { _VL_VPI_WARNING(__FILE__, __LINE__, "Ignoring vpi_put_value with NULL value pointer"); return 0; @@ -1578,8 +1578,8 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value value_p, int len = strlen(value_p->value.str); CData* datap = (reinterpret_cast(vop->varDatap())); div_t idx; - datap[0] = 0; // reset zero'th byte - for (int i=0; imask_byte(idx.quot); @@ -1692,9 +1693,10 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value value_p, if (i&1) { datap[i>>1] |= hex<<4; } else { - datap[i>>1] = hex; // this also resets all bits to 0 prior to or'ing above of the msb - } - } + datap[i>>1] = hex; // this also resets all + // bits to 0 prior to or'ing above of the msb + } + } // apply bit mask to most significant byte datap[(chars-1)>>1] &= vop->mask_byte((chars-1)>>1); return object; @@ -1736,9 +1738,9 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value value_p, case VLVT_UINT32: *(reinterpret_cast(vop->varDatap())) = vop->mask() & value_p->value.integer; return object; - case VLVT_WDATA: // FALLTHRU - case VLVT_UINT64: // FALLTHRU - default: + case VLVT_WDATA: // FALLTHRU + case VLVT_UINT64: // FALLTHRU + default: _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(value_p->format), vop->fullname()); return 0; @@ -1789,13 +1791,13 @@ void vpi_get_time(vpiHandle object, p_vpi_time time_p) { PLI_UINT32 vpi_mcd_open(PLI_BYTE8 *filenamep) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); return VL_FOPEN_S(filenamep,"wb"); } PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); VL_FCLOSE_I(mcd); return 0; } @@ -1805,7 +1807,7 @@ PLI_BYTE8 *vpi_mcd_name(PLI_UINT32 mcd) { PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, PLI_BYTE8 *formatp, ...) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); va_list ap; va_start(ap,formatp); int chars = vpi_mcd_vprintf(mcd, formatp, ap); @@ -1815,7 +1817,7 @@ PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, PLI_BYTE8 *formatp, ...) { PLI_INT32 vpi_printf(PLI_BYTE8 *formatp, ...) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); va_list ap; va_start(ap,formatp); int chars = vpi_vprintf(formatp, ap); @@ -1825,14 +1827,14 @@ PLI_INT32 vpi_printf(PLI_BYTE8 *formatp, ...) { PLI_INT32 vpi_vprintf(PLI_BYTE8* formatp, va_list ap) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); return VL_VPRINTF(formatp, ap); } PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, PLI_BYTE8 *format, va_list ap) { VerilatedVpiImp::assertOneCheck(); FILE* fp = VL_CVT_I_FP(mcd); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); // cppcheck-suppress nullPointer if (VL_UNLIKELY(!fp)) return 0; int chars = vfprintf(fp, format, ap); @@ -1841,7 +1843,7 @@ PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, PLI_BYTE8 *format, va_list ap) { PLI_INT32 vpi_flush(void) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); Verilated::flushCall(); return 0; } @@ -1849,7 +1851,7 @@ PLI_INT32 vpi_flush(void) { PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd) { VerilatedVpiImp::assertOneCheck(); FILE* fp = VL_CVT_I_FP(mcd); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!fp)) return 1; fflush(fp); return 0; @@ -1868,13 +1870,13 @@ PLI_INT32 vpi_chk_error(p_vpi_error_info error_info_p) { if (error_info_p && _error_info_p) { *error_info_p = *_error_info_p; } - if (!_error_info_p) return 0; // no error occured + if (!_error_info_p) return 0; // no error occured return _error_info_p->level; // return error severity level }; PLI_INT32 vpi_free_object(vpiHandle object) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); return vpi_release_handle(object); // Deprecated } @@ -1882,7 +1884,7 @@ PLI_INT32 vpi_release_handle(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_release_handle %p\n",object);); VerilatedVpiImp::assertOneCheck(); VerilatedVpio* vop = VerilatedVpio::castp(object); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); if (VL_UNLIKELY(!vop)) return 0; vpi_remove_cb(object); // May not be a callback, but that's ok delete vop; @@ -1891,7 +1893,7 @@ PLI_INT32 vpi_release_handle(vpiHandle object) { PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) VL_MT_SAFE { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); vlog_info_p->argc = Verilated::getCommandArgs()->argc; vlog_info_p->argv = (PLI_BYTE8**)Verilated::getCommandArgs()->argv; vlog_info_p->product = (PLI_BYTE8*)Verilated::productName(); @@ -1917,7 +1919,7 @@ PLI_INT32 vpi_put_userdata(vpiHandle obj, void *userdata) { PLI_INT32 vpi_control(PLI_INT32 operation, ...) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_control %d\n",operation);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); // reset vpi error status + _VL_VPI_ERROR_RESET(); switch (operation) { case vpiFinish: { VL_FINISH_MT(__FILE__,__LINE__,"*VPI*"); diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 61d27f226..180427a29 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -24,7 +24,7 @@ //========================================================================= #ifndef _VERILATED_VPI_H_ -#define _VERILATED_VPI_H_ 1 ///< Header Guard +#define _VERILATED_VPI_H_ 1 ///< Header Guard #include "verilatedos.h" #include "verilated.h" @@ -49,5 +49,4 @@ public: static void selfTest() VL_MT_UNSAFE_ONE; }; - -#endif // Guard +#endif // Guard diff --git a/include/verilatedos.h b/include/verilatedos.h index 9c87e3031..6a5e00d50 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -28,7 +28,7 @@ #ifndef _VERILATEDOS_H_ -#define _VERILATEDOS_H_ 1 ///< Header Guard +#define _VERILATEDOS_H_ 1 ///< Header Guard //========================================================================= // Compiler pragma abstraction @@ -188,14 +188,14 @@ #ifndef VL_WARNINGS # ifdef _MSC_VER -# pragma warning(disable:4099) // C4099: type name first seen using 'class' now seen using 'struct' (V3AstNode) -# pragma warning(disable:4100) // C4100: unreferenced formal parameter (L4) -# pragma warning(disable:4127) // C4127: conditional expression is constant (L4) -# pragma warning(disable:4146) // C4146: unary minus operator applied to unsigned type, result still unsigned -# pragma warning(disable:4189) // C4189: local variable is initialized but not referenced (L4) -# pragma warning(disable:4244) // C4244: conversion from 'uint64_t' to 'uint_32_t', possible loss of data -# pragma warning(disable:4245) // C4245: conversion from 'int' to 'unsigned', signed/unsigned mismatch -# pragma warning(disable:4996) // C4996: sscanf/fopen/etc may be unsafe +# pragma warning(disable:4099) // C4099: type name first seen using 'class' now seen using 'struct' (V3AstNode) +# pragma warning(disable:4100) // C4100: unreferenced formal parameter (L4) +# pragma warning(disable:4127) // C4127: conditional expression is constant (L4) +# pragma warning(disable:4146) // C4146: unary minus operator applied to unsigned type, result still unsigned +# pragma warning(disable:4189) // C4189: local variable is initialized but not referenced (L4) +# pragma warning(disable:4244) // C4244: conversion from 'uint64_t' to 'uint_32_t', possible loss of data +# pragma warning(disable:4245) // C4245: conversion from 'int' to 'unsigned', signed/unsigned mismatch +# pragma warning(disable:4996) // C4996: sscanf/fopen/etc may be unsafe # endif #endif @@ -211,10 +211,10 @@ typedef unsigned char uint8_t; ///< 8-bit unsigned type (backward comp typedef unsigned short int uint16_t; ///< 16-bit unsigned type (backward compatibility) typedef unsigned char vluint8_t; ///< 8-bit unsigned type typedef unsigned short int vluint16_t; ///< 16-bit unsigned type -# if defined(__uint32_t_defined) || defined(___int32_t_defined) // Newer Cygwin uint32_t in stdint.h as an unsigned int -typedef int32_t vlsint32_t; ///< 32-bit signed type -typedef uint32_t vluint32_t; ///< 32-bit unsigned type -# else // Older Cygwin has long==uint32_t +# if defined(__uint32_t_defined) || defined(___int32_t_defined) // Newer Cygwin uint32_t in stdint.h as an unsigned int +typedef int32_t vlsint32_t; ///< 32-bit signed type +typedef uint32_t vluint32_t; ///< 32-bit unsigned type +# else // Older Cygwin has long==uint32_t typedef unsigned long uint32_t; ///< 32-bit unsigned type (backward compatibility) typedef long vlsint32_t; ///< 32-bit signed type typedef unsigned long vluint32_t; ///< 32-bit unsigned type @@ -247,9 +247,9 @@ typedef signed __int32 ssize_t; ///< signed size_t; returned fro # endif # endif -#else // Linux or compliant Unix flavors, -m64 +#else // Linux or compliant Unix flavors, -m64 -# include // Solaris +# include // Solaris # include // Linux and most flavors # include // __WORDSIZE # include // ssize_t @@ -272,7 +272,7 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type #ifdef _WIN32 # define VL_PRI64 "I64" -#else // Linux or compliant Unix flavors +#else // Linux or compliant Unix flavors # if defined(__WORDSIZE) && (__WORDSIZE == 64) # define VL_PRI64 "l" # else @@ -297,7 +297,7 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type #ifdef _WIN32 # define VL_DEV_NULL "nul" -#else // Linux or compliant Unix flavors +#else // Linux or compliant Unix flavors # define VL_DEV_NULL "/dev/null" #endif @@ -341,9 +341,9 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type /// Mask for quads with 1's where relevant bits are (0=all bits) #define VL_MASK_Q(nbits) (((nbits) & VL_SIZEBITS_Q) \ ? ((VL_ULL(1) << ((nbits) & VL_SIZEBITS_Q) )-VL_ULL(1)) : VL_ULL(~0)) -#define VL_BITWORD_I(bit) ((bit)/VL_WORDSIZE) ///< Word number for a wide quantity -#define VL_BITBIT_I(bit) ((bit)&VL_SIZEBITS_I) ///< Bit number for a bit in a long -#define VL_BITBIT_Q(bit) ((bit)&VL_SIZEBITS_Q) ///< Bit number for a bit in a quad +#define VL_BITWORD_I(bit) ((bit)/VL_WORDSIZE) ///< Word number for a wide quantity +#define VL_BITBIT_I(bit) ((bit)&VL_SIZEBITS_I) ///< Bit number for a bit in a long +#define VL_BITBIT_Q(bit) ((bit)&VL_SIZEBITS_Q) ///< Bit number for a bit in a quad //========================================================================= // Floating point diff --git a/nodist/dot_importer b/nodist/dot_importer index ad9d5e8fc..659bc80a1 100755 --- a/nodist/dot_importer +++ b/nodist/dot_importer @@ -8,7 +8,7 @@ use IO::File; use Pod::Usage; use Data::Dumper; $Data::Dumper::Indent=1; use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== @@ -32,14 +32,14 @@ if (! GetOptions ( usage(); } -dotread ($opt_filename); +dotread($opt_filename); cwrite("graph_export.cpp"); #---------------------------------------------------------------------- sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub debug { diff --git a/nodist/dot_pruner b/nodist/dot_pruner index 60d3f82a7..acc914e35 100755 --- a/nodist/dot_pruner +++ b/nodist/dot_pruner @@ -8,7 +8,7 @@ use IO::File; use Pod::Usage; use Data::Dumper; $Data::Dumper::Indent=1; use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== @@ -35,7 +35,7 @@ if (! GetOptions ( usage(); } -dotread ($opt_filename); +dotread($opt_filename); circle($opt_circle) if $opt_circle; simplify(); dotwrite(); @@ -44,7 +44,7 @@ dotwrite(); sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub debug { diff --git a/nodist/git_untabify b/nodist/git_untabify index 2973a11e6..8bf59dccd 100755 --- a/nodist/git_untabify +++ b/nodist/git_untabify @@ -8,7 +8,7 @@ use IO::File; use IO::Dir; use Pod::Usage; use strict; -use vars qw ($Debug); +use vars qw($Debug); our $VERSION = '0.001'; our $Opt_Widen = 1; @@ -18,7 +18,7 @@ our $Opt_Widen = 1; autoflush STDOUT 1; autoflush STDERR 1; -Getopt::Long::config ("no_auto_abbrev"); +Getopt::Long::config("no_auto_abbrev"); if (! GetOptions ( "debug" => sub { $Debug = 1; }, "help" => sub { print "Version $VERSION\n"; diff --git a/nodist/install_test b/nodist/install_test index aea80740b..d37c86c63 100755 --- a/nodist/install_test +++ b/nodist/install_test @@ -7,7 +7,7 @@ use Cwd; use IO::File; use Pod::Usage; use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== # main @@ -17,7 +17,7 @@ our $Opt_Jobs = calc_jobs(); autoflush STDOUT 1; autoflush STDERR 1; -Getopt::Long::config ("no_auto_abbrev"); +Getopt::Long::config("no_auto_abbrev"); if (! GetOptions ( "debug" => sub { $Debug = 1; }, "<>" => sub { die "%Error: Unknown parameter: $_[0]\n"; }, diff --git a/nodist/vtree_importer b/nodist/vtree_importer index e7bf9f165..85fbbcd95 100755 --- a/nodist/vtree_importer +++ b/nodist/vtree_importer @@ -8,7 +8,7 @@ use IO::File; use Pod::Usage; use Data::Dumper; $Data::Dumper::Indent=1; use strict; -use vars qw ($Debug); +use vars qw($Debug); #====================================================================== @@ -31,7 +31,7 @@ if (! GetOptions ( usage(); } -vread ($opt_filename); +vread($opt_filename); #print Dumper($Tree); vwrite(); @@ -41,7 +41,7 @@ print '(query-replace-regexp "(\\([0-9a-z_]+\\))" "\\1" nil nil nil)',"\n"; sub usage { pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); - exit (1); + exit(1); } sub debug {