Skip to content

Commit

Permalink
automatic bench conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Nov 2, 2024
1 parent 2fda9ad commit a9f2111
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
33 changes: 31 additions & 2 deletions Sources/Fault/Entries/atpg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Fault/Entries/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9f2111

Please sign in to comment.