diff --git a/Sources/Fault/Entries/atpg.swift b/Sources/Fault/Entries/atpg.swift index 39d83da..4553c2e 100644 --- a/Sources/Fault/Entries/atpg.swift +++ b/Sources/Fault/Entries/atpg.swift @@ -94,9 +94,18 @@ extension Fault { @Option( name: [.short, .long], - help: "Netlist in bench format. (Required iff generator is set to Atalanta or PODEM.)") + help: + "Netlist in bench format. (Required if generator is set to Atalanta or PODEM and a liberty file is not passed.)" + ) var bench: String? + @Option( + name: [.customShort("l"), .long], + help: + "Liberty file. (Required if generator is set to Atalanta or PODEM and a bench file is not passed.)" + ) + var liberty: String? + @Flag(help: "Generate only one testbench for inspection, and do not delete it.") var sampleRun: Bool = false @@ -182,8 +191,28 @@ extension Fault { Stderr.print("Unknown external test vector generator '\(tvGenerator)'.") Foundation.exit(EX_USAGE) } + if bench == nil && liberty == nil { + Stderr.print( + "Either --bench or --liberty must be passed when using an external test vector generator." + ) + Foundation.exit(EX_USAGE) + } - let benchUnwrapped = bench! // Program exits if etvGen.value isn't nil and bench.value is or vice versa + let benchUnwrapped = + bench + ?? ({ + let nl2bench = Python.import("nl2bench") + let pyPath = Python.import("pathlib").Path + let benchPath = file.replacingExtension(".v", with: ".bench") + let benchPathF = Python.open(benchPath, "w", encoding: "utf8") + nl2bench.nl2bench.verilog_netlist_to_bench( + pyPath(file), + [ + liberty! + ], + benchPathF, Array(bypass.bypassedIOs)) + return benchPath + })() if !fileManager.fileExists(atPath: benchUnwrapped) { throw ValidationError("Bench file '\(benchUnwrapped)' not found.") diff --git a/Sources/Fault/Entries/main.swift b/Sources/Fault/Entries/main.swift index 435d81d..eba2b5c 100644 --- a/Sources/Fault/Entries/main.swift +++ b/Sources/Fault/Entries/main.swift @@ -21,7 +21,7 @@ import Foundation import PythonKit import Yams -let VERSION = "0.9.0" +let VERSION = "0.10.0" var env = ProcessInfo.processInfo.environment let iverilogBase = env["FAULT_IVL_BASE"] ?? "/usr/local/lib/ivl" diff --git a/flake.lock b/flake.lock index 9d57cda..e65215a 100644 --- a/flake.lock +++ b/flake.lock @@ -86,11 +86,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1728905391, - "narHash": "sha256-iox9yGNG4MwSKhQuwegLcDW6wVGzfdBPrh8SrhSLA8c=", + "lastModified": 1729690989, + "narHash": "sha256-vH6nNmYWX5IV8+C1eorCjA/8YyYhNlKnPCruaiTlW6U=", "owner": "efabless", "repo": "nix-eda", - "rev": "0814aa6c1c7d556aa08212cc875063cff62cb9b0", + "rev": "c54cac502fc8e828244063a0e0fd1dfbf706cb00", "type": "github" }, "original": { @@ -126,11 +126,11 @@ ] }, "locked": { - "lastModified": 1729429745, - "narHash": "sha256-dQgCxAcoEv1NTqSRpNGEE4NhNufc76Cyc3HDInqL2+0=", + "lastModified": 1730551568, + "narHash": "sha256-OjlXcUPxtBxVjfJ6geZk0mRM34ZyAwvSyV+VaJ2J4Ic=", "owner": "donn", "repo": "nl2bench", - "rev": "23d4e0954d56ec15a12bb27064501e93566ee8e7", + "rev": "1654bab0c720a84eab7e662fcee494f502c30bc3", "type": "github" }, "original": { @@ -148,11 +148,11 @@ ] }, "locked": { - "lastModified": 1722162293, - "narHash": "sha256-WILtL6WKXs5pB5Jujx9HIT2w1jiVTZymXC7DTuqLPEM=", + "lastModified": 1729433159, + "narHash": "sha256-/zUDNezyZaV7tGIXK9LcdWH5xGHI5CRKALh0vNDf6HE=", "owner": "coloquinte", "repo": "quaigh", - "rev": "2fec998178d4e48c5379dd0a2025f8688797f99a", + "rev": "c9a17d28bfb3ff73315262d4f2b345e8877b395a", "type": "github" }, "original": {