question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Verilator Double-Triggering

See original GitHub issue

I’ve run into a bug where rising edges of clocks will double-trigger, when using Verilator as a simulator.

Here is a minimum reproduction of the design that causes the issue:

module test(input wire clk);
    reg clkdiv2;
    always @(posedge clk) begin
        clkdiv2 <= ~clkdiv2;
    end
endmodule

See this gist for my full test setup.

I can’t seem to get the example to trigger at all in iverilog, so I don’t entirely know if it’s Verilator or CocoTB. I’m assuming iverilog is optimizing out clkdiv2 but I’m not sure how to fix that.

EDIT:

Specifically what’s happening is the following statement:

await RisingEdge(dut.clkdiv2)
print(get_sim_time())

Triggers twice per clock edge. (Also tested with FallingEdge, Edge, and ClockCycles)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
davidlenfestycommented, Nov 30, 2020

I can confirm that the issue has been fixed, running a fresh build: Verilator 4.105 devel rev v4.104-81-gd21b4e3f.

The infinite loop issue I believe was related has also been fixed!

0reactions
marlonjamescommented, Nov 30, 2020

@davidlenfesty Can you check if this issue is still occuring? verilator/verilator#2644 may have fixed this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Verilator 5.005 documentation
Verilator reads the input Verilog code and determines all “top modules”, that is, modules or programs that are not used as instances under...
Read more >
cocotb/Lobby - Gitter
Seeing some unexpected behavior with Verilator. ... are called again after the readwrite callbacks without an eval, which is the cause of double...
Read more >
FAQ/Frequently Asked Questions — Verilator 5.005 ... - Veripool
Verilator is one of the “big 4” simulators, meaning one of the four leading ... Any of your VPI/DPI C++ routines that Verilator...
Read more >
Verilator Pt.1: Introduction - It's Embedded!
To simulate a design using Verilator, a native binary executable is built from the verilated HDL code and the C++ testbench using GCC...
Read more >
Taking a New Look at Verilator - ZipCPU
You will start by running the Verilator command line program on your top level Verilog file. For the purposes of this discussion, let's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found