From ae07298a6b26315793167d9fe0e47d33412fc033 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Sun, 21 Feb 2021 09:14:37 -0500 Subject: [PATCH] machxo2: Switch to LUT4 sim model which propagates less undefined/don't care values. --- techlibs/machxo2/cells_sim.v | 16 +++++----------- tests/arch/machxo2/mux.ys | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/techlibs/machxo2/cells_sim.v b/techlibs/machxo2/cells_sim.v index c6d70a055..161ddfe2e 100644 --- a/techlibs/machxo2/cells_sim.v +++ b/techlibs/machxo2/cells_sim.v @@ -4,17 +4,11 @@ module LUT4 #( input A, B, C, D, output Z ); - wire [3:0] I; - wire [3:0] I_pd; - - genvar ii; - generate - for (ii = 0; ii < 4; ii = ii + 1'b1) - assign I_pd[ii] = (I[ii] === 1'bz) ? 1'b0 : I[ii]; - endgenerate - - assign I = {D, C, B, A}; - assign Z = INIT[I_pd]; + // This form of LUT propagates as few x's as possible. + wire [7:0] s3 = D ? INIT[15:8] : INIT[7:0]; + wire [3:0] s2 = C ? s3[ 7:4] : s3[3:0]; + wire [1:0] s1 = B ? s2[ 3:2] : s2[1:0]; + assign Z = A ? s1[1] : s1[0]; endmodule module FACADE_FF #( diff --git a/tests/arch/machxo2/mux.ys b/tests/arch/machxo2/mux.ys index 0cfc365bd..6c8aa857c 100644 --- a/tests/arch/machxo2/mux.ys +++ b/tests/arch/machxo2/mux.ys @@ -35,6 +35,6 @@ proc equiv_opt -assert -map +/machxo2/cells_sim.v synth_machxo2 # equivalency check design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) cd mux16 # Constrain all select calls below inside the top module -select -assert-count 12 t:LUT4 +select -assert-count 11 t:LUT4 select -assert-none t:LUT4 t:FACADE_IO %% t:* %D -- 2.30.2