From 1a562f9605aa689f634e3c8c5ed0b7ec2d82352c Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Thu, 28 Nov 2024 15:16:48 +0100 Subject: [PATCH] techmap: add TCL test for Han-Carlson adder --- tests/techmap/han-carlson.nomatch | 2 ++ tests/techmap/han-carlson.tcl | 14 ++++++++++++++ tests/techmap/lcu_refined.v | 20 ++++++++++++++++++++ tests/techmap/run-test.sh | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/techmap/han-carlson.nomatch create mode 100644 tests/techmap/han-carlson.tcl create mode 100644 tests/techmap/lcu_refined.v diff --git a/tests/techmap/han-carlson.nomatch b/tests/techmap/han-carlson.nomatch new file mode 100644 index 000000000..142d509b3 --- /dev/null +++ b/tests/techmap/han-carlson.nomatch @@ -0,0 +1,2 @@ +i +j \ No newline at end of file diff --git a/tests/techmap/han-carlson.tcl b/tests/techmap/han-carlson.tcl new file mode 100644 index 000000000..114ebe4dc --- /dev/null +++ b/tests/techmap/han-carlson.tcl @@ -0,0 +1,14 @@ +yosys -import + +read_verilog +/choices/han-carlson.v +read_verilog lcu_refined.v +design -save init + +for {set i 1} {$i <= 16} {incr i} { + design -load init + chparam -set WIDTH $i + yosys proc + equiv_make -blacklist han-carlson.nomatch lcu _85_lcu_han_carlson equiv + equiv_simple equiv + equiv_status -assert equiv +} diff --git a/tests/techmap/lcu_refined.v b/tests/techmap/lcu_refined.v new file mode 100644 index 000000000..9187f68fe --- /dev/null +++ b/tests/techmap/lcu_refined.v @@ -0,0 +1,20 @@ +// Copied from techlibs/common/simlib.v +// with this condition removed: (^{P, G, CI} !== 1'bx) +module lcu (P, G, CI, CO); + +parameter WIDTH = 2; + +input [WIDTH-1:0] P; // Propagate +input [WIDTH-1:0] G; // Generate +input CI; // Carry-in + +output reg [WIDTH-1:0] CO; // Carry-out + +integer i; +always @* begin + CO[0] = G[0] || (P[0] && CI); + for (i = 1; i < WIDTH; i = i+1) + CO[i] = G[i] || (P[i] && CO[i-1]); +end + +endmodule diff --git a/tests/techmap/run-test.sh b/tests/techmap/run-test.sh index 581847ab0..16741cace 100755 --- a/tests/techmap/run-test.sh +++ b/tests/techmap/run-test.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -eu source ../gen-tests-makefile.sh -run_tests --yosys-scripts --bash --yosys-args "-e 'select out of bounds'" +run_tests --yosys-scripts --tcl-scripts --bash --yosys-args "-e 'select out of bounds'"