Skip to content

Commit

Permalink
svlog: Fix ports with expl dir carrying over data
Browse files Browse the repository at this point in the history
Fix an issue in the `port_list` module where a port with an explicit
direction would still carry over the previous port's type and sign. This
should instead reset everything to the default.

Fixes #224.
  • Loading branch information
fabianschuiki committed Mar 30, 2021
1 parent 0d98ec2 commit eb4d44c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Fix ports with explicit direction carrying over previous port type data (#224)

## 0.12.0 - 2021-01-09
### Added
Expand Down
17 changes: 14 additions & 3 deletions src/svlog/port_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,26 @@ fn lower_node_ports_ansi<'a>(
expr,
} => {
// If no direction has been provided, use the one carried over
// from the previous port.
let dir = dir.unwrap_or(carry_dir);
// from the previous port. Explicitly specifying a direction
// clears the carried kind, type, sign, and packed dimensions to
// their defaults.
let dir = match *dir {
Some(dir) => {
carry_kind = None;
carry_ty = Cow::Owned(ast::TypeKind::new(port.span(), ast::LogicType));
carry_sign = ast::TypeSign::None;
carry_packed_dims = &[];
dir
}
None => carry_dir,
};

// If no port kind has been provided, use the one carried over
// from the previous port.
let kind = kind.or(carry_kind);

// If no port type has been provided, use the one carried over
// from the previous port.
// from the previous port.
let (ty, sign, packed_dims, ty_span) = if ty.kind.data == ast::ImplicitType
&& ty.sign == ast::TypeSign::None
&& ty.dims.is_empty()
Expand Down
10 changes: 10 additions & 0 deletions test/svlog/regr/iss224_port_type_carry.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: moore %s -e A

module A;
wire [31:0] x;
wire y;
B system_bus_xbar (.x(x), .y(y));
endmodule

module B (input [31:0] x, output y);
endmodule

0 comments on commit eb4d44c

Please sign in to comment.