当前位置:   article > 正文

Verilator_assertion failed: verilator invocation failed

assertion failed: verilator invocation failed

https://en.wikipedia.org/wiki/Verilator

https://www.veripool.org/projects/verilator/wiki/Installing

https://www.veripool.org/ftp/verilator_doc.pdf

https://www.veripool.org/wiki/verilator/Manual-verilator

-------------------------------------------------------------------------------------------------------------

Other users have reported the following relative performance on their designs: (Note they seem contradictory, as they refer to differing designs.)

  • Verilator is 90x faster than Icarus Verilog.
  • Verilator is 10-40x faster than Modelsim SE.
  • Verilator is 3x faster than NC-Verilog.
  • Verilator is 1.5x faster than VCS.
  • VTOC is 4x faster than Verilator.
  • VTOC is 50x faster than NC-Verilog.
  • VCS is 3x faster than Verilator.
  • VCS is 3x faster than NC-Verilog.
  • VCS is 10x faster than NC-Verilog.
  • VCS is the same speed as NC-Verilog.
  • CVer is the same speed as Icarus Verilog.

--------------------------------------------------------------------------------

Icarus 就是iverilog

http://iverilog.icarus.com/

http://bleyer.org/icarus/

https://segmentfault.com/a/1190000011059615

windows下安装:

https://www.cnblogs.com/goco/p/11399799.html

https://zhuanlan.zhihu.com/p/33443736

仿真步骤:

所需文件是4个,准备3个文件及仿真工程:

 

Makefile

Sim_main.cpp

vc文件

mk文件

Makefile文件:

  1. #*****************************************************************************
  2. #
  3. # DESCRIPTION: Verilator Example: Makefile for inside source directory
  4. #
  5. # This calls the object directory makefile. That allows the objects to
  6. # be placed in the "current directory" which simplifies the Makefile.
  7. #
  8. # Copyright 2003-2017 by Wilson Snyder. This program is free software; you can
  9. # redistribute it and/or modify it under the terms of either the GNU
  10. # Lesser General Public License Version 3 or the Perl Artistic License
  11. # Version 2.0.
  12. #
  13. #****************************************************************************/
  14. default: show_config test_default
  15. # This must point to the root of the VERILATOR kit
  16. #VERILATOR_ROOT := $(shell pwd)/..
  17. #export VERILATOR_ROOT
  18. CURRENT_PATH := $(shell pwd)
  19. # Pick up PERL and other variable settings
  20. include $(VERILATOR_ROOT)/include/verilated.mk
  21. DEBUG_QUIET = --debug --debugi 0 --gdbbt --no-dump-tree
  22. DEBUG_ON = --debug --trace-dups --gdbbt
  23. #DEBUG = $(DEBUG_ON)
  24. VALGRIND_ON = $(DEBUG_ON) --gdb "valgrind -v --leak-check=yes"
  25. ######################################################################
  26. test_default: prep compile run wave
  27. test_debug: prep_dbg compile run
  28. test_valgrind: prep_vg compile run
  29. #VERILATOR_FLAGS = --cc -f $(VERILATOR_ROOT)/test_v/input.vc top.v
  30. VERILATOR_FLAGS = --cc -f $(CURRENT_PATH)/input.vc $(CURRENT_PATH)/top.v
  31. VERILATOR_FLAGS += --trace
  32. #show_config: Is the very first time we've executed Verilator after building
  33. #so we make sure to run with --gdbbt, so if it dumps we'll get a trace.
  34. show_config:
  35. $(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_QUIET) -V
  36. #prep: Is the very first time we're running a Verilation
  37. #so we make sure to run with --gdbbt, so if it dumps we'll get a trace.
  38. prep:
  39. $(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_QUIET) $(VERILATOR_FLAGS)
  40. prep_dbg:
  41. $(PERL) $(VERILATOR_ROOT)/bin/verilator $(DEBUG_ON) $(VERILATOR_FLAGS)
  42. prep_vg:
  43. $(PERL) $(VERILATOR_ROOT)/bin/verilator $(VALGRIND_ON) $(VERILATOR_FLAGS)
  44. compile:
  45. cd obj_dir ; $(MAKE) -j 3 -f ../Makefile_obj
  46. run:
  47. obj_dir/simx
  48. wave:
  49. gtkwave $(CURRENT_PATH)/vlt_dump.vcd
  50. ######################################################################
  51. obj_dir:
  52. mkdir $@
  53. ######################################################################
  54. maintainer-copy::
  55. clean mostlyclean distclean maintainer-clean::
  56. -rm -rf obj_dir *.log *.dmp *.vpd core

