mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-29 23:43:16 +00:00
sv: Fix typedef parameters
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
f6b5e47e40
commit
c962951612
4 changed files with 70 additions and 9 deletions
|
@ -790,8 +790,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
|||
log_assert(!children[0]->is_custom_type);
|
||||
}
|
||||
|
||||
// resolve types of wires and parameters
|
||||
if (type == AST_WIRE || type == AST_LOCALPARAM || type == AST_PARAMETER) {
|
||||
// resolve types of wires
|
||||
if (type == AST_WIRE) {
|
||||
if (is_custom_type) {
|
||||
log_assert(children.size() == 1);
|
||||
log_assert(children[0]->type == AST_WIRETYPE);
|
||||
|
@ -820,6 +820,35 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
|||
log_assert(!is_custom_type);
|
||||
}
|
||||
|
||||
// resolve types of parameters
|
||||
if (type == AST_LOCALPARAM || type == AST_PARAMETER) {
|
||||
if (is_custom_type) {
|
||||
log_assert(children.size() == 2);
|
||||
log_assert(children[1]->type == AST_WIRETYPE);
|
||||
if (!current_scope.count(children[1]->str))
|
||||
log_file_error(filename, linenum, "Unknown identifier `%s' used as type name", children[1]->str.c_str());
|
||||
AstNode *resolved_type = current_scope.at(children[1]->str);
|
||||
if (resolved_type->type != AST_TYPEDEF)
|
||||
log_file_error(filename, linenum, "`%s' does not name a type", children[1]->str.c_str());
|
||||
log_assert(resolved_type->children.size() == 1);
|
||||
AstNode *templ = resolved_type->children[0];
|
||||
delete children[1];
|
||||
children.pop_back();
|
||||
|
||||
is_signed = templ->is_signed;
|
||||
is_string = templ->is_string;
|
||||
is_custom_type = templ->is_custom_type;
|
||||
|
||||
range_valid = templ->range_valid;
|
||||
range_swapped = templ->range_swapped;
|
||||
range_left = templ->range_left;
|
||||
range_right = templ->range_right;
|
||||
for (auto template_child : templ->children)
|
||||
children.push_back(template_child->clone());
|
||||
}
|
||||
log_assert(!is_custom_type);
|
||||
}
|
||||
|
||||
// resolve constant prefixes
|
||||
if (type == AST_PREFIX) {
|
||||
if (children[0]->type != AST_CONSTANT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue