Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fails with certain optimizations disabled #1024

Closed
veripoolbot opened this issue Jan 18, 2016 · 3 comments
Closed

Test fails with certain optimizations disabled #1024

veripoolbot opened this issue Jan 18, 2016 · 3 comments
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: no fix needed Closed; no fix required (not a bug)

Comments

@veripoolbot
Copy link
Contributor


Author Name: Johan Bjork
Original Redmine Issue: 1024 from https://www.veripool.org
Original Date: 2016-01-18


While investigating a different issue I found that the following combination of optimization levels successfully compiles but fails the test.

// No inline, no const folding, no gate wire elimination
./t_param_ceil.pl --debug -Oi -Og -Oc

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Johan Bjork
Original Date: 2016-01-19T00:37:10Z


It seems to happen when an initial block references something that gets passed through at least one module. A single level works fine (ie, replace SetStuff with "tester" in the below example and it works

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2010 by Wilson Snyder.

module t (/*AUTOARG*/);

    /*AUTOWIRE*/
    // Beginning of automatic wires (for undeclared instantiated-module outputs)
    wire [31:0]		O_out;			// From test of Test.v
    // End of automatics

    SetStuff test (/*AUTOINST*/
	      // Outputs
	      .O_out			(O_out));

    initial begin
       if (O_out != 32'h4) $stop;
       $write("*-* All Finished *-*\n");
       $finish;
    end

endmodule

module SetStuff
  (
    output [31:0] O_out
    );

    tester t5
    (
  	.O_out(O_out)
	 );

endmodule

module tester
    (
     output [31:0] O_out
     );
    assign O_out = 4;
endmodule

```

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2016-01-21T03:24:31Z


When the inliner is working, it flattens the variable, so the test works.

When not, there's two initial statements, with a wire that must propagate results between them.

Verilog doesn't guarantee ordering between initial statements, much less with a continuous assignment in the middle, so either behavior is legal.

With other then verilator, an e.g. "#1;" would be required to let things propagate. In verilator tests, I generally use an "always @ (posedge clk)" around the value and $finish, for this exact ordering reason.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Johan Bjork
Original Date: 2016-01-21T03:27:43Z


Perfect, thanks for the great explanation.

@veripoolbot veripoolbot added area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: nofixneeded resolution: no fix needed Closed; no fix required (not a bug) and removed resolution: nofixneeded labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: no fix needed Closed; no fix required (not a bug)
Projects
None yet
Development

No branches or pull requests

1 participant