Skip to content

Commit

Permalink
Quaigh works!
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Jul 25, 2024
1 parent 889733d commit 688062a
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 486 deletions.
178 changes: 0 additions & 178 deletions Sources/Fault/BenchCircuit.swift

This file was deleted.

7 changes: 1 addition & 6 deletions Sources/Fault/Entries/asm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ extension Fault {
let goldenOutput = goldenOutput ?? json.replacingExtension(".tv.json", with: ".au.bin")

print("Loading JSON data…")
let start = DispatchTime.now()
guard let data = try? Data(contentsOf: URL(fileURLWithPath: json)) else {
throw ValidationError("Failed to open test vector JSON file.")
}
Expand All @@ -60,10 +59,6 @@ extension Fault {
guard let tvinfo = try? decoder.decode(TVInfo.self, from: data) else {
throw ValidationError("Test vector JSON file is invalid.")
}
let end = DispatchTime.now()
let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds
let timeInterval = Double(nanoTime) / 1_000_000_000
print("Loaded JSON data in \(timeInterval)s.")

// Extract chain metadata
let (chain, _, _) = ChainMetadata.extract(file: verilog)
Expand All @@ -80,7 +75,7 @@ extension Fault {
// Check input order
let chainOrder = order.filter { $0.kind != .bypassInput }
guard chainOrder.count == jsInputOrder.count else {
throw ValidationError("Number of inputs in the JSON (\(jsInputOrder.count)) does not match scan-chain registers (\(chainOrder.count)).")
throw ValidationError("Number of inputs in the test-vector JSON file (\(jsInputOrder.count)) does not match scan-chain registers (\(chainOrder.count)): Found \(Set(chainOrder.map { $0.name }).symmetricDifference(jsInputOrder.map { $0.name })).")
}

for (i, input) in jsInputOrder.enumerated() {
Expand Down
26 changes: 17 additions & 9 deletions Sources/Fault/Entries/atpg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,24 @@ extension Fault {

var faultPoints: Set<String> = []
var gateCount = 0
var inputsMinusIgnored: [Port] = []
if etvSetVectors.count == 0 {
inputsMinusIgnored = inputs.filter {
!bypass.bypassedInputs.contains($0.name)
}
} else {
etvSetInputs.sort { $0.ordinal < $1.ordinal }
inputsMinusIgnored = etvSetInputs.filter {
!bypass.bypassedInputs.contains($0.name)
var inputsMinusIgnored: [Port] = inputs.filter {
!bypass.bypassedInputs.contains($0.name)
}
if etvSetVectors.count > 0 {
var evtInputsMinusIgnored: [Port] = []
var offset = 0
for (i, input) in etvSetInputs.enumerated() {
if bypass.bypassedInputs.contains(input.name) {
for (j, _) in etvSetVectors.enumerated() {
etvSetVectors[j].remove(at: i - offset)
}
offset += 1
} else {
evtInputsMinusIgnored.append(input)
}
}
assert(inputsMinusIgnored.count == evtInputsMinusIgnored.count);
inputsMinusIgnored = evtInputsMinusIgnored
}

for (_, port) in ports {
Expand Down
Loading

0 comments on commit 688062a

Please sign in to comment.