aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2021-03-17 00:18:36 +0100
committerZachary Snow <zachary.j.snow@gmail.com>2021-03-17 11:44:03 -0400
commit092e923330ce23adffa7843a27bdba8a0b139e58 (patch)
tree08bed305ed18522ae38b0718de8fdffa04814d1f /frontends
parentdd6d34f461910a120ac95c485fe34cca6485b95e (diff)
downloadyosys-092e923330ce23adffa7843a27bdba8a0b139e58.tar.gz
yosys-092e923330ce23adffa7843a27bdba8a0b139e58.tar.bz2
yosys-092e923330ce23adffa7843a27bdba8a0b139e58.zip
verilog: fix buf/not primitives with multiple outputs
From IEEE1364-2005, section 7.3 buf and not gates: > These two logic gates shall have one input and one or more outputs. > The last terminal in the terminal list shall connect to the input of the > logic gate, and the other terminals shall connect to the outputs of > the logic gate. yosys does not follow this and instead interprets the first argument as the output, the second as the input and ignores the rest.
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/simplify.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index d9eae3a06..b9965ba99 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -2223,6 +2223,21 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
children.push_back(node);
did_something = true;
}
+ else if (str == "buf" || str == "not")
+ {
+ AstNode *input = children_list.back();
+ if (str == "not")
+ input = new AstNode(AST_BIT_NOT, input);
+
+ newNode = new AstNode(AST_GENBLOCK);
+ for (auto it = children_list.begin(); it != std::prev(children_list.end()); it++) {
+ newNode->children.push_back(new AstNode(AST_ASSIGN, *it, input->clone()));
+ newNode->children.back()->was_checked = true;
+ }
+ delete input;
+
+ did_something = true;
+ }
else
{
AstNodeType op_type = AST_NONE;
@@ -2240,10 +2255,6 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
op_type = AST_BIT_XOR;
if (str == "xnor")
op_type = AST_BIT_XOR, invert_results = true;
- if (str == "buf")
- op_type = AST_POS;
- if (str == "not")
- op_type = AST_POS, invert_results = true;
log_assert(op_type != AST_NONE);
AstNode *node = children_list[1];