Navigation Menu

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

Verilator mis-searches for modules with double underscores with __05F #631

Closed
veripoolbot opened this issue Mar 11, 2013 · 7 comments
Closed
Assignees
Labels
resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Jason McMullan (@ezrec)
Original Redmine Issue: 631 from https://www.veripool.org
Original Date: 2013-03-11
Original Assignee: Wilson Snyder (@wsnyder)


I am working with a codebase with a number of models of the form of
section__module.v, and the default name mangling of Verilator would necessitate that I rename them all to section__05Fmodule.v

With the following change, verilator now only mangles a double underscore if it is at the start of a name:

ie:

__encode__me => __05Fencode__me
encode__me   => encode__me

--- a/src/V3Ast.cpp
+++ b/src/V3Ast.cpp
@@ -100,7 +100,7 @@ string AstNode::encodeName(const string& namein) {
             : isalnum(pos[0])) {
             out += pos[0];
         } else if (pos[0]=='_') {
-           if (pos[1]=='_') {
+           if (start == pos && pos[1]=='_') {
                 out += "_"; out += "__05F";  // hex(_) = 0x5F
                 pos++;
             } else {

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-03-11T19:13:57Z


This isn't a sufficient fix, because for example section__5F, which is a legal identifier will be mishandled and reported as section___, and worse anything in DOT or other special stuff will be very wrong; all the internals assume all double underscores are made safe for internal use even not at the beginning. Sorry.

You should be able to make all verilator-internal __ into ___, but there's probably a lot.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jason McMullan (@ezrec)
Original Date: 2013-03-11T19:19:13Z


Agreed on all counts, I just thought it was strange that verilator would insist on a filename that didn't match the model name.

Would a better solution be to demangle the verilator name when doing the path search?

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-03-11T19:23:48Z


Wait, what?

No you should never see a _5F needed anywhere but in the C structure and class names. So if you create a model the output .c file will have a _5F, but nothing in Verilog never should; if that's not the case please describe what is needing it.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jason McMullan (@ezrec)
Original Date: 2013-03-12T01:59:59Z


Simple example where verilator fails to find a module with double underscores in the -y search path:

find__me.v

module find__me; endmodule

testcase.v

module testcase;
find__me found;
endmodule

 $ verilator --lint-only testcase.v -y .
%Error: testcase.v:4: Cannot find file containing module: find___05Fme
%Error: testcase.v:4: Looked in:
%Error: testcase.v:4:       find___05Fme
%Error: testcase.v:4:       find___05Fme.v
%Error: testcase.v:4:       find___05Fme.sv
%Error: testcase.v:4:       obj_dir/find___05Fme
%Error: testcase.v:4:       obj_dir/find___05Fme.v
%Error: testcase.v:4:       obj_dir/find___05Fme.sv
%Error: Exiting due to 8 error(s)
%Error: Command Failed /usr/bin/verilator_bin --lint-only testcase.v -y .

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-03-12T11:29:14Z


Surprised no one noticed that until now. Fixed along with a bunch of warnings that also mis-used the __5F.

Fixed in git towards 3.847.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-05-11T20:17:20Z


In 3.847.

@klcheungaj
Copy link

Original Redmine Comment
Author Name: Jason McMullan (@ezrec)
Original Date: 2013-03-11T19:19:13Z

Agreed on all counts, I just thought it was strange that verilator would insist on a filename that didn't match the model name.

Would a better solution be to demangle the verilator name when doing the path search?

I'm also curious why file name should match module name in order to make directory searching work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

3 participants