mirror of https://github.com/YosysHQ/yosys.git
Module name scope support
This commit is contained in:
parent
082cbcb4c7
commit
6127f22788
|
@ -1597,6 +1597,13 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
|
||||||
if (type == AST_IDENTIFIER) {
|
if (type == AST_IDENTIFIER) {
|
||||||
if (current_scope.count(str) == 0) {
|
if (current_scope.count(str) == 0) {
|
||||||
AstNode *current_scope_ast = (current_ast_mod == nullptr) ? current_ast : current_ast_mod;
|
AstNode *current_scope_ast = (current_ast_mod == nullptr) ? current_ast : current_ast_mod;
|
||||||
|
const std::string& mod_scope = current_scope_ast->str;
|
||||||
|
if (str[0] == '\\' && str.substr(0, mod_scope.size()) == mod_scope) {
|
||||||
|
std::string new_str = "\\" + str.substr(mod_scope.size() + 1);
|
||||||
|
if (current_scope.count(new_str)) {
|
||||||
|
str = new_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (auto node : current_scope_ast->children) {
|
for (auto node : current_scope_ast->children) {
|
||||||
//log("looking at mod scope child %s\n", type2str(node->type).c_str());
|
//log("looking at mod scope child %s\n", type2str(node->type).c_str());
|
||||||
switch (node->type) {
|
switch (node->type) {
|
||||||
|
|
|
@ -223,6 +223,10 @@ module gen_test8;
|
||||||
`ASSERT(A.x == 2)
|
`ASSERT(A.x == 2)
|
||||||
`ASSERT(A.C.x == 1)
|
`ASSERT(A.C.x == 1)
|
||||||
`ASSERT(A.B.x == 0)
|
`ASSERT(A.B.x == 0)
|
||||||
|
`ASSERT(gen_test8.x == 3)
|
||||||
|
`ASSERT(gen_test8.A.x == 2)
|
||||||
|
`ASSERT(gen_test8.A.C.x == 1)
|
||||||
|
`ASSERT(gen_test8.A.B.x == 0)
|
||||||
end
|
end
|
||||||
begin : C
|
begin : C
|
||||||
wire [1:0] x = 2'b01;
|
wire [1:0] x = 2'b01;
|
||||||
|
@ -230,12 +234,20 @@ module gen_test8;
|
||||||
`ASSERT(A.x == 2)
|
`ASSERT(A.x == 2)
|
||||||
`ASSERT(A.C.x == 1)
|
`ASSERT(A.C.x == 1)
|
||||||
`ASSERT(A.B.x == 0)
|
`ASSERT(A.B.x == 0)
|
||||||
|
`ASSERT(gen_test8.x == 3)
|
||||||
|
`ASSERT(gen_test8.A.x == 2)
|
||||||
|
`ASSERT(gen_test8.A.C.x == 1)
|
||||||
|
`ASSERT(gen_test8.A.B.x == 0)
|
||||||
end
|
end
|
||||||
assign x = B.x ^ 2'b11 ^ C.x;
|
assign x = B.x ^ 2'b11 ^ C.x;
|
||||||
`ASSERT(x == 2)
|
`ASSERT(x == 2)
|
||||||
`ASSERT(A.x == 2)
|
`ASSERT(A.x == 2)
|
||||||
`ASSERT(A.C.x == 1)
|
`ASSERT(A.C.x == 1)
|
||||||
`ASSERT(A.B.x == 0)
|
`ASSERT(A.B.x == 0)
|
||||||
|
`ASSERT(gen_test8.x == 3)
|
||||||
|
`ASSERT(gen_test8.A.x == 2)
|
||||||
|
`ASSERT(gen_test8.A.C.x == 1)
|
||||||
|
`ASSERT(gen_test8.A.B.x == 0)
|
||||||
end
|
end
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
|
@ -243,4 +255,8 @@ module gen_test8;
|
||||||
`ASSERT(A.x == 2)
|
`ASSERT(A.x == 2)
|
||||||
`ASSERT(A.C.x == 1)
|
`ASSERT(A.C.x == 1)
|
||||||
`ASSERT(A.B.x == 0)
|
`ASSERT(A.B.x == 0)
|
||||||
|
`ASSERT(gen_test8.x == 3)
|
||||||
|
`ASSERT(gen_test8.A.x == 2)
|
||||||
|
`ASSERT(gen_test8.A.C.x == 1)
|
||||||
|
`ASSERT(gen_test8.A.B.x == 0)
|
||||||
endmodule
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue