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

Hierarchical Signal Access #202

Closed
Seek64 opened this issue Jul 28, 2022 · 2 comments
Closed

Hierarchical Signal Access #202

Seek64 opened this issue Jul 28, 2022 · 2 comments

Comments

@Seek64
Copy link

Seek64 commented Jul 28, 2022

Hello everyone,

I was playing around with the unbounded prover example:

module testbench (
  input clk,
  input reset,
  input [7:0] din,
  output reg [7:0] dout
);
  demo uut (
    .clk  (clk  ),
    .reset(reset),
    .din  (din  ),
    .dout (dout )
  );

  reg init = 1;
  always @(posedge clk) begin
    if (init) assume (reset);
    if (!reset) assert (!dout[1:0]);
    init <= 0;
  end
endmodule

module demo (
  input clk,
  input reset,
  input [7:0] din,
  output reg [7:0] dout
);
  reg [7:0] buffer;
  reg [1:0] state;

  always @(posedge clk) begin
    if (reset) begin
      dout <= 0;
      state <= 0;
    end else
    case (state)
      0: begin
        buffer <= din;
	state <= 1;
      end
      1: begin
        if (buffer[1:0])
	  buffer <= buffer + 1;
	else
	  state <= 2;
      end
      2: begin
        dout <= dout + buffer;
	state <= 0;
      end
    endcase
  end
endmodule

My question is if there is a way to access the submodule signals from the testbench itself?
Essentially, what I would like to do is something like:

if (!reset) assert (uut.state!=3);

If I try it like this, what I get is the following warning

Warning: Identifier `\uut.state' is implicitly declared.

and the assertion is ignored during the proof.

The two workarounds I tried were

  • Putting the assertion directly into the demo module
  • Creating a separate output for the state signal

Both of them worked. For my use case, however, I would like to compare the signals of the different submodules. Therefore, only the second option would be viable.
However, creating a separate output for each signal I want to compare seems very cumbersome, so I would like to know if hierarchical access is also possible somehow?

@nakengelhardt
Copy link
Member

No, unfortunately hierarchical access is only possible using the verific frontend (available in the commercial Tabby CAD Suite only). There is an effort to implement it for read_verilog by an external contributor but it seems currently stalled: YosysHQ/yosys#2752

@Seek64
Copy link
Author

Seek64 commented Aug 1, 2022

Thank you for the response. I will then resort to the workaround for the time being and also have a look at the PR.

@Seek64 Seek64 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants