From de4a0c2ef0da8686a0c4a6f522abf7f91542b8b4 Mon Sep 17 00:00:00 2001 From: Youssef Kandil Date: Sun, 29 Sep 2024 13:18:03 +0200 Subject: [PATCH] Co-authored-by: Mohamed Gaber --- .gitignore | 1 + Benchmarks/Benchmarks/aes128.v | 3 ++- Benchmarks/test.sh | 4 ++-- Sources/Fault/Entries/atpg.swift | 2 ++ Sources/Fault/Entries/main.swift | 1 + Sources/Fault/Synthesis.swift | 2 ++ Sources/Fault/TVGenerator.swift | 25 +++++++++++++++++++++++++ docs/Source/installation.md | 1 + flake.lock | 7 ++++--- flake.nix | 5 ++--- 10 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 37d40d7..8758252 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ parsetab.py .swiftpm/ abc.history +temp.txt diff --git a/Benchmarks/Benchmarks/aes128.v b/Benchmarks/Benchmarks/aes128.v index 3516dc4..8b0c54c 100644 --- a/Benchmarks/Benchmarks/aes128.v +++ b/Benchmarks/Benchmarks/aes128.v @@ -14,8 +14,9 @@ * limitations under the License. */ -module aes128(clk, state, key, out); +module aes128(clk, state, key, out, reset); input clk; + input reset; input [127:0] state, key; output [127:0] out; reg [127:0] s0, k0; diff --git a/Benchmarks/test.sh b/Benchmarks/test.sh index d405ea0..ad27416 100755 --- a/Benchmarks/test.sh +++ b/Benchmarks/test.sh @@ -10,7 +10,7 @@ function usage() { echo " --all Runs Fault's complete flow" echo " --synth Runs synthesis script" echo " --cut Runs cut option on the synthesized netlist" - echo " -g, --tvgen Runs fault simulation using the specified TV generator (swift, atalanta, LFSR, PODEM)" + echo " -g, --tvgen Runs fault simulation using the specified TV generator (swift, atalanta, LFSR, PODEM, PodemQuest)" echo " --delay Runs the transition fault simulator" echo " --chain Runs chain option on the synthesized netlist" echo " --tap Runs tap option on the chained netlist" @@ -194,7 +194,7 @@ do ignoring="-i $ignored_input,$clock_signal,$reset_signal" fi # Check tvgen type - if [ $tvgen = "atalanta" ] || [ $tvgen = "podem" ]; + if [ $tvgen = "atalanta" ] || [ $tvgen = "podem" ] || [ $tvgen = "PodemQuest" ]; then bench=$cut_netlist.bench echo "Generating bench circuit for $cut_netlist" diff --git a/Sources/Fault/Entries/atpg.swift b/Sources/Fault/Entries/atpg.swift index 31f7782..1a8f244 100644 --- a/Sources/Fault/Entries/atpg.swift +++ b/Sources/Fault/Entries/atpg.swift @@ -217,6 +217,8 @@ extension Fault { evtInputsMinusIgnored.append(input) } } + print(inputsMinusIgnored); + print(evtInputsMinusIgnored); assert(inputsMinusIgnored.count == evtInputsMinusIgnored.count); inputsMinusIgnored = evtInputsMinusIgnored } diff --git a/Sources/Fault/Entries/main.swift b/Sources/Fault/Entries/main.swift index bd6f6e7..5aaf948 100644 --- a/Sources/Fault/Entries/main.swift +++ b/Sources/Fault/Entries/main.swift @@ -38,6 +38,7 @@ _ = [ // Register all TVGens Atalanta.registered, Quaigh.registered, PODEM.registered, + PodemQuest.registered, ] let yosysTest = "'\(yosysExecutable)' -V".sh(silent: true) diff --git a/Sources/Fault/Synthesis.swift b/Sources/Fault/Synthesis.swift index 01d47b2..96d2957 100644 --- a/Sources/Fault/Synthesis.swift +++ b/Sources/Fault/Synthesis.swift @@ -36,6 +36,7 @@ enum Synthesis { # check design hierarchy hierarchy \(checkHierarchy ? "-check" : "") -top \(module) + flatten; # translate processes (always blocks) proc; \(opt) @@ -60,6 +61,7 @@ enum Synthesis { # mapping logic to mycells.lib abc -liberty \(libertyFile) + splitnets -ports # print gate count stat diff --git a/Sources/Fault/TVGenerator.swift b/Sources/Fault/TVGenerator.swift index b3def59..17e7432 100644 --- a/Sources/Fault/TVGenerator.swift +++ b/Sources/Fault/TVGenerator.swift @@ -316,3 +316,28 @@ class PODEM: ExternalTestVectorGenerator { static let registered = ETVGFactory.register(name: "PODEM", type: PODEM.self) } + + +class PodemQuest: ExternalTestVectorGenerator { + + required init() {} + + func generate(file: String, module: String) -> ([TestVector], [Port]) { + let output = file.replacingExtension(".bench", with: ".test") + let podemQuest = "podemquest -i\(file) -o \(output)".sh() + + if podemQuest != EX_OK { + exit(podemQuest) + } + + do { + let (testvectors, inputs) = try TVSet.readFromTest(output, withInputsFrom: file) + return (vectors: testvectors, inputs: inputs) + } catch { + Stderr.print("Internal software error: \(error)") + exit(EX_SOFTWARE) + } + } + + static let registered = ETVGFactory.register(name: "PodemQuest", type: PodemQuest.self) +} diff --git a/docs/Source/installation.md b/docs/Source/installation.md index 1c3fba1..492fe28 100644 --- a/docs/Source/installation.md +++ b/docs/Source/installation.md @@ -56,3 +56,4 @@ are some pointers nevertheless. - [Quaigh](https://github.com/coloquinte/quaigh) (Optional but really recommended) - [Atalanta](https://github.com/hsluoyz/atalanta) (Optional) - [NTU EE PODEM](https://github.com/donn/VLSI-Testing) (Optional) +//todo: add PodemQuest diff --git a/flake.lock b/flake.lock index e44be17..2217483 100644 --- a/flake.lock +++ b/flake.lock @@ -123,15 +123,16 @@ ] }, "locked": { - "lastModified": 1721923472, - "narHash": "sha256-Rvjd/0WYNTVg1hF1ODK7KagXrs4eLP/mTZROA+psWag=", + "lastModified": 1727023453, + "narHash": "sha256-dh7gV/vRmTFrG1sbVLewq3tieSonn8uHMgFHdasep+g=", "owner": "donn", "repo": "nl2bench", - "rev": "4fc66fb534bff125d437f7807d1dd660a08ed03c", + "rev": "42f08f65b35c286af42478b5ce3efd68e559b60e", "type": "github" }, "original": { "owner": "donn", + "ref": "dirtiest_workaround_imaginable", "repo": "nl2bench", "type": "github" } diff --git a/flake.nix b/flake.nix index 099b2a6..cf2d974 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ inputs = { nix-eda.url = github:efabless/nix-eda; nl2bench = { - url = github:donn/nl2bench; + url = github:donn/nl2bench/dirtiest_workaround_imaginable; inputs.nix-eda.follows = "nix-eda"; }; quaigh = { @@ -21,7 +21,7 @@ devShells = nix-eda.forAllSystems { withInputs = [nix-eda quaigh nl2bench self]; } (util: with util; rec { mac-testing = pkgs.stdenvNoCC.mkDerivation (with pkgs; let - pyenv = (python3.withPackages(ps: with ps; [pyverilog pyyaml pytest])); + pyenv = (python3.withPackages(ps: with ps; [pyverilog pyyaml pytest pkgs.nl2bench])); in { # Use the host's Clang and Swift name = "shell"; @@ -29,7 +29,6 @@ yosys verilog pkgs.quaigh - pkgs.nl2bench pyenv gtkwave ];