From bef9b1a3f06c9db3a1fef0e6d9489f7a4f8780f8 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Wed, 26 Jul 2023 23:42:51 -0400 Subject: [PATCH] allow inout task and function ports --- CHANGELOG.md | 4 ++++ src/Language/SystemVerilog/Parser/Parse.y | 5 ++--- test/basic/task_inout.sv | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/basic/task_inout.sv diff --git a/CHANGELOG.md b/CHANGELOG.md index a9db5d7..6cb18a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ * Removed deprecated CLI flags `-d`/`-e`/`-i`, which have been aliased to `-D`/`-E`/`-I` with a warning since late 2019 +### Bug Fixes + +* Fixed an issue that prevented parsing tasks and functions with `inout` ports + ## v0.0.11 ### New Features diff --git a/src/Language/SystemVerilog/Parser/Parse.y b/src/Language/SystemVerilog/Parser/Parse.y index 5a0d56e..8e195d3 100644 --- a/src/Language/SystemVerilog/Parser/Parse.y +++ b/src/Language/SystemVerilog/Parser/Parse.y @@ -1604,9 +1604,8 @@ combineDeclsAndStmts (a1, b1) (a2, b2) = else return (a1 ++ a2, b1 ++ b2) makeInput :: Decl -> Decl -makeInput (Variable Local t x a e) = Variable Input t x a e -makeInput (Variable Input t x a e) = Variable Input t x a e -makeInput (Variable Output t x a e) = Variable Output t x a e +makeInput (Variable d t x a e) = Variable d' t x a e + where d' = if d == Local then Input else d makeInput (CommentDecl c) = CommentDecl c makeInput other = error $ "unexpected non-var or non-port function decl: " ++ (show other) diff --git a/test/basic/task_inout.sv b/test/basic/task_inout.sv new file mode 100644 index 0000000..29519cf --- /dev/null +++ b/test/basic/task_inout.sv @@ -0,0 +1,20 @@ +module top; + task t(inout [7:0] x, y); + begin + x = ~x; + if (y) begin + x = x * 3; + y = y + 1; + end + end + endtask + reg [7:0] a, b; + always @* t(a, b); + initial begin + a = 0; + b = 1; + $monitor("%d %b %b", $time, a, b); + repeat (100) + #5 b = b * 3 - 1; + end +endmodule