Skip to content

Commit

Permalink
add support for high impedance state 'bZ (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
peppergrayxyz authored Jan 19, 2024
1 parent a217e59 commit 3c1ad44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ namespace Digitaljs {

namespace Yosys {

export type BitChar = '0' | '1' | 'x';
export const ConstChars = ["0", "1", "x", "z"] as const;

export type Bit = number | '0' | '1' | 'x';
export type BitChar = (typeof ConstChars)[number];

export type Bit = number | BitChar;

export type BitVector = Bit[];

Expand Down Expand Up @@ -404,7 +406,7 @@ function yosys_to_digitaljs(data: Yosys.Output, portmaps: Portmaps, options: Con

function yosys_to_digitaljs_mod(name: string, mod: Yosys.Module, portmaps: Portmaps, options: ConvertOptions = {}): Digitaljs.Module {
function constbit(bit: Bit) {
return bit == '0' || bit == '1' || bit == 'x';
return (Yosys.ConstChars as readonly string[]).includes(bit.toString());
}
const nets = new HashMap<Net, NetInfo>();
const netnames = new HashMap<Net, string[]>();
Expand Down
7 changes: 7 additions & 0 deletions tests/z.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// high impedance state
module sourceZ(
output out
);
assign out = 1'bZ;

endmodule

0 comments on commit 3c1ad44

Please sign in to comment.