diff --git a/include/verilated.cpp b/include/verilated.cpp index b32c99ad9..53f1b3999 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -143,6 +143,15 @@ WDataOutP VL_ZERO_RESET_W(int obits, WDataOutP outwp) { return outwp; } +//=========================================================================== +// Debug + +void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp) { + VL_PRINTF(" Data: w%d: ", lbits); + for (int i=VL_WORDS_I(lbits)-1; i>=0; i--) { VL_PRINTF("%08x ",iwp[i]); } + VL_PRINTF("\n"); +} + //=========================================================================== // Slow math diff --git a/include/verilated.h b/include/verilated.h index 1a8e20896..6ebb3e83b 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -328,11 +328,7 @@ static inline IData VL_EXTENDSIGN_I(int lbits, IData lhs) { return (-((lhs)&(VL static inline QData VL_EXTENDSIGN_Q(int lbits, QData lhs) { return (-((lhs)&(VL_ULL(1)<<(lbits-1)))); } // Debugging prints -static inline void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp) { - printf(" Data: w%d: ", lbits); - for (int i=VL_WORDS_I(lbits)-1; i>=0; i--) { printf("%08x ",iwp[i]); } - printf("\n"); -} +void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp); //========================================================================= // Pli macros diff --git a/src/V3Error.h b/src/V3Error.h index b7f83943e..d39367724 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -203,7 +203,7 @@ inline void v3errorEnd(ostringstream& sstr) { V3Error::v3errorEnd(sstr); } // For use in V3Ast static functions only #define UASSERT_STATIC(condition,stmsg) { if (!(condition)) { cerr<<"Internal Error: "<<__FILE__<<":"< \&debug, "gdb!" => \$opt_gdb, "gdbbt!" => \$opt_gdbbt, + "gdbsim!" => \$opt_gdbsim, "help" => \&usage, "iverilog!" => \$opt_iv, "j=i" => \$opt_jobs, @@ -531,7 +533,8 @@ sub execute { #&& (!$param{needs_v4} || -r "$ENV{VERILATOR_ROOT}/src/V3Gate.cpp") ) { $self->_run(logfile=>"$self->{obj_dir}/vlt_sim.log", - cmd=>["$self->{obj_dir}/$param{VM_PREFIX}", + cmd=>[(($opt_gdbsim ? "gdbrun ":"") + ."$self->{obj_dir}/$param{VM_PREFIX}"), @{$param{all_run_flags}}, ], %param, @@ -1143,13 +1146,17 @@ specifies the number of simulation cycles (for tests that support it). =item --gdb -Run verilator under the debugger. +Run Verilator under the debugger. =item --gdbbt -Run verilator under the debugger, only to print backtrace information. +Run Verilator under the debugger, only to print backtrace information. Requires --debug. +=item --gdbsim + +Run Verilator generated executable under the debugger. + =item --help Displays this message and program version and exits.