Sim_main.cpp

  1. // DESCRIPTION: Verilator Example: Top level main for invoking model
  2. //
  3. // Copyright 2003-2017 by Wilson Snyder. This program is free software; you can
  4. // redistribute it and/or modify it under the terms of either the GNU
  5. // Lesser General Public License Version 3 or the Perl Artistic License
  6. // Version 2.0.
  7. #include <verilated.h> // Defines common routines
  8. #include "Vtop.h" // From Verilating "top.v"
  9. #if VM_TRACE
  10. # include <verilated_vcd_c.h> // Trace file format header
  11. #endif
  12. Vtop *top; // Instantiation of module
  13. vluint64_t main_time = 0; // Current simulation time (64-bit unsigned)
  14. double sc_time_stamp () { // Called by $time in Verilog
  15. return main_time; // Note does conversion to real, to match SystemC
  16. }
  17. int main(int argc, char **argv, char **env) {
  18. if (0 && argc && argv && env) {} // Prevent unused variable warnings
  19. top = new Vtop; // Create instance of module
  20. Verilated::commandArgs(argc, argv);
  21. Verilated::debug(0);
  22. #if VM_TRACE // If verilator was invoked with --trace
  23. Verilated::traceEverOn(true); // Verilator must compute traced signals
  24. VL_PRINTF("Enabling waves...\n");
  25. VerilatedVcdC* tfp = new VerilatedVcdC;
  26. top->trace (tfp, 99); // Trace 99 levels of hierarchy
  27. tfp->open ("vlt_dump.vcd"); // Open the dump file
  28. #endif
  29. top->rst_n = 0; // Set some inputs
  30. top->en = 0;
  31. top->clk = 0;
  32. while (main_time < 60) {
  33. if (main_time == 3) { // Toggle clock
  34. top->rst_n = 1;
  35. }
  36. else if(main_time == 6){
  37. top->en = 1;
  38. }
  39. top->eval(); // Evaluate model
  40. #if VM_TRACE
  41. if (tfp) tfp->dump (main_time); // Create waveform trace for this timestamp
  42. #endif
  43. // Read outputs
  44. //VL_PRINTF ("[%" VL_PRI64 "d] %x %x %x %x %x_%08x_%08x\n",
  45. // main_time, top->clk, top->reset_l, top->passed,
  46. // top->out_small, top->out_wide[2], top->out_wide[1], top->out_wide[0]);
  47. top->clk = !top->clk;
  48. main_time++; // Time passes...
  49. }
  50. top->final();
  51. #if VM_TRACE
  52. if (tfp) tfp->close();
  53. #endif
  54. /* if (!top->passed) {
  55. VL_PRINTF ("A Test failed\n");
  56. abort();
  57. } else {
  58. VL_PRINTF ("All Tests passed\n");
  59. }
  60. */
  61. exit(0L);
  62. }

vc文件:是工程路径包含文件

input.vc

  1. +librescan +libext+.v
  2. -y .
  3. +incdir+.
  4. +incdir+$(VERILATOR)/include

mk文件:是编译生成文件

仿真源文件:top.v

  1. //
  2. //
  3. module top(
  4. input clk,
  5. input rst_n,
  6. input en,
  7. output clk_o,
  8. output clk_on
  9. );
  10. clk_div #(
  11. .PMT_CNTT(16'd1)
  12. )
  13. clk_div_i(
  14. .clk(clk),
  15. .rst_n(rst_n),
  16. .en(en),
  17. .cnt_o(clk_o),
  18. .cnt_on(clk_on)
  19. );
  20. endmodule

clk_div.v

  1. /*
  2. PMT_CNTT = 1 , div 2
  3. in clk:_|-|_|-|
  4. out cnt_o:___|---|
  5. PMT_CNTT = 2 , div 4
  6. PMT_CNTT = 3 , div 6
  7. : :
  8. */
  9. module clk_div
  10. #( parameter PMT_CNTT = 16'd2)
  11. (
  12. input clk,
  13. input rst_n,
  14. input en,
  15. output reg cnt_o,
  16. output cnt_on
  17. );
  18. /* verilator lint_off UNSIGNED */
  19. assign cnt_on = ~ cnt_o;
  20. reg[15:0] CNT_REG;
  21. always @ ( posedge clk or negedge rst_n)
  22. begin
  23. if( (~rst_n) || (~en))
  24. begin
  25. CNT_REG <= 'b0;
  26. end
  27. else
  28. begin
  29. if(CNT_REG < (PMT_CNTT - 16'd1))
  30. begin
  31. CNT_REG <= CNT_REG + 16'd1;
  32. end
  33. else
  34. begin
  35. CNT_REG<='d0;
  36. end
  37. end
  38. end
  39. //
  40. always @ ( posedge clk or negedge rst_n)
  41. begin
  42. if( (~rst_n) || (~en))
  43. begin
  44. cnt_o <= 'b1;
  45. end
  46. else
  47. begin
  48. if(CNT_REG == PMT_CNTT - 16'd1)
  49. begin
  50. cnt_o <= ~cnt_o;
  51. end
  52. else
  53. begin
  54. cnt_o <= cnt_o;
  55. end
  56. end
  57. end
  58. endmodule

指令说明:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/912410
推荐阅读
相关标签
  

闽ICP备14008679号