-
-
Notifications
You must be signed in to change notification settings - Fork 89
Parse ANSI parameters declaration #1160
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
Open
Anselmo95
wants to merge
2
commits into
nickg:master
Choose a base branch
from
Anselmo95:ansiparams
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3260,6 +3260,33 @@ static void p_list_of_port_declarations(vlog_node_t mod) | |
consume(tRPAREN); | ||
} | ||
|
||
static void p_ansi_parameter_declaration(vlog_node_t mod) | ||
{ | ||
// parameter data_type_or_implicit parameter_assigment | ||
|
||
BEGIN("ANSI parameter declaration"); | ||
|
||
consume(tPARAMETER); | ||
|
||
vlog_node_t dt = p_data_type_or_implicit(); | ||
vlog_add_decl(mod, p_param_assignment(dt)); | ||
} | ||
|
||
static void p_list_of_param_declarations(vlog_node_t mod) | ||
{ | ||
// parameter_port_list ::= ansi_param_assignments { , ansi_param_assignments } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm using the System Verilog grammar rather than the traditional Verilog one |
||
|
||
BEGIN("list of parameter declarations"); | ||
|
||
consume(tHASHLPAREN); | ||
|
||
do { | ||
p_ansi_parameter_declaration(mod); | ||
} while (optional(tCOMMA)); | ||
|
||
consume(tRPAREN); | ||
} | ||
|
||
static void p_module_ansi_header(vlog_node_t mod) | ||
{ | ||
// { attribute_instance } module_keyword [ lifetime ] module_identifier | ||
|
@@ -3268,6 +3295,9 @@ static void p_module_ansi_header(vlog_node_t mod) | |
|
||
EXTEND("module ANSI header"); | ||
|
||
if (peek() == tHASHLPAREN) | ||
p_list_of_param_declarations(mod); | ||
|
||
if (peek() == tLPAREN) | ||
p_list_of_port_declarations(mod); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module param2 #( | ||
parameter [7:0] p1 = 8'd5, | ||
parameter p2 = 8 | ||
); | ||
assign w1 = p1; // OK | ||
parameter logic p1 = 1; // Error | ||
endmodule // param2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
#(
is a single token. It's shown with a space between it them the grammar in the standard (e.g. page 1138 of 1800-2017) and also here:https://www.sigasi.com/tech/systemverilog.ebnf/#module-parameters-and-ports
Icarus Verilog and Verilator also both treat the
#
and(
as separate tokens.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks for the review I wasn't aware that they were separate tokens, I'll try to look better into the syntax and adjust the code. It's gonna take a bit of time though