diff --git a/chips/yosys/tests/arch/analogdevices/dsp_abc9.ys b/chips/yosys/tests/arch/analogdevices/dsp_abc9.ys new file mode 100644 index 0000000000000000000000000000000000000000..99a057fe4d821c7cc01a51b787cab52d1350e665 --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/dsp_abc9.ys @@ -0,0 +1,41 @@ +logger -nowarn "Yosys has only limited support for tri-state logic at the moment\. .*" +logger -nowarn "Ignoring boxed module .*\." + +read_verilog < 1: + top_list.pop(0) + + # iterate over string substitutions + for top in top_list: + # limit number of tests per file to allow parallel make + if not f: + fn = f"t_mem{i}.ys" + f = open(fn, mode="w") + j = 0 + + # output yosys script test file + print( + blockram_template.format(param_str=param_str, top=top, tech=sim_test.tech, opts=" ".join(sim_test.opts)), + file=f + ) + for assertion in sim_test.assertions: + print(f"log ** CHECKING CELL COUNTS FOR TEST {top} WITH PARAMS{param_str} ON TECH {sim_test.tech}", file=f) + print(f"select {assertion}", file=f) + print("", file=f) + + # increment test counter + j += 1 + if j >= max_j: + f = f.close() + i += 1 + +if f: + f.close() diff --git a/chips/yosys/tests/arch/analogdevices/mul.ys b/chips/yosys/tests/arch/analogdevices/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..460bfeb68f389ff39fb2e9a7f063f31c616c9bf0 --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/mul.ys @@ -0,0 +1,9 @@ +read_verilog ../common/mul.v +hierarchy -top top +proc +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:RBBDSP +select -assert-none t:RBBDSP %% t:* %D diff --git a/chips/yosys/tests/arch/analogdevices/mul_unsigned.v b/chips/yosys/tests/arch/analogdevices/mul_unsigned.v new file mode 100644 index 0000000000000000000000000000000000000000..e3713a6428174ddfb3c64db9bc8c4267e9c0e7b7 --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/mul_unsigned.v @@ -0,0 +1,30 @@ +/* +Example from: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_1/ug901-vivado-synthesis.pdf [p. 89]. +*/ + +// Unsigned 16x24-bit Multiplier +// 1 latency stage on operands +// 3 latency stage after the multiplication +// File: multipliers2.v +// +module mul_unsigned (clk, A, B, RES); +parameter WIDTHA = /*16*/ 6; +parameter WIDTHB = /*24*/ 9; +input clk; +input [WIDTHA-1:0] A; +input [WIDTHB-1:0] B; +output [WIDTHA+WIDTHB-1:0] RES; +reg [WIDTHA-1:0] rA; +reg [WIDTHB-1:0] rB; +reg [WIDTHA+WIDTHB-1:0] M [3:0]; +integer i; +always @(posedge clk) + begin + rA <= A; + rB <= B; + M[0] <= rA * rB; + for (i = 0; i < 3; i = i+1) + M[i+1] <= M[i]; + end +assign RES = M[3]; +endmodule diff --git a/chips/yosys/tests/arch/analogdevices/mul_unsigned.ys b/chips/yosys/tests/arch/analogdevices/mul_unsigned.ys new file mode 100644 index 0000000000000000000000000000000000000000..5bdbdaac4c2fcdfe06d4df9c1f3a0fe4d51de61b --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/mul_unsigned.ys @@ -0,0 +1,10 @@ +read_verilog mul_unsigned.v +hierarchy -top mul_unsigned +proc + +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned # Constrain all select calls below inside the top module +select -assert-count 1 t:RBBDSP +select -assert-count 75 t:FFRE +select -assert-none t:RBBDSP t:FFRE %% t:* %D diff --git a/chips/yosys/tests/arch/analogdevices/mux.ys b/chips/yosys/tests/arch/analogdevices/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..375ce90f2b90a8219dcbfbd5e1cd5995d4fda730 --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/mux.ys @@ -0,0 +1,50 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 + +select -assert-none t:LUT3 %% t:* %D + + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT6 + +select -assert-none t:LUT6 %% t:* %D + + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 2 t:LUT6 + +select -assert-none t:LUT3 t:LUT6 %% t:* %D + + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # 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-max 2 t:LUT3 +select -assert-max 2 t:LUT4 +select -assert-min 4 t:LUT6 +select -assert-max 7 t:LUT6 +select -assert-max 2 t:LUTMUX7 +dump + +select -assert-none t:LUT6 t:LUT4 t:LUT3 t:LUTMUX7 %% t:* %D diff --git a/chips/yosys/tests/arch/analogdevices/opt_lut_ins.ys b/chips/yosys/tests/arch/analogdevices/opt_lut_ins.ys new file mode 100644 index 0000000000000000000000000000000000000000..9723ee651ff27a7f78eb69e1b5ebe53ab6b813d0 --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/opt_lut_ins.ys @@ -0,0 +1,26 @@ +read_rtlil << EOF + +module \top + + wire width 4 input 1 \A + + wire output 2 \O + + cell \LUT4 $0 + parameter \INIT 16'1111110011000000 + connect \I0 \A [0] + connect \I1 \A [1] + connect \I2 \A [2] + connect \I3 \A [3] + connect \O \O + end +end + +EOF + +read_verilog -lib +/analogdevices/cells_sim.v +equiv_opt -assert -map +/analogdevices/cells_sim.v opt_lut_ins -tech analogdevices + +design -load postopt + +select -assert-count 1 t:LUT3 diff --git a/chips/yosys/tests/arch/analogdevices/shifter.ys b/chips/yosys/tests/arch/analogdevices/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..3cd67cb9340a68a9c08946dcb089e331cc4cc5fb --- /dev/null +++ b/chips/yosys/tests/arch/analogdevices/shifter.ys @@ -0,0 +1,10 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/analogdevices/cells_sim.v synth_analogdevices -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 8 t:FFRE +select -assert-none t:FFRE %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/.gitignore b/chips/yosys/tests/arch/anlogic/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d9f7e276c696c7b6f40ee2ff3824c86af3e1985f --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/.gitignore @@ -0,0 +1,2 @@ ++*_synth.v ++*_testbench diff --git a/chips/yosys/tests/arch/anlogic/add_sub.ys b/chips/yosys/tests/arch/anlogic/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..5396ce7ec5029cefa21ab56cb41fefa2d215fc06 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/add_sub.ys @@ -0,0 +1,10 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 10 t:AL_MAP_ADDER +select -assert-count 4 t:AL_MAP_LUT1 + +select -assert-none t:AL_MAP_LUT1 t:AL_MAP_ADDER %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/blockram.ys b/chips/yosys/tests/arch/anlogic/blockram.ys new file mode 100644 index 0000000000000000000000000000000000000000..da23409bafb1122013713d135c98d525813388a5 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/blockram.ys @@ -0,0 +1,13 @@ +read_verilog ../common/blockram.v +hierarchy -top sync_ram_sp +proc +memory -nomap +equiv_opt -run :prove -map +/anlogic/cells_sim.v synth_anlogic +memory +opt -full + +design -load postopt +cd sync_ram_sp + +select -assert-count 1 t:EG_PHY_BRAM +select -assert-none t:EG_PHY_BRAM %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/counter.ys b/chips/yosys/tests/arch/anlogic/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..a6eab248cc4af4f9c21c93ee99c62e5b05719948 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/counter.ys @@ -0,0 +1,11 @@ +read_verilog ../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 9 t:AL_MAP_ADDER +select -assert-count 8 t:AL_MAP_SEQ +select -assert-none t:AL_MAP_SEQ t:AL_MAP_ADDER %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/dffs.ys b/chips/yosys/tests/arch/anlogic/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..deb90e05191b49555035850cbc1e77b38a416147 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/dffs.ys @@ -0,0 +1,19 @@ +read_verilog ../common/dffs.v +design -save read + +hierarchy -top dff +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dff # Constrain all select calls below inside the top module +select -assert-count 1 t:AL_MAP_SEQ +select -assert-none t:AL_MAP_SEQ %% t:* %D + +design -load read +hierarchy -top dffe +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:AL_MAP_SEQ +select -assert-none t:AL_MAP_SEQ %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/fsm.ys b/chips/yosys/tests/arch/anlogic/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..eb94177ad2b231b3009b5fbae106c6cd38d5d009 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/fsm.ys @@ -0,0 +1,15 @@ +read_verilog ../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/anlogic/cells_sim.v synth_anlogic +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-count 6 t:AL_MAP_SEQ + +select -assert-none t:AL_MAP_LUT* t:AL_MAP_SEQ %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/generate_mk.py b/chips/yosys/tests/arch/anlogic/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..06a6040ad48bae5c2ce7163455d96b2401a68986 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/anlogic/latches.ys b/chips/yosys/tests/arch/anlogic/latches.ys new file mode 100644 index 0000000000000000000000000000000000000000..34a3b14d069c090bc7039bc6258e7561bb075a86 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/latches.ys @@ -0,0 +1,35 @@ +read_verilog ../common/latches.v +design -save read + +hierarchy -top latchp +proc +equiv_opt -assert -multiclock -map +/anlogic/cells_sim.v synth_anlogic +design -load postopt +cd latchp # Constrain all select calls below inside the top module + +select -assert-count 1 t:AL_MAP_SEQ +select -assert-count 1 t:AL_MAP_LUT1 +select -assert-none t:AL_MAP_SEQ t:AL_MAP_LUT1 %% t:* %D + + +design -load read +hierarchy -top latchn +proc +equiv_opt -assert -multiclock -map +/anlogic/cells_sim.v synth_anlogic +design -load postopt +cd latchn # Constrain all select calls below inside the top module + +select -assert-count 1 t:AL_MAP_SEQ +select -assert-none t:AL_MAP_SEQ %% t:* %D + + +design -load read +hierarchy -top latchsr +proc +equiv_opt -assert -multiclock -map +/anlogic/cells_sim.v synth_anlogic +design -load postopt +cd latchsr # Constrain all select calls below inside the top module + +select -assert-count 1 t:AL_MAP_SEQ +select -assert-count 2 t:AL_MAP_LUT3 +select -assert-none t:AL_MAP_SEQ t:AL_MAP_LUT3 %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/logic.ys b/chips/yosys/tests/arch/anlogic/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..0c570eb1739cadf89e4f2ac1d1d4dd4e6b5e066b --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/logic.ys @@ -0,0 +1,11 @@ +read_verilog ../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 4 t:AL_MAP_LUT1 +select -assert-count 3 t:AL_MAP_LUT2 +select -assert-count 2 t:AL_MAP_LUT4 +select -assert-none t:AL_MAP_LUT1 t:AL_MAP_LUT2 t:AL_MAP_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/lutram.ys b/chips/yosys/tests/arch/anlogic/lutram.ys new file mode 100644 index 0000000000000000000000000000000000000000..fe6135c73ac6052def66aa9cb8493dbaa50222cd --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/lutram.ys @@ -0,0 +1,20 @@ +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +proc +memory -nomap +equiv_opt -run :prove -map +/anlogic/cells_sim.v synth_anlogic -nobram +memory +opt -full + +miter -equiv -flatten -make_assert -make_outputs gold gate miter +#ERROR: Failed to import cell gate.mem.0.0.0 (type EG_LOGIC_DRAM16X4) to SAT database. +#sat -verify -prove-asserts -seq 3 -set-init-zero -show-inputs -show-outputs miter + +design -load postopt +cd lutram_1w1r + +select -assert-count 4 t:AL_MAP_LUT3 +select -assert-count 8 t:AL_MAP_LUT6 +select -assert-count 8 t:AL_MAP_SEQ +select -assert-count 8 t:EG_LOGIC_DRAM16X4 #Why not AL_LOGIC_BRAM? +select -assert-none t:AL_MAP_LUT3 t:AL_MAP_LUT6 t:AL_MAP_SEQ t:EG_LOGIC_DRAM16X4 %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/mux.ys b/chips/yosys/tests/arch/anlogic/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..ce6dd3a524c682c02a42656d48deb676cdea1ed9 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/mux.ys @@ -0,0 +1,50 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:AL_MAP_LUT3 + +select -assert-none t:AL_MAP_LUT3 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:AL_MAP_LUT6 + +select -assert-none t:AL_MAP_LUT6 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-max 4 t:AL_MAP_LUT4 +select -assert-max 1 t:AL_MAP_LUT5 + +select -assert-none t:AL_MAP_LUT4 t:AL_MAP_LUT5 %% t:* %D + +design -load read +hierarchy -top mux16 +proc + +# Flaky test, started failing with statically allocated IdStrings, but works +# for me locally when I scramble the names using: +# +# rename -scramble-name -seed 1 +# + +#equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # 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 +#show +#select -assert-count 5 t:AL_MAP_LUT6 + +#select -assert-none t:AL_MAP_LUT6 %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/shifter.ys b/chips/yosys/tests/arch/anlogic/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..12df44b2a5d7f37e556ae71dc949e5942f4560b0 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/shifter.ys @@ -0,0 +1,10 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/anlogic/cells_sim.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 8 t:AL_MAP_SEQ + +select -assert-none t:AL_MAP_SEQ %% t:* %D diff --git a/chips/yosys/tests/arch/anlogic/tribuf.ys b/chips/yosys/tests/arch/anlogic/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..eaa0737508b2f55d73e1f611f804f495f5beed77 --- /dev/null +++ b/chips/yosys/tests/arch/anlogic/tribuf.ys @@ -0,0 +1,9 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +flatten +equiv_opt -assert -map +/anlogic/cells_sim.v -map +/simcells.v synth_anlogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/common/add_sub.v b/chips/yosys/tests/arch/common/add_sub.v new file mode 100644 index 0000000000000000000000000000000000000000..77e5f57457c5e02d64c32ef9be3638c233f696f3 --- /dev/null +++ b/chips/yosys/tests/arch/common/add_sub.v @@ -0,0 +1,12 @@ +module top +( + input [3:0] x, + input [3:0] y, + + output [3:0] A, + output [3:0] B +); + + assign A = x + y; + assign B = x - y; +endmodule diff --git a/chips/yosys/tests/arch/common/adffs.v b/chips/yosys/tests/arch/common/adffs.v new file mode 100644 index 0000000000000000000000000000000000000000..966e7c2b87fdedbe2773ad5ab90471f07bccf66a --- /dev/null +++ b/chips/yosys/tests/arch/common/adffs.v @@ -0,0 +1,51 @@ +module adff( input d, clk, clr, output reg q ); +`ifndef NO_INIT + initial begin + q = 0; + end +`endif + always @( posedge clk, posedge clr ) + if ( clr ) + q <= 1'b0; + else + q <= d; +endmodule + +module adffn( input d, clk, clr, output reg q ); +`ifndef NO_INIT + initial begin + q = 0; + end +`endif + always @( posedge clk, negedge clr ) + if ( !clr ) + q <= 1'b0; + else + q <= d; +endmodule + +module dffs( input d, clk, pre, clr, output reg q ); +`ifndef NO_INIT + initial begin + q = 0; + end +`endif + always @( posedge clk ) + if ( pre ) + q <= 1'b1; + else + q <= d; +endmodule + +module ndffnr( input d, clk, pre, clr, output reg q ); +`ifndef NO_INIT + initial begin + q = 0; + end +`endif + always @( negedge clk ) + if ( !clr ) + q <= 1'b0; + else + q <= d; +endmodule diff --git a/chips/yosys/tests/arch/common/blockram.v b/chips/yosys/tests/arch/common/blockram.v new file mode 100644 index 0000000000000000000000000000000000000000..c00dc6d96cd654c2ea84f8b4ab40f96f3f45096e --- /dev/null +++ b/chips/yosys/tests/arch/common/blockram.v @@ -0,0 +1,327 @@ +`default_nettype none +module sync_ram_sp #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=10) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; + +endmodule // sync_ram_sp + + +module sync_ram_sp_nochange #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=10) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + else + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; + +endmodule // sync_ram_sp_nochange + + +module sync_ram_sdp #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=10) + (input wire clk, write_enable, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in_r, address_in_w, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in_w] <= data_in; + data_out_r <= memory[address_in_r]; + end + + assign data_out = data_out_r; + +endmodule // sync_ram_sdp + + +module sync_ram_sdp_wwr #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=10, SHIFT_VAL=1) // wd=16, wa=9 +( + input wire clk_w, clk_r, write_enable, + input wire [WORD-1:0] data_in, + input wire [ADDRESS_WIDTH_W-1:0] address_in_w, + input wire [ADDRESS_WIDTH-1:0] address_in_r, + output wire [DATA_WIDTH-1:0] data_out +); + + localparam ADDRESS_WIDTH_W = ADDRESS_WIDTH-SHIFT_VAL; + localparam BYTE = DATA_WIDTH; + localparam WORD = DATA_WIDTH<> 12); + j = j ^ (j << 25); + j = j ^ (j >> 27); + end + end + + always @(posedge clk) begin + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; + +endmodule // sync_rom diff --git a/chips/yosys/tests/arch/common/counter.v b/chips/yosys/tests/arch/common/counter.v new file mode 100644 index 0000000000000000000000000000000000000000..1e0a13dc95ad29979a7f30df9de7e59cc44d1791 --- /dev/null +++ b/chips/yosys/tests/arch/common/counter.v @@ -0,0 +1,11 @@ +module top ( out, clk, reset ); + output [7:0] out; + input clk, reset; + reg [7:0] out; + + always @(posedge clk, posedge reset) + if (reset) + out <= 8'b0; + else + out <= out + 1; +endmodule diff --git a/chips/yosys/tests/arch/common/dffs.v b/chips/yosys/tests/arch/common/dffs.v new file mode 100644 index 0000000000000000000000000000000000000000..0c607af5040b9184b8e3ea4800f76179c011ca98 --- /dev/null +++ b/chips/yosys/tests/arch/common/dffs.v @@ -0,0 +1,15 @@ +module dff ( input d, clk, output reg q ); + always @( posedge clk ) + q <= d; +endmodule + +module dffe( input d, clk, en, output reg q ); +`ifndef NO_INIT + initial begin + q = 0; + end +`endif + always @( posedge clk ) + if ( en ) + q <= d; +endmodule diff --git a/chips/yosys/tests/arch/common/fsm.v b/chips/yosys/tests/arch/common/fsm.v new file mode 100644 index 0000000000000000000000000000000000000000..3d96674c771a2a4cb51d9a3b1c13de89b6df6da9 --- /dev/null +++ b/chips/yosys/tests/arch/common/fsm.v @@ -0,0 +1,51 @@ + module fsm ( clock, reset, req_0, req_1, gnt_0, gnt_1 ); + input clock,reset,req_0,req_1; + output gnt_0,gnt_1; + wire clock,reset,req_0,req_1; + reg gnt_0,gnt_1; + + parameter SIZE = 3; + parameter IDLE = 3'b001; + parameter GNT0 = 3'b010; + parameter GNT1 = 3'b100; + parameter GNT2 = 3'b101; + + reg [SIZE-1:0] state; + reg [SIZE-1:0] next_state; + + always @ (posedge clock) + begin : FSM + if (reset == 1'b1) begin + state <= #1 IDLE; + gnt_0 <= 0; + gnt_1 <= 0; + end + else + case(state) + IDLE : if (req_0 == 1'b1) begin + state <= #1 GNT0; + gnt_0 <= 1; + end else if (req_1 == 1'b1) begin + gnt_1 <= 1; + state <= #1 GNT0; + end else begin + state <= #1 IDLE; + end + GNT0 : if (req_0 == 1'b1) begin + state <= #1 GNT0; + end else begin + gnt_0 <= 0; + state <= #1 IDLE; + end + GNT1 : if (req_1 == 1'b1) begin + state <= #1 GNT2; + gnt_1 <= req_0; + end + GNT2 : if (req_0 == 1'b1) begin + state <= #1 GNT1; + gnt_1 <= req_1; + end + default : state <= #1 IDLE; + endcase + end +endmodule diff --git a/chips/yosys/tests/arch/common/latches.v b/chips/yosys/tests/arch/common/latches.v new file mode 100644 index 0000000000000000000000000000000000000000..60b7571030d91f531f1e9bd892643bdc690581ad --- /dev/null +++ b/chips/yosys/tests/arch/common/latches.v @@ -0,0 +1,21 @@ +module latchp ( input d, clk, en, output reg q ); + always @* + if ( en ) + q <= d; +endmodule + +module latchn ( input d, clk, en, output reg q ); + always @* + if ( !en ) + q <= d; +endmodule + +module latchsr ( input d, clk, en, clr, pre, output reg q ); + always @* + if ( clr ) + q <= 1'b0; + else if ( pre ) + q <= 1'b1; + else if ( en ) + q <= d; +endmodule diff --git a/chips/yosys/tests/arch/common/logic.v b/chips/yosys/tests/arch/common/logic.v new file mode 100644 index 0000000000000000000000000000000000000000..c17899fa0e123395f05a8359bbb4423da17565b5 --- /dev/null +++ b/chips/yosys/tests/arch/common/logic.v @@ -0,0 +1,16 @@ +module top +( + input [0:7] in, + output B1,B2,B3,B4,B5,B6,B7,B8,B9,B10 +); + assign B1 = in[0] & in[1]; + assign B2 = in[0] | in[1]; + assign B3 = in[0] ~& in[1]; + assign B4 = in[0] ~| in[1]; + assign B5 = in[0] ^ in[1]; + assign B6 = in[0] ~^ in[1]; + assign B7 = ~in[0]; + assign B8 = in[0]; + assign B9 = in[0:1] && in [2:3]; + assign B10 = in[0:1] || in [2:3]; +endmodule diff --git a/chips/yosys/tests/arch/common/lutram.v b/chips/yosys/tests/arch/common/lutram.v new file mode 100644 index 0000000000000000000000000000000000000000..9534b76198a5b505e7c9ba489fd44d2cf211bb73 --- /dev/null +++ b/chips/yosys/tests/arch/common/lutram.v @@ -0,0 +1,42 @@ +module lutram_1w1r +#(parameter D_WIDTH=8, A_WIDTH=6) +( + input [D_WIDTH-1:0] data_a, + input [A_WIDTH:1] addr_a, + input we_a, clk, + output reg [D_WIDTH-1:0] q_a +); + // Declare the RAM variable + reg [D_WIDTH-1:0] ram[(2**A_WIDTH)-1:0]; + + // Port A + always @ (posedge clk) + begin + if (we_a) + ram[addr_a] <= data_a; + q_a <= ram[addr_a]; + end +endmodule + + +module lutram_1w3r +#(parameter D_WIDTH=8, A_WIDTH=5) +( + input [D_WIDTH-1:0] data_a, data_b, data_c, + input [A_WIDTH:1] addr_a, addr_b, addr_c, + input we_a, clk, + output reg [D_WIDTH-1:0] q_a, q_b, q_c +); + // Declare the RAM variable + reg [D_WIDTH-1:0] ram[(2**A_WIDTH)-1:0]; + + // Port A + always @ (posedge clk) + begin + if (we_a) + ram[addr_a] <= data_a; + q_a <= ram[addr_a]; + q_b <= ram[addr_b]; + q_c <= ram[addr_c]; + end +endmodule diff --git a/chips/yosys/tests/arch/common/memory_attributes/attributes_test.v b/chips/yosys/tests/arch/common/memory_attributes/attributes_test.v new file mode 100644 index 0000000000000000000000000000000000000000..5fa0f940623f5d9c63fec5aff6cf72ddead9e779 --- /dev/null +++ b/chips/yosys/tests/arch/common/memory_attributes/attributes_test.v @@ -0,0 +1,87 @@ +`default_nettype none +module block_ram #(parameter DATA_WIDTH=4, ADDRESS_WIDTH=10) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; +endmodule // block_ram + +`default_nettype none +module distributed_ram #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; +endmodule // distributed_ram + +`default_nettype none +module distributed_ram_manual #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + (* ram_style = "block" *) reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; +endmodule // distributed_ram + +`default_nettype none +module distributed_ram_manual_syn #(parameter DATA_WIDTH=8, ADDRESS_WIDTH=4) + (input wire write_enable, clk, + input wire [DATA_WIDTH-1:0] data_in, + input wire [ADDRESS_WIDTH-1:0] address_in, + output wire [DATA_WIDTH-1:0] data_out); + + localparam WORD = (DATA_WIDTH-1); + localparam DEPTH = (2**ADDRESS_WIDTH-1); + + reg [WORD:0] data_out_r; + (* synthesis, ram_block *) reg [WORD:0] memory [0:DEPTH]; + + always @(posedge clk) begin + if (write_enable) + memory[address_in] <= data_in; + data_out_r <= memory[address_in]; + end + + assign data_out = data_out_r; +endmodule // distributed_ram diff --git a/chips/yosys/tests/arch/common/mul.v b/chips/yosys/tests/arch/common/mul.v new file mode 100644 index 0000000000000000000000000000000000000000..baed64fcdb01c2be30342d38538739ab9961f5a3 --- /dev/null +++ b/chips/yosys/tests/arch/common/mul.v @@ -0,0 +1,10 @@ +module top +#(parameter X_WIDTH=6, Y_WIDTH=6, A_WIDTH=12) +( + input [X_WIDTH-1:0] x, + input [Y_WIDTH-1:0] y, + + output [A_WIDTH-1:0] A, +); + assign A = x * y; +endmodule diff --git a/chips/yosys/tests/arch/common/mux.v b/chips/yosys/tests/arch/common/mux.v new file mode 100644 index 0000000000000000000000000000000000000000..71c1ac7f2e21a140a792e96733137ef641b3feba --- /dev/null +++ b/chips/yosys/tests/arch/common/mux.v @@ -0,0 +1,60 @@ +module mux2 (S,A,B,Y); + input S; + input A,B; + output reg Y; + + always @(*) + Y = (S)? B : A; +endmodule + +module mux4 ( S, D, Y ); + input[1:0] S; + input[3:0] D; + output Y; + + reg Y; + wire[1:0] S; + wire[3:0] D; + + always @* + begin + case( S ) + 0 : Y = D[0]; + 1 : Y = D[1]; + 2 : Y = D[2]; + 3 : Y = D[3]; + endcase + end +endmodule + +module mux8 ( S, D, Y ); + input[2:0] S; + input[7:0] D; + output Y; + + reg Y; + wire[2:0] S; + wire[7:0] D; + + always @* + begin + case( S ) + 0 : Y = D[0]; + 1 : Y = D[1]; + 2 : Y = D[2]; + 3 : Y = D[3]; + 4 : Y = D[4]; + 5 : Y = D[5]; + 6 : Y = D[6]; + 7 : Y = D[7]; + endcase + end +endmodule + +module mux16 (D, S, Y); + input [15:0] D; + input [3:0] S; + output Y; + + assign Y = D[S]; +endmodule diff --git a/chips/yosys/tests/arch/common/shifter.v b/chips/yosys/tests/arch/common/shifter.v new file mode 100644 index 0000000000000000000000000000000000000000..589e2d29f1f11e40c6560b25243b8dbf7eaf732c --- /dev/null +++ b/chips/yosys/tests/arch/common/shifter.v @@ -0,0 +1,17 @@ +module top(out, clk, in); + output [7:0] out; + input signed clk, in; + reg signed [7:0] out; + +`ifndef NO_INIT + initial begin + out = 0; + end +`endif + + always @(posedge clk) + begin + out <= out >> 1; + out[7] <= in; + end +endmodule diff --git a/chips/yosys/tests/arch/common/tribuf.v b/chips/yosys/tests/arch/common/tribuf.v new file mode 100644 index 0000000000000000000000000000000000000000..e1d701611eb579a17e04f12e1aea970e3cb47fa6 --- /dev/null +++ b/chips/yosys/tests/arch/common/tribuf.v @@ -0,0 +1,8 @@ +module tristate(en, i, o); + input en; + input i; + output reg o; + + always @(en or i) + o <= (en)? i : 1'bZ; +endmodule diff --git a/chips/yosys/tests/arch/ecp5/abc9_inout_pad_input.ys b/chips/yosys/tests/arch/ecp5/abc9_inout_pad_input.ys new file mode 100644 index 0000000000000000000000000000000000000000..04fc54d14406632f3a0460b0590f53c2c30c028c --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/abc9_inout_pad_input.ys @@ -0,0 +1,21 @@ +read_verilog < DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +## With parameters + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # too inefficient +select -assert-count 9 t:TRELLIS_DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "block_ram" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "Block_RAM" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD # any case works + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set ram_block 1 m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD +select -assert-count 9 t:TRELLIS_DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "registers" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # requested FFRAM explicitly +select -assert-count 180 t:TRELLIS_FF + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set logic_block 1 m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # requested FFRAM explicitly +select -assert-count 180 t:TRELLIS_FF + +# RAM bits <= 18K; Data width <= 18; Address width <= 10: -> DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 11 -set DATA_WIDTH 9 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 12 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 13 -set DATA_WIDTH 2 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 14 -set DATA_WIDTH 1 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +## With parameters + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # too inefficient +select -assert-count 5 t:TRELLIS_DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "block_ram" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "Block_RAM" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:DP16KD # any case works + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set ram_block 1 m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # too inefficient +select -assert-count 5 t:TRELLIS_DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "registers" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # requested FFRAM explicitly +select -assert-count 90 t:TRELLIS_FF + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set logic_block 1 m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:DP16KD # requested FFRAM explicitly +select -assert-count 90 t:TRELLIS_FF + +# RAM bits <= 64; Data width <= 4; Address width <= 4: -> DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 4 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:TRELLIS_DPR16X4 + +## With parameters + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 4 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "distributed" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:TRELLIS_DPR16X4 + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 4 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "registers" m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:TRELLIS_DPR16X4 # requested FFRAM explicitly +select -assert-count 68 t:TRELLIS_FF + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 4 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set logic_block 1 m:memory +synth_ecp5 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:TRELLIS_DPR16X4 # requested FFRAM explicitly +select -assert-count 68 t:TRELLIS_FF + +# ================================ ROM ================================ +# ROM bits <= 18K; Data width <= 36; Address width <= 9: -> DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +## With parameters + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # too inefficient +select -assert-min 18 t:LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "ebr" m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +setattr -set rom_block 1 m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "logic" m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # requested LUTROM explicitly +select -assert-min 18 t:LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 36 sync_rom +hierarchy -top sync_rom +setattr -set logic_block 1 m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # requested LUTROM explicitly +select -assert-min 18 t:LUT4 + +# ROM bits <= 18K; Data width <= 18; Address width <= 10: -> DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +## With parameters + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # too inefficient +select -assert-min 9 t:LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "ebr" m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +setattr -set rom_block 1 m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 1 t:DP16KD + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "logic" m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # requested LUTROM explicitly +select -assert-min 9 t:LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 3 -set DATA_WIDTH 18 sync_rom +hierarchy -top sync_rom +setattr -set logic_block 1 m:memory +synth_ecp5 -top sync_rom; cd sync_rom +select -assert-count 0 t:DP16KD # requested LUTROM explicitly +select -assert-min 9 t:LUT4 + +# ============================== TDP RAM ============================== +# RAM bits <= 18K; Data width <= 18x2; Address width <= 9: -> DP16KD + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 18 sync_ram_tdp +hierarchy -top sync_ram_tdp +synth_ecp5 -top sync_ram_tdp; cd sync_ram_tdp +select -assert-count 1 t:DP16KD +select -assert-none t:LUT4 diff --git a/chips/yosys/tests/arch/ecp5/mul.ys b/chips/yosys/tests/arch/ecp5/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..f887e9585896d6eec5969ff5cef14b34367bf78b --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/mul.ys @@ -0,0 +1,11 @@ +read_verilog ../common/mul.v +hierarchy -top top +proc +# Blocked by issue #1358 (Missing ECP5 simulation models) +#equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +synth_ecp5 + +#design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT18X18D +select -assert-none t:MULT18X18D %% t:* %D diff --git a/chips/yosys/tests/arch/ecp5/mux.ys b/chips/yosys/tests/arch/ecp5/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..daa9e86f269f61995612342c31154844d23629da --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/mux.ys @@ -0,0 +1,46 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT4 +select -assert-none t:LUT4 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-max 1 t:L6MUX21 +select -assert-max 4 t:LUT4 +select -assert-max 2 t:PFUMX + +select -assert-none t:LUT4 t:L6MUX21 t:PFUMX %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-max 1 t:L6MUX21 +select -assert-max 8 t:LUT4 +select -assert-max 3 t:PFUMX + +select -assert-none t:LUT4 t:L6MUX21 t:PFUMX %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # 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-max 12 t:L6MUX21 +select -assert-max 34 t:LUT4 +select -assert-max 17 t:PFUMX + +select -assert-none t:LUT4 t:L6MUX21 t:PFUMX %% t:* %D diff --git a/chips/yosys/tests/arch/ecp5/opt_lut_ins.ys b/chips/yosys/tests/arch/ecp5/opt_lut_ins.ys new file mode 100644 index 0000000000000000000000000000000000000000..7f9970c691473cbf87a4377452ddb310b940ef45 --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/opt_lut_ins.ys @@ -0,0 +1,32 @@ +read_rtlil << EOF + +module \top + + wire input 1 \A + wire input 2 \B + wire input 3 \C + wire input 4 \D + + wire output 5 \Z + + cell \LUT4 $0 + parameter \INIT 16'1111110011000000 + connect \A \A + connect \B \B + connect \C \C + connect \D \D + connect \Z \Z + end +end + +EOF + +read_verilog -lib +/ecp5/cells_sim.v + +equiv_opt -assert -map +/ecp5/cells_sim.v opt_lut_ins -tech lattice + +design -load postopt + +select -assert-count 1 top/t:LUT4 +select -assert-count 0 top/w:A %co top/t:LUT4 %i +select -assert-count 1 top/w:B %co top/t:LUT4 %i diff --git a/chips/yosys/tests/arch/ecp5/rom.v b/chips/yosys/tests/arch/ecp5/rom.v new file mode 100644 index 0000000000000000000000000000000000000000..0a0f41f3754f832f8c35226428d410c01f2e5813 --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/rom.v @@ -0,0 +1,18 @@ +/* +Example from: https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/EI/iCEcube201701UserGuide.ashx?document_id=52071 [p. 74]. +*/ +module top(data, addr); +output [3:0] data; +input [4:0] addr; +always @(addr) begin +case (addr) +0 : data = 'h4; +1 : data = 'h9; +2 : data = 'h1; +15 : data = 'h8; +16 : data = 'h1; +17 : data = 'h0; +default : data = 'h0; +endcase +end +endmodule diff --git a/chips/yosys/tests/arch/ecp5/rom.ys b/chips/yosys/tests/arch/ecp5/rom.ys new file mode 100644 index 0000000000000000000000000000000000000000..98645ae4308a36a74fae3b6b96026f8a7e9c8f14 --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/rom.ys @@ -0,0 +1,10 @@ +read_verilog rom.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 6 t:LUT4 +select -assert-count 3 t:PFUMX +select -assert-none t:LUT4 t:PFUMX %% t:* %D diff --git a/chips/yosys/tests/arch/ecp5/shifter.ys b/chips/yosys/tests/arch/ecp5/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..e39a4fcbc9a599ca9da99f63e6a104b18f7d8a40 --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/shifter.ys @@ -0,0 +1,10 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/ecp5/cells_sim.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 8 t:TRELLIS_FF +select -assert-none t:TRELLIS_FF %% t:* %D diff --git a/chips/yosys/tests/arch/ecp5/tribuf.ys b/chips/yosys/tests/arch/ecp5/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..0118705a267c5191e288a78c8a3243d280a90b59 --- /dev/null +++ b/chips/yosys/tests/arch/ecp5/tribuf.ys @@ -0,0 +1,9 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +flatten +equiv_opt -assert -map +/ecp5/cells_sim.v -map +/simcells.v synth_ecp5 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/add_sub.ys b/chips/yosys/tests/arch/efinix/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..81a6a97c71e54c38c5639325f2fa9940cf486ecc --- /dev/null +++ b/chips/yosys/tests/arch/efinix/add_sub.ys @@ -0,0 +1,9 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 10 t:EFX_ADD +select -assert-count 4 t:EFX_LUT4 +select -assert-none t:EFX_ADD t:EFX_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/adffs.ys b/chips/yosys/tests/arch/efinix/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..86d44643908ab7efc0180aedcbd83d7d837df2f4 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/adffs.ys @@ -0,0 +1,48 @@ +read_verilog ../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D + + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D + + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D + + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/counter.ys b/chips/yosys/tests/arch/efinix/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..f8fb29a87b1892333b3fbc14ff1426034bc63400 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/counter.ys @@ -0,0 +1,12 @@ +read_verilog ../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:EFX_GBUFCE +select -assert-count 8 t:EFX_FF +select -assert-count 9 t:EFX_ADD +select -assert-none t:EFX_GBUFCE t:EFX_FF t:EFX_ADD %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/dffs.ys b/chips/yosys/tests/arch/efinix/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..f9111873c07b9db69bcfa7ee1935e671cb4a4b06 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/dffs.ys @@ -0,0 +1,23 @@ +read_verilog ../common/dffs.v +design -save read + +hierarchy -top dff +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dff # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D + +design -load read +hierarchy -top dffe +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_FF +select -assert-count 1 t:EFX_GBUFCE + +select -assert-none t:EFX_FF t:EFX_GBUFCE %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/fsm.ys b/chips/yosys/tests/arch/efinix/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..aef720d4662b10d69b281bb52acbc7e4f3047667 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/fsm.ys @@ -0,0 +1,15 @@ +read_verilog ../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/efinix/cells_sim.v synth_efinix +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-count 1 t:EFX_GBUFCE +select -assert-count 6 t:EFX_FF +select -assert-none t:EFX_GBUFCE t:EFX_FF t:EFX_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/generate_mk.py b/chips/yosys/tests/arch/efinix/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..06a6040ad48bae5c2ce7163455d96b2401a68986 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/efinix/latches.ys b/chips/yosys/tests/arch/efinix/latches.ys new file mode 100644 index 0000000000000000000000000000000000000000..4ac60a8d787a1ca601376d974c3fb83f40f78cad --- /dev/null +++ b/chips/yosys/tests/arch/efinix/latches.ys @@ -0,0 +1,33 @@ +read_verilog ../common/latches.v +design -save read + +hierarchy -top latchp +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_efinix -latches info +cd latchp # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D + + +design -load read +hierarchy -top latchn +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_efinix -latches info +cd latchn # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D + + +design -load read +hierarchy -top latchsr +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_efinix -latches info +cd latchsr # Constrain all select calls below inside the top module +select -assert-count 2 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/logic.ys b/chips/yosys/tests/arch/efinix/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..76e98e079998862c749fd3b65b50506e52fd8829 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/logic.ys @@ -0,0 +1,9 @@ +read_verilog ../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 9 t:EFX_LUT4 +select -assert-none t:EFX_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/lutram.ys b/chips/yosys/tests/arch/efinix/lutram.ys new file mode 100644 index 0000000000000000000000000000000000000000..8412d138958250e749c94a97296600deb60686c7 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/lutram.ys @@ -0,0 +1,7 @@ +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +synth_efinix +cd lutram_1w1r +select -assert-count 1 t:EFX_GBUFCE +select -assert-count 1 t:EFX_RAM_5K +select -assert-none t:EFX_GBUFCE t:EFX_RAM_5K %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/mux.ys b/chips/yosys/tests/arch/efinix/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..4fa67c49b019a7dcff0ef0e6ed1c3ed4c92bfba5 --- /dev/null +++ b/chips/yosys/tests/arch/efinix/mux.ys @@ -0,0 +1,41 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +#select -assert-count 2 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +#select -assert-count 5 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # 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-max 13 t:EFX_LUT4 + +select -assert-none t:EFX_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/shifter.ys b/chips/yosys/tests/arch/efinix/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..54f71167fc259650562bb11ef3bcf4e718e7dedb --- /dev/null +++ b/chips/yosys/tests/arch/efinix/shifter.ys @@ -0,0 +1,11 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/efinix/cells_sim.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:EFX_GBUFCE +select -assert-count 8 t:EFX_FF +select -assert-none t:EFX_GBUFCE t:EFX_FF %% t:* %D diff --git a/chips/yosys/tests/arch/efinix/tribuf.ys b/chips/yosys/tests/arch/efinix/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..47904f2d5f542f275cdd3e0fcc603b962f7c505e --- /dev/null +++ b/chips/yosys/tests/arch/efinix/tribuf.ys @@ -0,0 +1,12 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/efinix/cells_sim.v -map +/simcells.v synth_efinix # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +#Internal cell type used. Need support it. +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/fabulous/.gitignore b/chips/yosys/tests/arch/fabulous/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d9f7e276c696c7b6f40ee2ff3824c86af3e1985f --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/.gitignore @@ -0,0 +1,2 @@ ++*_synth.v ++*_testbench diff --git a/chips/yosys/tests/arch/fabulous/arith_map.v b/chips/yosys/tests/arch/fabulous/arith_map.v new file mode 100644 index 0000000000000000000000000000000000000000..0919beb1116f379e57e7457327f068717f462ea4 --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/arith_map.v @@ -0,0 +1,64 @@ +`default_nettype none + +`ifdef ARITH_ha +(* techmap_celltype = "$alu" *) +module _80_fabulous_ha_alu (A, B, CI, BI, X, Y, CO); + +parameter A_SIGNED = 0; +parameter B_SIGNED = 0; +parameter A_WIDTH = 1; +parameter B_WIDTH = 1; +parameter Y_WIDTH = 1; + +parameter _TECHMAP_CONSTMSK_CI_ = 0; +parameter _TECHMAP_CONSTVAL_CI_ = 0; + +(* force_downto *) +input [A_WIDTH-1:0] A; +(* force_downto *) +input [B_WIDTH-1:0] B; +input CI, BI; +(* force_downto *) +output [Y_WIDTH-1:0] X, Y, CO; + +(* force_downto *) +wire [Y_WIDTH-1:0] A_buf, B_buf; +\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf)); +\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf)); + +(* force_downto *) +wire [Y_WIDTH-1:0] AA = A_buf; +(* force_downto *) +wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf; +wire [Y_WIDTH:0] CARRY; + + +LUT4_HA #( + .INIT(16'b0), + .I0MUX(1'b1) +) carry_start ( + .I0(), .I1(CI), .I2(CI), .I3(), + .Ci(), + .Co(CARRY[0]) +); + +// Carry chain +genvar i; +generate for (i = 0; i < Y_WIDTH; i = i + 1) begin:slice + LUT4_HA #( + .INIT(16'b1001_0110_1001_0110), // full adder sum over (I2, I1, I0) + .I0MUX(1'b1) + ) lut_i ( + .I0(), .I1(AA[i]), .I2(BB[i]), .I3(), + .Ci(CARRY[i]), + .O(Y[i]), + .Co(CARRY[i+1]) + ); + + assign CO[i] = (AA[i] && BB[i]) || ((Y[i] ^ AA[i] ^ BB[i]) && (AA[i] || BB[i])); +end endgenerate + +assign X = AA ^ BB; + +endmodule +`endif diff --git a/chips/yosys/tests/arch/fabulous/carry.ys b/chips/yosys/tests/arch/fabulous/carry.ys new file mode 100644 index 0000000000000000000000000000000000000000..b0e723c7558c6c832f687fb6066be6ae905ea79a --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/carry.ys @@ -0,0 +1,9 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +proc +equiv_opt -assert -map prims.v synth_fabulous -carry ha -noiopad -ff $_DFF_P_ x -ff $_DLATCH_?_ x -extra-plib prims.v -cells-map cells_map.v -arith-map arith_map.v -extra-map ff_map.v -extra-map latches_map.v # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-max 10 t:LUT4_HA +select -assert-max 4 t:LUT1 +select -assert-none t:LUT1 t:LUT4_HA %% t:* %D diff --git a/chips/yosys/tests/arch/fabulous/cells_map.v b/chips/yosys/tests/arch/fabulous/cells_map.v new file mode 100644 index 0000000000000000000000000000000000000000..2329286f569e901b61f4d907c7c3dcc8ecd7d56b --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/cells_map.v @@ -0,0 +1,30 @@ +module \$lut (A, Y); + parameter WIDTH = 0; + parameter LUT = 0; + + input [WIDTH-1:0] A; + output Y; + + generate + if (WIDTH == 1) begin + LUT1 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0])); + end else + if (WIDTH == 2) begin + LUT2 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0]), .I1(A[1])); + end else + if (WIDTH == 3) begin + LUT3 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0]), .I1(A[1]), .I2(A[2])); + end else + if (WIDTH == 4) begin + LUT4 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0]), .I1(A[1]), .I2(A[2]), .I3(A[3])); + end else + if (WIDTH == 5) begin + LUT5 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0]), .I1(A[1]), .I2(A[2]), .I3(A[3]), .I4(A[4])); + end else + if (WIDTH == 6) begin + LUT6 #(.INIT(LUT)) _TECHMAP_REPLACE_ (.O(Y), .I0(A[0]), .I1(A[1]), .I2(A[2]), .I3(A[3]), .I4(A[4]), .I5(A[5])); + end else begin + wire _TECHMAP_FAIL_ = 1; + end + endgenerate +endmodule diff --git a/chips/yosys/tests/arch/fabulous/complexflop.ys b/chips/yosys/tests/arch/fabulous/complexflop.ys new file mode 100644 index 0000000000000000000000000000000000000000..c5f300284c62694e32e23b270d215ff8853e79c6 --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/complexflop.ys @@ -0,0 +1,37 @@ +read_verilog < (others => '0')); + reg [3:0] mem [31:0]; + + wire [4:0] W_ADR;// write address + wire [4:0] A_ADR;// port A read address + wire [4:0] B_ADR;// port B read address + + wire [3:0] D; // write data + wire [3:0] AD; // port A read data + wire [3:0] BD; // port B read data + + reg [3:0] AD_q; // port A read data register + reg [3:0] BD_q; // port B read data register + + integer i; + + assign W_ADR = {W_ADR4,W_ADR3,W_ADR2,W_ADR1,W_ADR0}; + assign A_ADR = {A_ADR4,A_ADR3,A_ADR2,A_ADR1,A_ADR0}; + assign B_ADR = {B_ADR4,B_ADR3,B_ADR2,B_ADR1,B_ADR0}; + + assign D = {D3,D2,D1,D0}; + + initial begin + for (i=0; i<32; i=i+1) begin + mem[i] = 4'b0000; + end + end + + always @ (posedge CLK) begin : P_write + if (W_en == 1'b1) begin + mem[W_ADR] <= D ; + end + end + + assign AD = mem[A_ADR]; + assign BD = mem[B_ADR]; + + always @ (posedge CLK) begin + AD_q <= AD; + BD_q <= BD; + end + + assign AD0 = AD_reg ? AD_q[0] : AD[0]; + assign AD1 = AD_reg ? AD_q[1] : AD[1]; + assign AD2 = AD_reg ? AD_q[2] : AD[2]; + assign AD3 = AD_reg ? AD_q[3] : AD[3]; + + assign BD0 = BD_reg ? BD_q[0] : BD[0]; + assign BD1 = BD_reg ? BD_q[1] : BD[1]; + assign BD2 = BD_reg ? BD_q[2] : BD[2]; + assign BD3 = BD_reg ? BD_q[3] : BD[3]; + +endmodule + +module LUTFF(input CLK, D, output reg O); + initial O = 1'b0; + always @ (posedge CLK) begin + O <= D; + end +endmodule + +module LUTFF_E ( + output reg O, + input CLK, E, D +); + initial O = 1'b0; + always @(posedge CLK) + if (E) + O <= D; +endmodule + +module LUTFF_SR ( + output reg O, + input CLK, R, D +); + initial O = 1'b0; + always @(posedge CLK) + if (R) + O <= 0; + else + O <= D; +endmodule + +module LUTFF_SS ( + output reg O, + input CLK, S, D +); + initial O = 1'b0; + always @(posedge CLK) + if (S) + O <= 1; + else + O <= D; +endmodule + +module LUTFF_ESR ( + output reg O, + input CLK, E, R, D +); + initial O = 1'b0; + always @(posedge CLK) + if (E) begin + if (R) + O <= 0; + else + O <= D; + end +endmodule + +module LUTFF_ESS ( + output reg O, + input CLK, E, S, D +); + initial O = 1'b0; + always @(posedge CLK) + if (E) begin + if (S) + O <= 1; + else + O <= D; + end +endmodule diff --git a/chips/yosys/tests/arch/fabulous/ram_regfile.txt b/chips/yosys/tests/arch/fabulous/ram_regfile.txt new file mode 100644 index 0000000000000000000000000000000000000000..af834b005fd544b9a985389e7c8ef3ae0787aba8 --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/ram_regfile.txt @@ -0,0 +1,46 @@ +# Yosys doesn't support configurable sync/async ports. +# So we define three RAMs for 2xasync, 1xsync 1xasync and 2xsync + +ram distributed $__REGFILE_AA_ { + abits 5; + width 4; + cost 6; + port sw "W" { + clock posedge "CLK"; + } + port ar "A" { + } + port ar "B" { + } +} + +ram distributed $__REGFILE_SA_ { + abits 5; + width 4; + cost 5; + port sw "W" { + clock posedge "CLK"; + wrtrans all old; + } + port sr "A" { + clock posedge "CLK"; + } + port ar "B" { + } +} + +ram distributed $__REGFILE_SS_ { + abits 5; + width 4; + cost 4; + port sw "W" { + clock posedge "CLK"; + wrtrans all old; + } + port sr "A" { + clock posedge "CLK"; + } + port sr "B" { + clock posedge "CLK"; + } +} diff --git a/chips/yosys/tests/arch/fabulous/regfile.ys b/chips/yosys/tests/arch/fabulous/regfile.ys new file mode 100644 index 0000000000000000000000000000000000000000..191c596d72af1b9142ed708a31eba629b23d2986 --- /dev/null +++ b/chips/yosys/tests/arch/fabulous/regfile.ys @@ -0,0 +1,33 @@ +read_verilog < CC_BRAM_20K SDP RAM +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 40 sync_ram_sdp +synth_gatemate -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:CC_BUFG +select -assert-count 1 t:CC_BRAM_20K + +# 512 x 20 bit x 2 -> CC_BRAM_20K TDP RAM +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 20 sync_ram_tdp +synth_gatemate -top sync_ram_tdp -noiopad +select -assert-count 2 t:CC_BUFG +select -assert-count 1 t:CC_BRAM_20K + +# 512 x 80 bit -> CC_BRAM_40K SDP RAM +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 80 sync_ram_sdp +synth_gatemate -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:CC_BUFG +select -assert-count 1 t:CC_BRAM_40K + +# 512 x 40 bit -> CC_BRAM_20K SDP ROM +design -reset +read_verilog ../common/blockrom.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 40 sync_rom +synth_gatemate -top sync_rom -noiopad +cd sync_rom +select -assert-count 1 t:CC_BUFG +select -assert-count 1 t:CC_BRAM_20K + +# 512 x 80 bit -> CC_BRAM_40K SDP ROM +design -reset +read_verilog ../common/blockrom.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 80 sync_rom +synth_gatemate -top sync_rom -noiopad +cd sync_rom +select -assert-count 1 t:CC_BUFG +select -assert-count 1 t:CC_BRAM_40K diff --git a/chips/yosys/tests/arch/gatemate/mul.v b/chips/yosys/tests/arch/gatemate/mul.v new file mode 100644 index 0000000000000000000000000000000000000000..55e8f9006502a5ce7f0661efdbdc163edfa5d29e --- /dev/null +++ b/chips/yosys/tests/arch/gatemate/mul.v @@ -0,0 +1,79 @@ + +module mul_plain(a, b, p); + + parameter M = 6; + parameter N = 6; + + input wire [M-1:0] a; + input wire [N-1:0] b; + output wire [M+N-1:0] p; + + assign p = a * b; + +endmodule + +module mul_signed_async (clk, rst, en, a, b, p); + + parameter M = 8; + parameter N = 6; + + input wire signed clk, rst, en; + input wire signed [M-1:0] a; + input wire signed [N-1:0] b; + output reg signed [M+N-1:0] p; + + reg signed [M-1:0] a_reg; + reg signed [N-1:0] b_reg; + + // signed M*N multiplier with + // - input and output pipeline registers + // - asynchronous reset (active high) + // - clock enable (active high) + always @(posedge clk or posedge rst) + begin + if (rst) begin + a_reg <= 0; + b_reg <= 0; + p <= 0; + end + else if (en) begin + a_reg <= a; + b_reg <= b; + p <= a_reg * b_reg; + end + end + +endmodule + +module mul_unsigned_sync (clk, rst, en, a, b, p); + + parameter M = 6; + parameter N = 3; + + input wire clk, rst, en; + input wire [M-1:0] a; + input wire [N-1:0] b; + output reg [M+N-1:0] p; + + reg [M-1:0] a_reg; + reg [N-1:0] b_reg; + + // unsigned M*N multiplier with + // - input and output pipeline registers + // - synchronous reset (active high) + // - clock enable (active high) + always @(posedge clk) + begin + if (rst) begin + a_reg <= 0; + b_reg <= 0; + p <= 0; + end + else if (en) begin + a_reg <= a; + b_reg <= b; + p <= a_reg * b_reg; + end + end + +endmodule diff --git a/chips/yosys/tests/arch/gatemate/mul.ys b/chips/yosys/tests/arch/gatemate/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..ef2255a767546a77fd2bbc7628481ff7e69c6f85 --- /dev/null +++ b/chips/yosys/tests/arch/gatemate/mul.ys @@ -0,0 +1,59 @@ +read_verilog mul.v +design -save read + +hierarchy -top mul_plain +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_plain # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_MULT +select -assert-none t:CC_MULT %% t:* %D + +design -load read +hierarchy -top mul_signed_async +proc +equiv_opt -assert -async2sync -map +/gatemate/cells_sim.v synth_gatemate -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_signed_async # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_MULT +select -assert-count 1 t:CC_BUFG +select -assert-count 28 t:CC_DFF +select -assert-none t:CC_MULT t:CC_BUFG t:CC_DFF %% t:* %D + +design -load read +hierarchy -top mul_unsigned_sync +proc +equiv_opt -assert -async2sync -map +/gatemate/cells_sim.v synth_gatemate -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned_sync # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_MULT +select -assert-count 1 t:CC_BUFG +select -assert-max 18 t:CC_LUT4 +select -assert-count 18 t:CC_DFF +select -assert-none t:CC_MULT t:CC_BUFG t:CC_LUT4 t:CC_DFF %% t:* %D + +design -load read +hierarchy -top mul_unsigned_sync +proc +equiv_opt -assert -async2sync -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned_sync # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_MULT +select -assert-count 1 t:CC_BUFG +select -assert-count 18 t:CC_LUT2 +select -assert-count 18 t:CC_MX2 +select -assert-count 18 t:CC_DFF +select -assert-none t:CC_MULT t:CC_BUFG t:CC_LUT2 t:CC_MX2 t:CC_DFF %% t:* %D + +design -load read +hierarchy -top mul_unsigned_sync +proc +# equiv_opt -assert -async2sync -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree -abc_new # equivalency check (fails) +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned_sync # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_MULT +select -assert-count 1 t:CC_BUFG +select -assert-count 18 t:CC_LUT2 +select -assert-count 18 t:CC_MX2 +select -assert-count 18 t:CC_DFF +select -assert-none t:CC_MULT t:CC_BUFG t:CC_LUT2 t:CC_MX2 t:CC_DFF %% t:* %D diff --git a/chips/yosys/tests/arch/gatemate/mux.ys b/chips/yosys/tests/arch/gatemate/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..9881830f1559ff189c39bd96763e38c3feac611a --- /dev/null +++ b/chips/yosys/tests/arch/gatemate/mux.ys @@ -0,0 +1,58 @@ +read_verilog ../common/mux.v +design -save read + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-max 3 t:CC_LUT3 +select -assert-none t:CC_LUT3 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 3 t:CC_MX2 +select -assert-none t:CC_MX2 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree -abc_new # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:CC_LUT1 +select -assert-count 3 t:CC_MX2 +select -assert-none t:CC_LUT1 t:CC_MX2 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-max 3 t:CC_LUT3 +select -assert-max 3 t:CC_LUT4 +select -assert-none t:CC_LUT3 t:CC_LUT4 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 7 t:CC_MX2 +select -assert-none t:CC_MX2 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/gatemate/cells_sim.v synth_gatemate -noiopad -luttree -abc_new # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 7 t:CC_MX2 +select -assert-none t:CC_MX2 %% t:* %D diff --git a/chips/yosys/tests/arch/gatemate/noflatten.ys b/chips/yosys/tests/arch/gatemate/noflatten.ys new file mode 100644 index 0000000000000000000000000000000000000000..ce0da468b9a206085e100ab5dfd4ecfd5acf9142 --- /dev/null +++ b/chips/yosys/tests/arch/gatemate/noflatten.ys @@ -0,0 +1,31 @@ +# Test that `synth_gatemate -noflatten` keeps a submodule in the design, +# and that only the top module receives IO pads. + +read_verilog < y; + assign ge = x >= y; + assign eq = x == y; + assign ne = x != y; +endmodule diff --git a/chips/yosys/tests/arch/gowin/compare.ys b/chips/yosys/tests/arch/gowin/compare.ys new file mode 100644 index 0000000000000000000000000000000000000000..657d2daf88ceb49e6d498022e17870849963f8de --- /dev/null +++ b/chips/yosys/tests/arch/gowin/compare.ys @@ -0,0 +1,7 @@ +read_verilog compare.v +hierarchy -top top +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 5 t:ALU diff --git a/chips/yosys/tests/arch/gowin/counter.ys b/chips/yosys/tests/arch/gowin/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..ec6ca0f5ee2657a752c55c17e6da62b19147462f --- /dev/null +++ b/chips/yosys/tests/arch/gowin/counter.ys @@ -0,0 +1,16 @@ +read_verilog ../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:LUT1 +select -assert-count 8 t:DFFC +select -assert-count 8 t:ALU +select -assert-count 1 t:GND +select -assert-count 1 t:VCC +select -assert-count 2 t:IBUF +select -assert-count 8 t:OBUF +select -assert-none t:LUT1 t:DFFC t:ALU t:GND t:VCC t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/dffs.ys b/chips/yosys/tests/arch/gowin/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..9c012213fa87efd349a148dbebddb6d8879b3808 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/dffs.ys @@ -0,0 +1,25 @@ +read_verilog ../common/dffs.v +design -save read + +hierarchy -top dff +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dff # Constrain all select calls below inside the top module +select -assert-count 1 t:DFF +select -assert-count 2 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:DFF t:IBUF t:OBUF %% t:* %D + +design -load read +hierarchy -top dffe +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:DFFE +select -assert-count 3 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:DFFE t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/fsm.ys b/chips/yosys/tests/arch/gowin/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..ce450452235571c02bd4d7cf0f57bca39f9cbf20 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/fsm.ys @@ -0,0 +1,11 @@ +read_verilog ../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/gowin/cells_sim.v synth_gowin # equivalency check +miter -equiv -make_assert -flatten gold gate miter +sat -verify -show-all -dump_vcd x.vcd -prove-asserts -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +#design -load postopt +#shell diff --git a/chips/yosys/tests/arch/gowin/generate_mk.py b/chips/yosys/tests/arch/gowin/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..06a6040ad48bae5c2ce7163455d96b2401a68986 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/gowin/init-error.ys b/chips/yosys/tests/arch/gowin/init-error.ys new file mode 100644 index 0000000000000000000000000000000000000000..de3813d6f8aed0d0395d428fdc99b6406b9db42e --- /dev/null +++ b/chips/yosys/tests/arch/gowin/init-error.ys @@ -0,0 +1,5 @@ +read_verilog init.v +chparam -set INIT 0 myDFF*P* +hierarchy -top myDFFP +logger -expect error "unsupported initial value and async reset value combination" 1 +synth_gowin diff --git a/chips/yosys/tests/arch/gowin/init.v b/chips/yosys/tests/arch/gowin/init.v new file mode 100644 index 0000000000000000000000000000000000000000..3c30f602dae8ad3eb1375df2a552862fffd24fb7 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/init.v @@ -0,0 +1,224 @@ +module myDFF (output reg Q, input CLK, D); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK) + Q <= D; +endmodule + +module myDFFE (output reg Q, input D, CLK, CE); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK) begin + if (CE) + Q <= D; + end +endmodule // DFFE (positive clock edge; clock enable) + + +module myDFFS (output reg Q, input D, CLK, SET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(posedge CLK) begin + if (SET) + Q <= 1'b1; + else + Q <= D; + end +endmodule // DFFS (positive clock edge; synchronous set) + + +module myDFFSE (output reg Q, input D, CLK, CE, SET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(posedge CLK) begin + if (SET) + Q <= 1'b1; + else if (CE) + Q <= D; +end +endmodule // DFFSE (positive clock edge; synchronous set takes precedence over clock enable) + + +module myDFFR (output reg Q, input D, CLK, RESET); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK) begin + if (RESET) + Q <= 1'b0; + else + Q <= D; + end +endmodule // DFFR (positive clock edge; synchronous reset) + + +module myDFFRE (output reg Q, input D, CLK, CE, RESET); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK) begin + if (RESET) + Q <= 1'b0; + else if (CE) + Q <= D; + end +endmodule // DFFRE (positive clock edge; synchronous reset takes precedence over clock enable) + + +module myDFFP (output reg Q, input D, CLK, PRESET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(posedge CLK or posedge PRESET) begin + if(PRESET) + Q <= 1'b1; + else + Q <= D; + end +endmodule // DFFP (positive clock edge; asynchronous preset) + + +module myDFFPE (output reg Q, input D, CLK, CE, PRESET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(posedge CLK or posedge PRESET) begin + if(PRESET) + Q <= 1'b1; + else if (CE) + Q <= D; + end +endmodule // DFFPE (positive clock edge; asynchronous preset; clock enable) + + +module myDFFC (output reg Q, input D, CLK, CLEAR); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK or posedge CLEAR) begin + if(CLEAR) + Q <= 1'b0; + else + Q <= D; + end +endmodule // DFFC (positive clock edge; asynchronous clear) + + +module myDFFCE (output reg Q, input D, CLK, CE, CLEAR); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(posedge CLK or posedge CLEAR) begin + if(CLEAR) + Q <= 1'b0; + else if (CE) + Q <= D; + end +endmodule // DFFCE (positive clock edge; asynchronous clear; clock enable) + + +module myDFFN (output reg Q, input CLK, D); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK) + Q <= D; +endmodule + +module myDFFNE (output reg Q, input D, CLK, CE); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK) begin + if (CE) + Q <= D; + end +endmodule // DFFNE (negative clock edge; clock enable) + + +module myDFFNS (output reg Q, input D, CLK, SET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(negedge CLK) begin + if (SET) + Q <= 1'b1; + else + Q <= D; + end +endmodule // DFFNS (negative clock edge; synchronous set) + + +module myDFFNSE (output reg Q, input D, CLK, CE, SET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(negedge CLK) begin + if (SET) + Q <= 1'b1; + else if (CE) + Q <= D; +end +endmodule // DFFNSE (negative clock edge; synchronous set takes precedence over clock enable) + + +module myDFFNR (output reg Q, input D, CLK, RESET); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK) begin + if (RESET) + Q <= 1'b0; + else + Q <= D; + end +endmodule // DFFNR (negative clock edge; synchronous reset) + + +module myDFFNRE (output reg Q, input D, CLK, CE, RESET); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK) begin + if (RESET) + Q <= 1'b0; + else if (CE) + Q <= D; + end +endmodule // DFFNRE (negative clock edge; synchronous reset takes precedence over clock enable) + + +module myDFFNP (output reg Q, input D, CLK, PRESET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(negedge CLK or posedge PRESET) begin + if(PRESET) + Q <= 1'b1; + else + Q <= D; + end +endmodule // DFFNP (negative clock edge; asynchronous preset) + + +module myDFFNPE (output reg Q, input D, CLK, CE, PRESET); + parameter [0:0] INIT = 1'b1; + initial Q = INIT; + always @(negedge CLK or posedge PRESET) begin + if(PRESET) + Q <= 1'b1; + else if (CE) + Q <= D; + end +endmodule // DFFNPE (negative clock edge; asynchronous preset; clock enable) + + +module myDFFNC (output reg Q, input D, CLK, CLEAR); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK or posedge CLEAR) begin + if(CLEAR) + Q <= 1'b0; + else + Q <= D; + end +endmodule // DFFNC (negative clock edge; asynchronous clear) + + +module myDFFNCE (output reg Q, input D, CLK, CE, CLEAR); + parameter [0:0] INIT = 1'b0; + initial Q = INIT; + always @(negedge CLK or posedge CLEAR) begin + if(CLEAR) + Q <= 1'b0; + else if (CE) + Q <= D; + end +endmodule // DFFNCE (negative clock edge; asynchronous clear; clock enable) diff --git a/chips/yosys/tests/arch/gowin/init.ys b/chips/yosys/tests/arch/gowin/init.ys new file mode 100644 index 0000000000000000000000000000000000000000..d522801c63d5ca4701264032392586782b6e394c --- /dev/null +++ b/chips/yosys/tests/arch/gowin/init.ys @@ -0,0 +1,69 @@ +read_verilog init.v +read_verilog -lib -specify +/gowin/cells_sim.v +design -save read + +proc +flatten +synth_gowin -run coarse: + +# check if all init values are handled +check -assert -noinit +# check if every flop mapped correctly +select -assert-count 1 t:DFF +select -assert-count 1 t:DFFC +select -assert-count 1 t:DFFCE +select -assert-count 1 t:DFFE +select -assert-count 1 t:DFFN +select -assert-count 1 t:DFFNC +select -assert-count 1 t:DFFNCE +select -assert-count 1 t:DFFNE +select -assert-count 1 t:DFFNP +select -assert-count 1 t:DFFNPE +select -assert-count 1 t:DFFNR +select -assert-count 1 t:DFFNRE +select -assert-count 1 t:DFFNS +select -assert-count 1 t:DFFNSE +select -assert-count 1 t:DFFP +select -assert-count 1 t:DFFPE +select -assert-count 1 t:DFFR +select -assert-count 1 t:DFFRE +select -assert-count 1 t:DFFS +select -assert-count 1 t:DFFSE + +design -load read + +# these should synth to a flop with reset +chparam -set INIT 1 myDFF myDFFN myDFFE myDFFNE + +# async would give an error +# sync should synth to a mux +chparam -set INIT 0 myDFF*S* +chparam -set INIT 1 myDFF*R* + +proc +flatten +synth_gowin -run coarse: + +# check the flops mapped as expected +select -assert-count 2 t:DFF +select -assert-count 1 t:DFFC +select -assert-count 1 t:DFFCE +select -assert-count 0 t:DFFE +select -assert-count 2 t:DFFN +select -assert-count 1 t:DFFNC +select -assert-count 1 t:DFFNCE +select -assert-count 0 t:DFFNE +select -assert-count 1 t:DFFNP +select -assert-count 1 t:DFFNPE +select -assert-count 0 t:DFFNR +select -assert-count 0 t:DFFNRE +select -assert-count 3 t:DFFNS +select -assert-count 1 t:DFFNSE +select -assert-count 1 t:DFFP +select -assert-count 1 t:DFFPE +select -assert-count 0 t:DFFR +select -assert-count 0 t:DFFRE +select -assert-count 3 t:DFFS +select -assert-count 1 t:DFFSE +select -assert-count 4 t:LUT2 +select -assert-count 4 t:LUT4 diff --git a/chips/yosys/tests/arch/gowin/latches.ys b/chips/yosys/tests/arch/gowin/latches.ys new file mode 100644 index 0000000000000000000000000000000000000000..6a05d2357de258a59638adf465252c00ca46439f --- /dev/null +++ b/chips/yosys/tests/arch/gowin/latches.ys @@ -0,0 +1,25 @@ +read_verilog ../common/latches.v +design -save read + +hierarchy -top latchp +proc +equiv_opt -async2sync -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd latchp # Constrain all select calls below inside the top module +select -assert-count 1 t:DL +select -assert-count 3 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:DL t:IBUF t:OBUF %% t:* %D + +design -load read +hierarchy -top latchn +proc +equiv_opt -async2sync -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd latchn # Constrain all select calls below inside the top module +select -assert-count 1 t:DLN +select -assert-count 3 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:DLN t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/logic.ys b/chips/yosys/tests/arch/gowin/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..d2b9e4540cfd947f7042babcd6df471192a76702 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/logic.ys @@ -0,0 +1,13 @@ +read_verilog ../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:LUT1 +select -assert-count 6 t:LUT2 +select -assert-count 2 t:LUT4 +select -assert-count 8 t:IBUF +select -assert-count 10 t:OBUF +select -assert-none t:LUT1 t:LUT2 t:LUT4 t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/lutram.ys b/chips/yosys/tests/arch/gowin/lutram.ys new file mode 100644 index 0000000000000000000000000000000000000000..d668783a226e43fb0c2e6f7de4b7252d4edb4cd7 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/lutram.ys @@ -0,0 +1,17 @@ +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +proc +memory -nomap +equiv_opt -run :prove -map +/gowin/cells_sim.v synth_gowin +memory +opt -full + +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 5 -set-init-zero -show-inputs -show-outputs miter +sat -prove-asserts -seq 5 -set-init-zero -show-inputs -show-outputs miter + +design -load postopt +cd lutram_1w1r +select -assert-count 8 t:RAM16SDP4 +# other logic present that is not simple +#select -assert-none t:RAM16S4 %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/mul_gw1n.ys b/chips/yosys/tests/arch/gowin/mul_gw1n.ys new file mode 100644 index 0000000000000000000000000000000000000000..9b174825571a528911d2b0d5f1906472bc187005 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/mul_gw1n.ys @@ -0,0 +1,53 @@ +read_verilog ../common/mul.v +chparam -set X_WIDTH 8 -set Y_WIDTH 8 -set A_WIDTH 16 +hierarchy -top top +proc +# equivalence checking is somewhat slow (and missing simulation models) +synth_gowin -family gw1n +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT9X9 + + +# Make sure that DSPs are not inferred with -nodsp option +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 8 -set Y_WIDTH 8 -set A_WIDTH 16 +hierarchy -top top +proc +synth_gowin -family gw1n -nodsp +cd top # Constrain all select calls below inside the top module +select -assert-none t:MULT9X9 + + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 16 -set Y_WIDTH 16 -set A_WIDTH 32 +hierarchy -top top +proc +synth_gowin -family gw1n +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT18X18 + + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 32 -set Y_WIDTH 32 -set A_WIDTH 64 +hierarchy -top top +proc +# equivalence checking is too slow here +synth_gowin +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT36X36 + + +# We end up with two 18x18 multipliers +# 36x36 min width is 22 +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 32 -set Y_WIDTH 16 -set A_WIDTH 48 +hierarchy -top top +proc +# equivalence checking is too slow here +synth_gowin +cd top # Constrain all select calls below inside the top module +select -assert-count 2 t:MULT18X18 diff --git a/chips/yosys/tests/arch/gowin/mul_gw2a.ys b/chips/yosys/tests/arch/gowin/mul_gw2a.ys new file mode 100644 index 0000000000000000000000000000000000000000..895c580b7869a723fa049c73fb54895c3da26454 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/mul_gw2a.ys @@ -0,0 +1,53 @@ +read_verilog ../common/mul.v +chparam -set X_WIDTH 8 -set Y_WIDTH 8 -set A_WIDTH 16 +hierarchy -top top +proc +# equivalence checking is somewhat slow (and missing simulation models) +synth_gowin -family gw2a +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT9X9 + + +# Make sure that DSPs are not inferred with -nodsp option +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 8 -set Y_WIDTH 8 -set A_WIDTH 16 +hierarchy -top top +proc +synth_gowin -family gw2a -nodsp +cd top # Constrain all select calls below inside the top module +select -assert-none t:MULT9X9 + + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 16 -set Y_WIDTH 16 -set A_WIDTH 32 +hierarchy -top top +proc +synth_gowin -family gw2a +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT18X18 + + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 32 -set Y_WIDTH 32 -set A_WIDTH 64 +hierarchy -top top +proc +# equivalence checking is too slow here +synth_gowin -family gw2a +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:MULT36X36 + + +# We end up with two 18x18 multipliers +# 36x36 min width is 22 +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 32 -set Y_WIDTH 16 -set A_WIDTH 48 +hierarchy -top top +proc +# equivalence checking is too slow here +synth_gowin -family gw2a +cd top # Constrain all select calls below inside the top module +select -assert-count 2 t:MULT18X18 diff --git a/chips/yosys/tests/arch/gowin/mux.ys b/chips/yosys/tests/arch/gowin/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..e9a7bd432d05595181999666ec9be7a313655a2d --- /dev/null +++ b/chips/yosys/tests/arch/gowin/mux.ys @@ -0,0 +1,56 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 3 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:LUT3 t:IBUF t:OBUF %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 4 t:LUT* +select -assert-count 2 t:MUX2_LUT5 +select -assert-count 1 t:MUX2_LUT6 +select -assert-count 6 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:LUT* t:MUX2_LUT6 t:MUX2_LUT5 t:IBUF t:OBUF %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 9 t:LUT1 +select -assert-count 2 t:LUT3 +select -assert-count 1 t:LUT4 +select -assert-count 5 t:MUX2_LUT5 +select -assert-count 2 t:MUX2_LUT6 +select -assert-count 1 t:MUX2_LUT7 +select -assert-count 11 t:IBUF +select -assert-count 1 t:OBUF +select -assert-count 1 t:GND + +select -assert-none t:LUT* t:MUX2_LUT7 t:MUX2_LUT6 t:MUX2_LUT5 t:IBUF t:OBUF t:GND %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # 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 20 t:IBUF +select -assert-count 1 t:OBUF + +select -assert-none t:GND t:VCC t:LUT* t:MUX2_LUT6 t:MUX2_LUT5 t:MUX2_LUT6 t:MUX2_LUT7 t:MUX2_LUT8 t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/shifter.ys b/chips/yosys/tests/arch/gowin/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..b43b1e869ec56afc1da1f1c415ec81c21f06b360 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/shifter.ys @@ -0,0 +1,12 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/gowin/cells_sim.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 8 t:DFF +select -assert-count 2 t:IBUF +select -assert-count 8 t:OBUF +select -assert-none t:DFF t:IBUF t:OBUF %% t:* %D diff --git a/chips/yosys/tests/arch/gowin/tribuf.ys b/chips/yosys/tests/arch/gowin/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..67207970653487aee61dc5fe8ed395d53de5b903 --- /dev/null +++ b/chips/yosys/tests/arch/gowin/tribuf.ys @@ -0,0 +1,14 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/gowin/cells_sim.v -map +/simcells.v synth_gowin # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +#Internal cell type used. Need support it. +select -assert-count 1 t:TBUF +select -assert-count 1 t:LUT1 +select -assert-count 2 t:IBUF +select -assert-none t:TBUF t:IBUF t:LUT1 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/.gitignore b/chips/yosys/tests/arch/ice40/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a86b36792e48b8f18729d9e96b0dd72c179ada7b --- /dev/null +++ b/chips/yosys/tests/arch/ice40/.gitignore @@ -0,0 +1,3 @@ +*.json ++*_synth.v ++*_testbench diff --git a/chips/yosys/tests/arch/ice40/add_sub.ys b/chips/yosys/tests/arch/ice40/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..c07b2219fe0ce7ac529a7b4d6a664e67780c4376 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/add_sub.ys @@ -0,0 +1,8 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 10 t:SB_LUT4 +select -assert-count 6 t:SB_CARRY +select -assert-none t:SB_LUT4 t:SB_CARRY %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/adffs.ys b/chips/yosys/tests/arch/ice40/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..e5dbabb43d899165873c9ffa0962e57c945400b3 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/adffs.ys @@ -0,0 +1,39 @@ +read_verilog ../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_DFFR +select -assert-none t:SB_DFFR %% t:* %D + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_DFFR +select -assert-count 1 t:SB_LUT4 +select -assert-none t:SB_DFFR t:SB_LUT4 %% t:* %D + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_DFFSS +select -assert-none t:SB_DFFSS %% t:* %D + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_DFFNSR +select -assert-count 1 t:SB_LUT4 +select -assert-none t:SB_DFFNSR t:SB_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/bram_init.v b/chips/yosys/tests/arch/ice40/bram_init.v new file mode 100644 index 0000000000000000000000000000000000000000..02c7e602d14d28eb4dfe3134736fcbd9754e4f3d --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init.v @@ -0,0 +1,72 @@ +// Test design for SB_RAM40_4K initialization data generation. +// Four widths, all would fit into one RAM40_4K (4096 bits) +// with random init data taken from bram_init_.hex. +// random init data is from author's /dev/random. + +module ram16 (clk, we, addr, wdata, rdata); +input clk, we; +input [7:0] addr; +input [15:0] wdata; +output reg [15:0] rdata; + +reg [15:0] mem [0:255]; +initial $readmemh("bram_init_16.hex", mem); + +always @(posedge clk) begin + if (we) + mem[addr] <= wdata; + rdata <= mem[addr]; +end + +endmodule + +module ram8 (clk, we, addr, wdata, rdata); +input clk, we; +input [8:0] addr; +input [7:0] wdata; +output reg [7:0] rdata; + +reg [7:0] mem [0:511]; +initial $readmemh("bram_init_8.hex", mem); + +always @(posedge clk) begin + if (we) + mem[addr] <= wdata; + rdata <= mem[addr]; +end + +endmodule + +module ram4 (clk, we, addr, wdata, rdata); +input clk, we; +input [9:0] addr; +input [3:0] wdata; +output reg [3:0] rdata; + +reg [3:0] mem [0:1023]; +initial $readmemh("bram_init_4.hex", mem); + +always @(posedge clk) begin + if (we) + mem[addr] <= wdata; + rdata <= mem[addr]; +end + +endmodule + +module ram2 (clk, we, addr, wdata, rdata); +input clk, we; +input [10:0] addr; +input [1:0] wdata; +output reg [1:0] rdata; + +reg [1:0] mem [0:2047]; +initial $readmemh("bram_init_2.hex", mem); + +always @(posedge clk) begin + if (we) + mem[addr] <= wdata; + rdata <= mem[addr]; +end + +endmodule diff --git a/chips/yosys/tests/arch/ice40/bram_init.ys b/chips/yosys/tests/arch/ice40/bram_init.ys new file mode 100644 index 0000000000000000000000000000000000000000..b50619f5e5b2394dc9acb0088e3d73b6d1b92a6f --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init.ys @@ -0,0 +1,98 @@ +# Golden test for iCE40 SB_RAM40_4K initialization data generation +# (memory_bram + techlibs/ice40/brams_map.v slice_init bit mapping). +# +# Init data: 4096 random bits from /dev/random, stored in bram_init_.hex. +# The INIT_0..INIT_F values below were recorded from yosys 8f3cc3d0c as the +# golden reference; any change in BRAM init generation breaks this test. +# Note: all bit widths of BRAM will have the same init data shown below, +# because they are all mapped to the same RAM40_4K resource. All the four +# types of BRAM test input share the same random data input, the only +# difference is the port width cut. + +design -reset +read_verilog bram_init.v +synth_ice40 -top ram16 +cd ram16 +select -assert-count 1 t:SB_RAM40_4K +select -assert-count 1 r:INIT_0=256'h1d5eb9737962af83fe39fc172dd49895c924a593f46a5faffc703ead422916d3 +select -assert-count 1 r:INIT_1=256'h7dce1aca4908a3d2fb83d464bddff628e35151c46bec064fee2da86b15f4712a +select -assert-count 1 r:INIT_2=256'h01e1bac5bebd58b92ef582d39a5e8f90a9e107c14b52d26215150df1a136c986 +select -assert-count 1 r:INIT_3=256'h38d8a5b31342f1ac2e7a0b1b94869fecf0edb4355626d22227a85095a3fb93cd +select -assert-count 1 r:INIT_4=256'hb21ba31e3cf9d8350aaea60bbf056e84ee536f6f5393ebaa705613b8eb20716b +select -assert-count 1 r:INIT_5=256'h01ff616027f57e62ec2da16f407505c7bd07b43aff7b5ce9a19a357b9c4ebcde +select -assert-count 1 r:INIT_6=256'hcb06e9bda042be47a7d5b8daf8fb58eead8bba47b6c51a70ea0bef0bff2f78da +select -assert-count 1 r:INIT_7=256'h42e0d2954262a8a31b4a5d194dc10344ae32d84805859fa12744054d01d0ee9c +select -assert-count 1 r:INIT_8=256'h042ac94be56daf1dfd5441986808138dc009e95ce51dd67bf88c3210d947f2f2 +select -assert-count 1 r:INIT_9=256'h4d77f080be61c7f277ef3509fe55eb6c4188d2679e86e1eb5204a0089069eae0 +select -assert-count 1 r:INIT_A=256'hbb0113aea7542aa0363a20bdf97db1ac08f98d82136f733f1de9ceeca0cebb3b +select -assert-count 1 r:INIT_B=256'h3022343256f932aa2339477be2e805102e711f707d44498b2810b0f028347189 +select -assert-count 1 r:INIT_C=256'h5260de0fa26ea82d12bcb3fd32187e83d72f7090a2e642b7c11abfb7e98ef2d2 +select -assert-count 1 r:INIT_D=256'h6d9971bb55ab57b9fab66cd0943db588ca542a2270981fc27a20b796e5462271 +select -assert-count 1 r:INIT_E=256'hf0326faee3e48c266887b9e542a03677091fae593cf8453fc2967d4b88fd171e +select -assert-count 1 r:INIT_F=256'h15d099dec9ada9e038ba12efe74ad07365b3694c50c34f18440699e02addfe91 + +design -reset +read_verilog bram_init.v +synth_ice40 -top ram8 +cd ram8 +select -assert-count 1 t:SB_RAM40_4K +select -assert-count 1 r:INIT_0=256'h1d5eb9737962af83fe39fc172dd49895c924a593f46a5faffc703ead422916d3 +select -assert-count 1 r:INIT_1=256'h7dce1aca4908a3d2fb83d464bddff628e35151c46bec064fee2da86b15f4712a +select -assert-count 1 r:INIT_2=256'h01e1bac5bebd58b92ef582d39a5e8f90a9e107c14b52d26215150df1a136c986 +select -assert-count 1 r:INIT_3=256'h38d8a5b31342f1ac2e7a0b1b94869fecf0edb4355626d22227a85095a3fb93cd +select -assert-count 1 r:INIT_4=256'hb21ba31e3cf9d8350aaea60bbf056e84ee536f6f5393ebaa705613b8eb20716b +select -assert-count 1 r:INIT_5=256'h01ff616027f57e62ec2da16f407505c7bd07b43aff7b5ce9a19a357b9c4ebcde +select -assert-count 1 r:INIT_6=256'hcb06e9bda042be47a7d5b8daf8fb58eead8bba47b6c51a70ea0bef0bff2f78da +select -assert-count 1 r:INIT_7=256'h42e0d2954262a8a31b4a5d194dc10344ae32d84805859fa12744054d01d0ee9c +select -assert-count 1 r:INIT_8=256'h042ac94be56daf1dfd5441986808138dc009e95ce51dd67bf88c3210d947f2f2 +select -assert-count 1 r:INIT_9=256'h4d77f080be61c7f277ef3509fe55eb6c4188d2679e86e1eb5204a0089069eae0 +select -assert-count 1 r:INIT_A=256'hbb0113aea7542aa0363a20bdf97db1ac08f98d82136f733f1de9ceeca0cebb3b +select -assert-count 1 r:INIT_B=256'h3022343256f932aa2339477be2e805102e711f707d44498b2810b0f028347189 +select -assert-count 1 r:INIT_C=256'h5260de0fa26ea82d12bcb3fd32187e83d72f7090a2e642b7c11abfb7e98ef2d2 +select -assert-count 1 r:INIT_D=256'h6d9971bb55ab57b9fab66cd0943db588ca542a2270981fc27a20b796e5462271 +select -assert-count 1 r:INIT_E=256'hf0326faee3e48c266887b9e542a03677091fae593cf8453fc2967d4b88fd171e +select -assert-count 1 r:INIT_F=256'h15d099dec9ada9e038ba12efe74ad07365b3694c50c34f18440699e02addfe91 + +design -reset +read_verilog bram_init.v +synth_ice40 -top ram4 +cd ram4 +select -assert-count 1 t:SB_RAM40_4K +select -assert-count 1 r:INIT_0=256'h1d5eb9737962af83fe39fc172dd49895c924a593f46a5faffc703ead422916d3 +select -assert-count 1 r:INIT_1=256'h7dce1aca4908a3d2fb83d464bddff628e35151c46bec064fee2da86b15f4712a +select -assert-count 1 r:INIT_2=256'h01e1bac5bebd58b92ef582d39a5e8f90a9e107c14b52d26215150df1a136c986 +select -assert-count 1 r:INIT_3=256'h38d8a5b31342f1ac2e7a0b1b94869fecf0edb4355626d22227a85095a3fb93cd +select -assert-count 1 r:INIT_4=256'hb21ba31e3cf9d8350aaea60bbf056e84ee536f6f5393ebaa705613b8eb20716b +select -assert-count 1 r:INIT_5=256'h01ff616027f57e62ec2da16f407505c7bd07b43aff7b5ce9a19a357b9c4ebcde +select -assert-count 1 r:INIT_6=256'hcb06e9bda042be47a7d5b8daf8fb58eead8bba47b6c51a70ea0bef0bff2f78da +select -assert-count 1 r:INIT_7=256'h42e0d2954262a8a31b4a5d194dc10344ae32d84805859fa12744054d01d0ee9c +select -assert-count 1 r:INIT_8=256'h042ac94be56daf1dfd5441986808138dc009e95ce51dd67bf88c3210d947f2f2 +select -assert-count 1 r:INIT_9=256'h4d77f080be61c7f277ef3509fe55eb6c4188d2679e86e1eb5204a0089069eae0 +select -assert-count 1 r:INIT_A=256'hbb0113aea7542aa0363a20bdf97db1ac08f98d82136f733f1de9ceeca0cebb3b +select -assert-count 1 r:INIT_B=256'h3022343256f932aa2339477be2e805102e711f707d44498b2810b0f028347189 +select -assert-count 1 r:INIT_C=256'h5260de0fa26ea82d12bcb3fd32187e83d72f7090a2e642b7c11abfb7e98ef2d2 +select -assert-count 1 r:INIT_D=256'h6d9971bb55ab57b9fab66cd0943db588ca542a2270981fc27a20b796e5462271 +select -assert-count 1 r:INIT_E=256'hf0326faee3e48c266887b9e542a03677091fae593cf8453fc2967d4b88fd171e +select -assert-count 1 r:INIT_F=256'h15d099dec9ada9e038ba12efe74ad07365b3694c50c34f18440699e02addfe91 + +design -reset +read_verilog bram_init.v +synth_ice40 -top ram2 +cd ram2 +select -assert-count 1 t:SB_RAM40_4K +select -assert-count 1 r:INIT_0=256'h1d5eb9737962af83fe39fc172dd49895c924a593f46a5faffc703ead422916d3 +select -assert-count 1 r:INIT_1=256'h7dce1aca4908a3d2fb83d464bddff628e35151c46bec064fee2da86b15f4712a +select -assert-count 1 r:INIT_2=256'h01e1bac5bebd58b92ef582d39a5e8f90a9e107c14b52d26215150df1a136c986 +select -assert-count 1 r:INIT_3=256'h38d8a5b31342f1ac2e7a0b1b94869fecf0edb4355626d22227a85095a3fb93cd +select -assert-count 1 r:INIT_4=256'hb21ba31e3cf9d8350aaea60bbf056e84ee536f6f5393ebaa705613b8eb20716b +select -assert-count 1 r:INIT_5=256'h01ff616027f57e62ec2da16f407505c7bd07b43aff7b5ce9a19a357b9c4ebcde +select -assert-count 1 r:INIT_6=256'hcb06e9bda042be47a7d5b8daf8fb58eead8bba47b6c51a70ea0bef0bff2f78da +select -assert-count 1 r:INIT_7=256'h42e0d2954262a8a31b4a5d194dc10344ae32d84805859fa12744054d01d0ee9c +select -assert-count 1 r:INIT_8=256'h042ac94be56daf1dfd5441986808138dc009e95ce51dd67bf88c3210d947f2f2 +select -assert-count 1 r:INIT_9=256'h4d77f080be61c7f277ef3509fe55eb6c4188d2679e86e1eb5204a0089069eae0 +select -assert-count 1 r:INIT_A=256'hbb0113aea7542aa0363a20bdf97db1ac08f98d82136f733f1de9ceeca0cebb3b +select -assert-count 1 r:INIT_B=256'h3022343256f932aa2339477be2e805102e711f707d44498b2810b0f028347189 +select -assert-count 1 r:INIT_C=256'h5260de0fa26ea82d12bcb3fd32187e83d72f7090a2e642b7c11abfb7e98ef2d2 +select -assert-count 1 r:INIT_D=256'h6d9971bb55ab57b9fab66cd0943db588ca542a2270981fc27a20b796e5462271 +select -assert-count 1 r:INIT_E=256'hf0326faee3e48c266887b9e542a03677091fae593cf8453fc2967d4b88fd171e +select -assert-count 1 r:INIT_F=256'h15d099dec9ada9e038ba12efe74ad07365b3694c50c34f18440699e02addfe91 diff --git a/chips/yosys/tests/arch/ice40/bram_init_16.hex b/chips/yosys/tests/arch/ice40/bram_init_16.hex new file mode 100644 index 0000000000000000000000000000000000000000..ded64cb4bd9d7ae735b5639d8a711f6cb157d4e3 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init_16.hex @@ -0,0 +1,256 @@ +436d +1681 +7e39 +acec +77bb +9de8 +c927 +a492 +e01d +6876 +a9bd +bead +eb23 +2dca +ad4f +317e +1d8a +447e +bd41 +beb1 +1371 +7ed2 +40da +8ac7 +9ea8 +f97f +84f8 +eb8b +cb46 +3082 +7348 +79fa +e192 +8d16 +6467 +003f +87c8 +23c6 +4263 +ec43 +e226 +b35c +c345 +6e75 +748d +fe3d +ea59 +4443 +d25b +df47 +409d +5e22 +8788 +07b8 +8c3d +dcd9 +f67a +c138 +3307 +3f64 +dc9a +034a +cd27 +784c +1dcb +ae82 +560e +09dc +ff82 +438f +3ff3 +abe5 +6ab0 +aa3b +9b21 +7710 +a49d +7c6d +9b16 +9b0d +f97c +b178 +1d6f +d906 +74e9 +bfef +9d2c +a93b +4173 +04d5 +9d53 +bcb1 +2fe8 +4e77 +0cc2 +5557 +79cc +bfbb +bba3 +bb81 +264c +ca79 +ab59 +f923 +75d8 +fdcd +f94c +ca77 +ab79 +8940 +fc97 +a392 +fab4 +4046 +1073 +0a72 +e62b +4033 +b0c8 +af24 +0252 +60e3 +30af +334a +ed01 +07c0 +c29d +46c0 +cfcc +a1db +0a0c +f898 +97ed +98b7 +b8d6 +9081 +521b +3880 +5086 +a8fe +ba37 +9cf3 +b1c3 +1520 +eec0 +9449 +9800 +0298 +ddc3 +e338 +87d9 +5082 +bed2 +aafd +182b +5ffb +c7e6 +ae69 +c888 +25f7 +bf0f +d950 +f6f0 +746b +1f9f +175b +e122 +7445 +dc1a +bcdf +5c15 +1f2c +6e00 +8a76 +571a +aa0b +588b +2c14 +cc4c +2804 +7183 +28fa +266e +2e65 +0026 +dec0 +17e7 +1e07 +5f08 +56ed +0d2c +0d08 +cbcc +f992 +ef3f +9186 +4795 +cf50 +488c +97bb +6ba9 +1a0c +de5f +561c +bc11 +9f50 +b3b9 +06c8 +0e45 +89f2 +cb3e +2e88 +636a +588c +2f00 +a2d4 +d82a +943d +68e4 +ef9c +56af +55ab +5d8f +78a7 +133e +f455 +39eb +c394 +15b7 +7c6c +ba65 +3117 +0f7d +4680 +ec5b +6991 +a530 +ced2 +7fb2 +8d8c +eaad +7a55 +e44a +01b0 +32a6 +41c9 +38d2 +4da7 +85cd +9be2 +5759 +7d0c +ec42 +f493 +f15e +406e diff --git a/chips/yosys/tests/arch/ice40/bram_init_2.hex b/chips/yosys/tests/arch/ice40/bram_init_2.hex new file mode 100644 index 0000000000000000000000000000000000000000..372cc47fe8560730de7fb1491d687f21ac77f4f5 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init_2.hex @@ -0,0 +1,2048 @@ +1 +3 +2 +1 +3 +0 +0 +1 +1 +0 +0 +2 +2 +1 +1 +0 +1 +2 +3 +0 +2 +3 +3 +1 +0 +3 +2 +3 +0 +3 +2 +2 +3 +2 +3 +2 +3 +1 +3 +1 +0 +2 +2 +3 +1 +3 +1 +2 +3 +1 +2 +0 +1 +2 +0 +3 +2 +0 +1 +2 +0 +1 +2 +2 +1 +3 +1 +0 +0 +0 +2 +3 +2 +1 +3 +1 +0 +2 +2 +1 +1 +3 +3 +2 +1 +2 +2 +2 +1 +3 +2 +2 +2 +3 +3 +2 +3 +0 +2 +0 +3 +2 +2 +3 +2 +2 +0 +3 +1 +3 +2 +0 +3 +3 +0 +1 +1 +3 +2 +2 +2 +3 +3 +1 +1 +0 +3 +0 +2 +2 +0 +2 +1 +3 +1 +0 +2 +3 +3 +1 +0 +1 +0 +1 +1 +0 +0 +1 +1 +3 +3 +2 +1 +0 +3 +2 +2 +3 +3 +2 +1 +0 +3 +1 +3 +0 +1 +0 +2 +0 +1 +3 +2 +3 +3 +1 +2 +2 +1 +3 +0 +0 +0 +1 +3 +1 +0 +3 +2 +2 +0 +2 +0 +2 +2 +2 +2 +3 +1 +2 +3 +3 +3 +1 +1 +2 +3 +3 +0 +2 +3 +3 +0 +1 +0 +2 +3 +2 +0 +2 +3 +2 +2 +3 +2 +1 +0 +1 +3 +2 +0 +3 +2 +0 +0 +2 +0 +0 +3 +0 +0 +2 +0 +1 +3 +0 +3 +1 +2 +2 +3 +3 +1 +2 +3 +1 +2 +0 +1 +2 +1 +0 +2 +3 +2 +1 +1 +0 +1 +3 +0 +2 +3 +1 +2 +1 +0 +1 +2 +1 +3 +3 +3 +0 +0 +0 +0 +0 +0 +2 +0 +3 +3 +1 +0 +2 +2 +1 +0 +3 +3 +0 +2 +0 +3 +0 +2 +1 +2 +0 +0 +1 +3 +0 +0 +1 +0 +3 +2 +3 +2 +1 +2 +0 +2 +0 +2 +3 +0 +3 +1 +1 +3 +0 +3 +2 +1 +1 +0 +1 +3 +0 +0 +3 +1 +1 +3 +1 +2 +3 +2 +1 +1 +3 +0 +2 +0 +1 +3 +1 +1 +3 +3 +0 +2 +3 +3 +3 +1 +2 +1 +1 +2 +2 +2 +3 +3 +0 +0 +1 +0 +1 +0 +1 +3 +2 +1 +1 +2 +0 +1 +3 +3 +1 +0 +1 +3 +3 +1 +3 +1 +3 +1 +2 +0 +0 +0 +1 +2 +0 +2 +0 +2 +3 +1 +1 +0 +2 +0 +2 +3 +1 +0 +2 +0 +2 +3 +2 +3 +1 +0 +0 +1 +3 +3 +0 +0 +3 +0 +2 +1 +2 +1 +3 +0 +3 +1 +3 +2 +2 +3 +1 +2 +1 +3 +3 +0 +2 +3 +0 +1 +0 +0 +3 +3 +1 +0 +0 +3 +0 +3 +0 +0 +1 +2 +1 +3 +3 +3 +0 +2 +2 +1 +2 +0 +3 +1 +3 +2 +2 +0 +1 +3 +0 +0 +0 +3 +1 +2 +0 +1 +3 +0 +3 +0 +3 +0 +1 +0 +2 +3 +1 +3 +2 +0 +3 +1 +3 +1 +0 +2 +0 +0 +2 +2 +3 +2 +2 +2 +3 +0 +0 +2 +1 +1 +1 +0 +3 +1 +3 +1 +2 +0 +0 +2 +0 +0 +2 +3 +3 +3 +3 +3 +3 +0 +2 +3 +0 +0 +1 +3 +0 +3 +3 +3 +3 +3 +0 +1 +1 +2 +3 +3 +2 +2 +2 +0 +0 +3 +2 +2 +2 +2 +1 +3 +2 +3 +0 +2 +2 +2 +2 +1 +0 +2 +0 +3 +2 +1 +2 +0 +0 +1 +0 +3 +1 +3 +1 +1 +3 +1 +2 +0 +1 +2 +2 +1 +3 +2 +1 +0 +3 +3 +1 +2 +1 +1 +0 +3 +2 +1 +2 +1 +3 +0 +0 +3 +2 +1 +2 +0 +3 +3 +1 +1 +2 +3 +3 +0 +2 +3 +1 +1 +0 +3 +2 +3 +3 +2 +1 +1 +3 +1 +0 +2 +1 +0 +0 +1 +2 +1 +3 +1 +2 +2 +3 +0 +1 +3 +1 +3 +3 +2 +3 +3 +3 +3 +2 +0 +3 +2 +0 +1 +3 +1 +2 +3 +2 +3 +0 +1 +2 +2 +2 +3 +0 +3 +1 +1 +0 +0 +1 +1 +1 +1 +3 +0 +1 +0 +0 +3 +0 +1 +1 +1 +3 +1 +2 +1 +0 +3 +2 +0 +3 +3 +2 +0 +2 +2 +3 +3 +3 +2 +0 +3 +1 +3 +1 +2 +3 +0 +1 +2 +0 +0 +3 +0 +3 +0 +0 +3 +1 +1 +1 +1 +1 +1 +1 +0 +3 +0 +3 +1 +2 +3 +1 +3 +2 +3 +2 +3 +3 +3 +2 +3 +0 +2 +2 +3 +2 +3 +2 +1 +0 +0 +2 +3 +2 +3 +2 +0 +3 +0 +1 +2 +1 +2 +0 +1 +2 +3 +1 +2 +2 +0 +3 +1 +2 +1 +1 +3 +2 +2 +2 +3 +0 +2 +0 +1 +2 +3 +3 +0 +2 +1 +3 +1 +1 +3 +1 +1 +3 +0 +3 +1 +3 +3 +3 +0 +3 +0 +1 +1 +2 +3 +3 +3 +1 +3 +1 +2 +2 +0 +3 +1 +2 +3 +1 +3 +2 +2 +2 +0 +0 +0 +1 +1 +2 +0 +2 +3 +1 +1 +2 +0 +3 +3 +3 +2 +0 +1 +2 +3 +0 +2 +2 +0 +1 +3 +2 +2 +2 +3 +3 +2 +1 +0 +1 +0 +0 +0 +1 +3 +0 +3 +1 +0 +0 +1 +0 +2 +0 +3 +1 +2 +2 +0 +0 +3 +2 +2 +0 +2 +1 +2 +3 +3 +0 +3 +0 +0 +0 +0 +1 +0 +2 +0 +3 +0 +0 +3 +2 +0 +1 +2 +0 +3 +3 +2 +2 +2 +0 +1 +1 +2 +0 +0 +0 +3 +0 +2 +3 +0 +0 +2 +1 +3 +3 +2 +2 +0 +0 +3 +0 +2 +2 +0 +1 +3 +0 +3 +0 +1 +0 +0 +0 +1 +3 +2 +3 +0 +0 +0 +3 +3 +1 +0 +0 +1 +3 +1 +2 +2 +0 +0 +3 +0 +0 +0 +3 +2 +1 +0 +1 +0 +3 +0 +3 +3 +3 +0 +3 +3 +2 +1 +3 +1 +0 +2 +2 +0 +3 +0 +0 +2 +2 +0 +0 +0 +2 +1 +2 +0 +2 +3 +3 +1 +3 +2 +3 +3 +1 +1 +2 +3 +1 +3 +2 +0 +2 +1 +2 +2 +1 +1 +3 +0 +2 +3 +2 +1 +0 +0 +2 +0 +0 +1 +2 +3 +2 +1 +0 +2 +0 +1 +1 +0 +0 +0 +2 +0 +2 +3 +0 +2 +1 +0 +2 +0 +0 +1 +1 +2 +3 +3 +3 +0 +2 +2 +2 +3 +1 +3 +0 +2 +2 +3 +2 +3 +0 +3 +3 +0 +3 +1 +2 +3 +0 +0 +3 +1 +0 +3 +2 +0 +0 +2 +0 +1 +1 +1 +0 +0 +0 +0 +3 +2 +3 +2 +3 +1 +2 +0 +1 +0 +1 +1 +2 +0 +0 +0 +0 +0 +2 +1 +2 +0 +2 +1 +2 +2 +0 +0 +0 +3 +0 +0 +3 +1 +3 +1 +3 +0 +2 +3 +0 +3 +0 +2 +3 +1 +2 +1 +3 +3 +1 +0 +2 +2 +0 +0 +2 +0 +0 +1 +1 +2 +0 +1 +3 +2 +3 +3 +2 +1 +3 +3 +3 +2 +2 +2 +2 +3 +2 +2 +0 +0 +2 +1 +0 +3 +2 +3 +3 +3 +3 +1 +1 +2 +1 +2 +3 +3 +1 +0 +3 +1 +2 +2 +1 +2 +3 +2 +2 +0 +2 +0 +2 +0 +2 +0 +3 +3 +1 +3 +3 +1 +1 +2 +0 +3 +3 +0 +0 +3 +3 +3 +2 +0 +0 +1 +1 +1 +2 +1 +3 +0 +0 +3 +3 +2 +1 +3 +3 +3 +2 +2 +1 +0 +1 +3 +1 +3 +3 +1 +2 +3 +3 +1 +0 +3 +2 +1 +1 +3 +1 +1 +0 +2 +0 +2 +0 +1 +0 +2 +3 +1 +1 +0 +1 +0 +1 +3 +1 +2 +2 +1 +0 +0 +3 +1 +3 +3 +3 +1 +3 +0 +3 +3 +2 +1 +1 +1 +0 +0 +3 +1 +1 +0 +3 +2 +0 +3 +3 +1 +0 +0 +0 +0 +0 +2 +3 +2 +1 +2 +1 +3 +1 +2 +2 +0 +2 +2 +2 +1 +0 +3 +1 +1 +1 +3 +2 +0 +0 +2 +2 +2 +2 +3 +2 +0 +2 +0 +2 +1 +1 +0 +1 +1 +0 +0 +3 +2 +0 +0 +3 +0 +1 +0 +3 +0 +3 +0 +1 +0 +0 +0 +2 +2 +0 +3 +0 +0 +2 +1 +0 +3 +1 +2 +2 +3 +3 +0 +2 +2 +0 +2 +3 +2 +1 +2 +1 +2 +0 +1 +1 +2 +1 +2 +3 +2 +0 +2 +1 +2 +0 +0 +0 +0 +0 +0 +0 +0 +3 +2 +3 +1 +3 +3 +1 +2 +3 +3 +1 +1 +0 +3 +1 +0 +0 +2 +3 +1 +0 +0 +2 +0 +0 +3 +3 +1 +1 +1 +3 +2 +3 +2 +1 +1 +1 +0 +3 +2 +0 +1 +3 +0 +0 +0 +2 +0 +0 +1 +3 +0 +0 +0 +3 +0 +3 +3 +2 +0 +3 +2 +0 +1 +2 +1 +2 +3 +3 +3 +3 +3 +0 +3 +3 +2 +3 +2 +1 +0 +2 +1 +0 +1 +2 +1 +1 +1 +2 +3 +1 +0 +1 +0 +0 +1 +1 +3 +3 +0 +3 +0 +3 +0 +2 +0 +2 +0 +1 +3 +2 +3 +2 +3 +1 +1 +2 +1 +2 +2 +2 +3 +2 +2 +1 +0 +3 +0 +0 +2 +2 +1 +0 +3 +3 +1 +1 +2 +3 +1 +3 +0 +3 +1 +0 +2 +1 +1 +1 +1 +0 +1 +0 +0 +3 +3 +2 +0 +0 +1 +1 +3 +3 +1 +2 +1 +2 +3 +2 +3 +0 +3 +2 +0 +2 +0 +3 +2 +1 +0 +0 +1 +1 +0 +1 +2 +3 +0 +0 +2 +0 +3 +3 +1 +2 +0 +2 +2 +3 +3 +0 +3 +2 +0 +3 +0 +2 +0 +2 +2 +3 +2 +0 +2 +2 +2 +1 +3 +0 +2 +1 +0 +3 +0 +2 +0 +2 +1 +1 +0 +0 +0 +0 +3 +3 +2 +0 +0 +1 +1 +3 +2 +0 +2 +2 +2 +2 +2 +0 +0 +2 +1 +3 +1 +3 +3 +0 +0 +1 +1 +2 +0 +1 +2 +3 +0 +2 +2 +1 +0 +3 +1 +2 +3 +3 +2 +3 +3 +3 +2 +2 +2 +1 +1 +1 +3 +2 +2 +2 +1 +1 +1 +1 +3 +3 +0 +2 +1 +3 +1 +1 +3 +1 +2 +2 +0 +2 +3 +1 +2 +3 +3 +0 +3 +0 +1 +0 +1 +1 +1 +1 +0 +1 +3 +3 +3 +2 +2 +3 +1 +2 +3 +0 +0 +1 +1 +2 +3 +0 +0 +3 +3 +1 +3 +2 +1 +1 +1 +0 +0 +3 +2 +1 +0 +3 +3 +1 +1 +1 +2 +1 +2 +2 +3 +2 +3 +1 +1 +0 +1 +0 +3 +0 +1 +3 +3 +1 +3 +3 +0 +0 +0 +0 +0 +2 +2 +1 +0 +1 +3 +2 +1 +1 +0 +3 +2 +3 +1 +0 +1 +2 +1 +2 +2 +1 +0 +0 +3 +0 +1 +1 +2 +2 +2 +0 +1 +3 +2 +3 +0 +3 +2 +0 +3 +2 +3 +3 +3 +1 +0 +3 +0 +2 +1 +3 +0 +2 +1 +3 +2 +2 +2 +2 +2 +3 +1 +1 +1 +1 +2 +2 +3 +1 +2 +2 +0 +1 +0 +1 +2 +3 +0 +0 +3 +2 +1 +0 +0 +0 +2 +1 +2 +2 +2 +0 +3 +0 +1 +2 +0 +3 +1 +0 +0 +1 +2 +0 +1 +3 +0 +2 +3 +0 +3 +1 +2 +2 +1 +3 +0 +1 +1 +3 +0 +3 +1 +1 +0 +2 +2 +0 +2 +3 +3 +2 +1 +2 +1 +2 +1 +1 +3 +1 +1 +1 +0 +3 +0 +0 +1 +3 +3 +1 +2 +0 +0 +1 +0 +3 +2 +3 +3 +0 +1 +2 +0 +1 +3 +3 +2 +3 +1 +1 +1 +0 +3 +3 +2 +3 +2 +1 +0 +0 +0 +1 diff --git a/chips/yosys/tests/arch/ice40/bram_init_4.hex b/chips/yosys/tests/arch/ice40/bram_init_4.hex new file mode 100644 index 0000000000000000000000000000000000000000..226d427bb5a7349906328d8e0a6b2df96814d8a2 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init_4.hex @@ -0,0 +1,1024 @@ +d +6 +3 +4 +1 +8 +6 +1 +9 +3 +e +7 +c +e +c +a +b +b +7 +7 +8 +e +d +9 +7 +2 +9 +c +2 +9 +4 +a +d +1 +0 +e +6 +7 +8 +6 +d +b +9 +a +d +a +e +b +3 +2 +b +e +a +c +d +2 +f +4 +d +a +e +7 +1 +3 +a +8 +d +1 +e +7 +4 +4 +1 +4 +d +b +1 +b +e +b +1 +7 +3 +1 +2 +d +e +7 +a +d +0 +4 +7 +c +a +8 +8 +a +e +9 +f +7 +9 +f +8 +f +4 +8 +b +8 +b +e +6 +4 +b +c +2 +8 +0 +3 +8 +4 +3 +7 +a +f +9 +7 +2 +9 +1 +e +6 +1 +d +8 +7 +6 +4 +6 +f +3 +0 +0 +8 +c +7 +8 +6 +c +3 +2 +3 +6 +2 +4 +3 +4 +c +e +6 +2 +2 +e +c +5 +3 +b +5 +4 +3 +c +5 +7 +e +6 +d +8 +4 +7 +d +3 +e +f +9 +5 +a +e +3 +4 +4 +4 +b +5 +2 +d +7 +4 +f +d +d +9 +0 +4 +2 +2 +e +5 +8 +8 +7 +8 +8 +b +7 +0 +d +3 +c +8 +9 +d +c +d +a +7 +6 +f +8 +3 +1 +c +7 +0 +3 +3 +4 +6 +f +3 +a +9 +c +d +a +4 +3 +0 +7 +2 +d +c +c +4 +8 +7 +b +c +d +1 +2 +8 +e +a +e +0 +6 +5 +c +d +9 +0 +2 +8 +f +f +f +8 +3 +4 +3 +f +f +3 +5 +e +b +a +0 +b +a +6 +b +3 +a +a +1 +2 +b +9 +0 +1 +7 +7 +d +9 +4 +a +d +6 +c +7 +6 +1 +b +9 +d +0 +b +9 +c +7 +9 +f +8 +7 +1 +b +f +6 +d +1 +6 +0 +9 +d +9 +e +4 +7 +f +e +f +b +c +2 +d +9 +b +3 +9 +a +3 +7 +1 +4 +5 +d +4 +0 +3 +5 +d +9 +1 +b +c +b +8 +e +f +2 +7 +7 +e +4 +2 +c +c +0 +7 +5 +5 +5 +c +c +9 +7 +b +b +f +b +3 +a +b +b +1 +8 +b +b +c +4 +6 +2 +9 +7 +a +c +9 +5 +b +a +3 +2 +9 +f +8 +d +5 +7 +d +c +d +f +c +4 +9 +f +7 +7 +a +c +9 +7 +b +a +0 +4 +9 +8 +7 +9 +c +f +2 +9 +3 +a +4 +b +a +f +6 +4 +0 +4 +3 +7 +0 +1 +2 +7 +a +0 +b +2 +6 +e +3 +3 +0 +4 +8 +c +0 +b +4 +2 +f +a +2 +5 +2 +0 +3 +e +0 +6 +f +a +0 +3 +a +4 +3 +3 +1 +0 +d +e +0 +c +7 +0 +d +9 +2 +c +0 +c +6 +4 +c +c +f +c +b +d +1 +a +c +0 +a +0 +8 +9 +8 +f +d +e +7 +9 +7 +b +8 +9 +6 +d +8 +b +1 +8 +0 +9 +b +1 +2 +5 +0 +8 +8 +3 +6 +8 +0 +5 +e +f +8 +a +7 +3 +a +b +3 +f +c +9 +3 +c +1 +b +0 +2 +5 +1 +0 +c +e +e +9 +4 +4 +9 +0 +0 +8 +9 +8 +9 +2 +0 +3 +c +d +d +8 +3 +3 +e +9 +d +7 +8 +2 +8 +0 +5 +2 +d +e +b +d +f +a +a +b +2 +8 +1 +b +f +f +5 +6 +e +7 +c +9 +6 +e +a +8 +8 +8 +c +7 +f +5 +2 +f +0 +f +b +0 +5 +9 +d +0 +f +6 +f +b +6 +4 +7 +f +9 +f +1 +b +5 +7 +1 +2 +2 +1 +e +5 +4 +4 +7 +a +1 +c +d +f +d +c +b +5 +1 +c +5 +c +2 +f +1 +0 +0 +e +6 +6 +7 +a +8 +a +1 +7 +5 +b +0 +a +a +b +8 +8 +5 +4 +1 +c +2 +c +4 +c +c +4 +0 +8 +2 +3 +8 +1 +7 +a +f +8 +2 +e +6 +6 +2 +5 +6 +e +2 +6 +2 +0 +0 +0 +c +e +d +7 +e +7 +1 +7 +0 +e +1 +8 +0 +f +5 +d +e +6 +5 +c +2 +d +0 +8 +0 +d +0 +c +c +b +c +2 +9 +9 +f +f +3 +f +e +6 +8 +1 +9 +5 +9 +7 +4 +0 +5 +f +c +c +8 +8 +4 +b +b +7 +9 +9 +a +b +6 +c +0 +a +1 +f +5 +e +d +c +1 +6 +5 +1 +1 +c +b +0 +5 +f +9 +9 +b +3 +b +8 +c +6 +0 +5 +4 +e +0 +2 +f +9 +8 +e +3 +b +c +8 +8 +e +2 +a +6 +3 +6 +c +8 +8 +5 +0 +0 +f +2 +4 +d +2 +a +a +2 +8 +d +d +3 +4 +9 +4 +e +8 +6 +c +9 +f +e +f +a +6 +5 +b +a +5 +5 +f +8 +d +5 +7 +a +8 +7 +e +3 +3 +1 +5 +5 +4 +f +b +e +9 +3 +4 +9 +3 +c +7 +b +5 +1 +c +6 +c +7 +5 +6 +a +b +7 +1 +1 +3 +d +7 +f +0 +0 +8 +6 +4 +b +5 +c +e +1 +9 +9 +6 +0 +3 +5 +a +2 +d +e +c +2 +b +f +7 +c +8 +d +8 +d +a +a +e +5 +5 +a +7 +a +4 +4 +e +0 +b +1 +0 +6 +a +2 +3 +9 +c +1 +4 +2 +d +8 +3 +7 +a +d +4 +d +c +5 +8 +2 +e +b +9 +9 +5 +7 +5 +c +0 +d +7 +2 +4 +c +e +3 +9 +4 +f +e +5 +1 +f +e +6 +0 +4 diff --git a/chips/yosys/tests/arch/ice40/bram_init_8.hex b/chips/yosys/tests/arch/ice40/bram_init_8.hex new file mode 100644 index 0000000000000000000000000000000000000000..b4a2973bcbcbb03c5e07b9474a0f5bf97cf6ab30 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bram_init_8.hex @@ -0,0 +1,512 @@ +6d +43 +81 +16 +39 +7e +ec +ac +bb +77 +e8 +9d +27 +c9 +92 +a4 +1d +e0 +76 +68 +bd +a9 +ad +be +23 +eb +ca +2d +4f +ad +7e +31 +8a +1d +7e +44 +41 +bd +b1 +be +71 +13 +d2 +7e +da +40 +c7 +8a +a8 +9e +7f +f9 +f8 +84 +8b +eb +46 +cb +82 +30 +48 +73 +fa +79 +92 +e1 +16 +8d +67 +64 +3f +00 +c8 +87 +c6 +23 +63 +42 +43 +ec +26 +e2 +5c +b3 +45 +c3 +75 +6e +8d +74 +3d +fe +59 +ea +43 +44 +5b +d2 +47 +df +9d +40 +22 +5e +88 +87 +b8 +07 +3d +8c +d9 +dc +7a +f6 +38 +c1 +07 +33 +64 +3f +9a +dc +4a +03 +27 +cd +4c +78 +cb +1d +82 +ae +0e +56 +dc +09 +82 +ff +8f +43 +f3 +3f +e5 +ab +b0 +6a +3b +aa +21 +9b +10 +77 +9d +a4 +6d +7c +16 +9b +0d +9b +7c +f9 +78 +b1 +6f +1d +06 +d9 +e9 +74 +ef +bf +2c +9d +3b +a9 +73 +41 +d5 +04 +53 +9d +b1 +bc +e8 +2f +77 +4e +c2 +0c +57 +55 +cc +79 +bb +bf +a3 +bb +81 +bb +4c +26 +79 +ca +59 +ab +23 +f9 +d8 +75 +cd +fd +4c +f9 +77 +ca +79 +ab +40 +89 +97 +fc +92 +a3 +b4 +fa +46 +40 +73 +10 +72 +0a +2b +e6 +33 +40 +c8 +b0 +24 +af +52 +02 +e3 +60 +af +30 +4a +33 +01 +ed +c0 +07 +9d +c2 +c0 +46 +cc +cf +db +a1 +0c +0a +98 +f8 +ed +97 +b7 +98 +d6 +b8 +81 +90 +1b +52 +80 +38 +86 +50 +fe +a8 +37 +ba +f3 +9c +c3 +b1 +20 +15 +c0 +ee +49 +94 +00 +98 +98 +02 +c3 +dd +38 +e3 +d9 +87 +82 +50 +d2 +be +fd +aa +2b +18 +fb +5f +e6 +c7 +69 +ae +88 +c8 +f7 +25 +0f +bf +50 +d9 +f0 +f6 +6b +74 +9f +1f +5b +17 +22 +e1 +45 +74 +1a +dc +df +bc +15 +5c +2c +1f +00 +6e +76 +8a +1a +57 +0b +aa +8b +58 +14 +2c +4c +cc +04 +28 +83 +71 +fa +28 +6e +26 +65 +2e +26 +00 +c0 +de +e7 +17 +07 +1e +08 +5f +ed +56 +2c +0d +08 +0d +cc +cb +92 +f9 +3f +ef +86 +91 +95 +47 +50 +cf +8c +48 +bb +97 +a9 +6b +0c +1a +5f +de +1c +56 +11 +bc +50 +9f +b9 +b3 +c8 +06 +45 +0e +f2 +89 +3e +cb +88 +2e +6a +63 +8c +58 +00 +2f +d4 +a2 +2a +d8 +3d +94 +e4 +68 +9c +ef +af +56 +ab +55 +8f +5d +a7 +78 +3e +13 +55 +f4 +eb +39 +94 +c3 +b7 +15 +6c +7c +65 +ba +17 +31 +7d +0f +80 +46 +5b +ec +91 +69 +30 +a5 +d2 +ce +b2 +7f +8c +8d +ad +ea +55 +7a +4a +e4 +b0 +01 +a6 +32 +c9 +41 +d2 +38 +a7 +4d +cd +85 +e2 +9b +59 +57 +0c +7d +42 +ec +93 +f4 +5e +f1 +6e +40 diff --git a/chips/yosys/tests/arch/ice40/bug1597.ys b/chips/yosys/tests/arch/ice40/bug1597.ys new file mode 100644 index 0000000000000000000000000000000000000000..c1509cabcf1149c0f4585424023141663d769a8e --- /dev/null +++ b/chips/yosys/tests/arch/ice40/bug1597.ys @@ -0,0 +1,73 @@ +read_verilog <:3.11-8.3 %i a:keep=0 %i a:foo=bar %i a:answer=42 %i +select -assert-count 1 c:adder a:src=:12.4-18.3 %i a:keep=1 %i a:blah=blah %i a:answer=43 %i diff --git a/chips/yosys/tests/arch/ice40/latches.ys b/chips/yosys/tests/arch/ice40/latches.ys new file mode 100644 index 0000000000000000000000000000000000000000..91c9df2b45649fa412ca79484224ed12bb91fa34 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/latches.ys @@ -0,0 +1,33 @@ +read_verilog ../common/latches.v +design -save read + +hierarchy -top latchp +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_ice40 -latches info +cd latchp # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D + + +design -load read +hierarchy -top latchn +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_ice40 -latches info +cd latchn # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D + + +design -load read +hierarchy -top latchsr +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_ice40 -latches info +cd latchsr # Constrain all select calls below inside the top module +select -assert-count 2 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/logic.ys b/chips/yosys/tests/arch/ice40/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..7432f5b1f8b987250f365a2d120e0445e4d320c3 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/logic.ys @@ -0,0 +1,7 @@ +read_verilog ../common/logic.v +hierarchy -top top +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 9 t:SB_LUT4 +select -assert-none t:SB_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/macc.v b/chips/yosys/tests/arch/ice40/macc.v new file mode 100644 index 0000000000000000000000000000000000000000..6f68e750078a00037b8ad1c9d9aeb667a3dd5c24 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/macc.v @@ -0,0 +1,47 @@ +/* +Example from: https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/EI/iCEcube201701UserGuide.ashx?document_id=52071 [p. 77]. +*/ +module top(clk,a,b,c,set); +parameter A_WIDTH = 6 /*4*/; +parameter B_WIDTH = 6 /*3*/; +input set; +input clk; +input signed [(A_WIDTH - 1):0] a; +input signed [(B_WIDTH - 1):0] b; +output signed [(A_WIDTH + B_WIDTH - 1):0] c; +reg [(A_WIDTH + B_WIDTH - 1):0] reg_tmp_c; +assign c = reg_tmp_c; +always @(posedge clk) +begin + if(set) + begin + reg_tmp_c <= 0; + end + else + begin + reg_tmp_c <= a * b + c; + end +end +endmodule + +module top2(clk,a,b,c,hold); +parameter A_WIDTH = 6 /*4*/; +parameter B_WIDTH = 6 /*3*/; +input hold; +input clk; +input signed [(A_WIDTH - 1):0] a; +input signed [(B_WIDTH - 1):0] b; +output signed [(A_WIDTH + B_WIDTH - 1):0] c; +reg signed [A_WIDTH-1:0] reg_a; +reg signed [B_WIDTH-1:0] reg_b; +reg [(A_WIDTH + B_WIDTH - 1):0] reg_tmp_c; +assign c = reg_tmp_c; +always @(posedge clk) +begin + if (!hold) begin + reg_a <= a; + reg_b <= b; + reg_tmp_c <= reg_a * reg_b + c; + end +end +endmodule diff --git a/chips/yosys/tests/arch/ice40/macc.ys b/chips/yosys/tests/arch/ice40/macc.ys new file mode 100644 index 0000000000000000000000000000000000000000..fd30e79c57e2ca44c8c523f01c171ad4f252e162 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/macc.ys @@ -0,0 +1,25 @@ +read_verilog macc.v +proc +design -save read + +hierarchy -top top +equiv_opt -assert -multiclock -map +/ice40/cells_sim.v synth_ice40 -dsp # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_MAC16 +select -assert-none t:SB_MAC16 %% t:* %D + +design -load read +hierarchy -top top2 + +#equiv_opt -multiclock -assert -map +/ice40/cells_sim.v synth_ice40 -dsp # equivalency check + +equiv_opt -run :prove -multiclock -assert -map +/ice40/cells_sim.v synth_ice40 -dsp # equivalency check +clk2fflogic +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -set-init-zero -seq 4 -verify -prove-asserts -show-ports miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top2 # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_MAC16 +select -assert-none t:SB_MAC16 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/memories.ys b/chips/yosys/tests/arch/ice40/memories.ys new file mode 100644 index 0000000000000000000000000000000000000000..d480a3abe100b18944ab672c4d8386fa3be05e00 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/memories.ys @@ -0,0 +1,138 @@ +# ================================ RAM ================================ +# RAM bits <= 4K; Data width <= 16; Address width <= 11: -> SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 11 -set DATA_WIDTH 2 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 4 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 8 -set DATA_WIDTH 16 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +## With parameters + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:SB_RAM40_4K # too inefficient +select -assert-min 1 t:SB_DFFE + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "block_ram" m:memory +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "Block_RAM" m:memory +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K # any case works + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set ram_block 1 m:memory +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set syn_ramstyle "registers" m:memory +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:SB_RAM40_4K # requested FFRAM explicitly +select -assert-min 1 t:SB_DFFE + +design -reset; read_verilog -defer ../common/blockram.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_ram_sdp +hierarchy -top sync_ram_sdp +setattr -set logic_block 1 m:memory +synth_ice40 -top sync_ram_sdp; cd sync_ram_sdp +select -assert-count 0 t:SB_RAM40_4K # requested FFRAM explicitly +select -assert-min 1 t:SB_DFFE + +# ================================ ROM ================================ +# ROM bits <= 4K; Data width <= 16; Address width <= 11: -> SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 11 -set DATA_WIDTH 2 sync_rom +hierarchy -top sync_rom +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 4 sync_rom +hierarchy -top sync_rom +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 8 -set DATA_WIDTH 16 sync_rom +hierarchy -top sync_rom +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +## With parameters + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 0 t:SB_RAM40_4K # too inefficient +select -assert-min 1 t:SB_LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "ebr" m:memory +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +setattr -set rom_block 1 m:memory +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 1 t:SB_RAM40_4K + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +setattr -set syn_romstyle "logic" m:memory +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 0 t:SB_RAM40_4K # requested LUTROM explicitly +select -assert-min 1 t:SB_LUT4 + +design -reset; read_verilog -defer ../common/blockrom.v +chparam -set ADDRESS_WIDTH 2 -set DATA_WIDTH 8 sync_rom +hierarchy -top sync_rom +setattr -set logic_block 1 m:memory +synth_ice40 -top sync_rom; cd sync_rom +select -assert-count 0 t:SB_RAM40_4K # requested LUTROM explicitly +select -assert-min 1 t:SB_LUT4 diff --git a/chips/yosys/tests/arch/ice40/mul.ys b/chips/yosys/tests/arch/ice40/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..b8c3eb941390c89302f8e6b032ce22df437bea06 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/mul.ys @@ -0,0 +1,7 @@ +read_verilog ../common/mul.v +hierarchy -top top +equiv_opt -assert -multiclock -map +/ice40/cells_sim.v synth_ice40 -dsp # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_MAC16 +select -assert-none t:SB_MAC16 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/mux.ys b/chips/yosys/tests/arch/ice40/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..977d6975063784351b99bbe739065211b91400c7 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/mux.ys @@ -0,0 +1,41 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:SB_LUT4 +select -assert-none t:SB_LUT4 %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 3 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 6 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # 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-min 13 t:SB_LUT4 +select -assert-max 14 t:SB_LUT4 + +select -assert-none t:SB_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/rom.v b/chips/yosys/tests/arch/ice40/rom.v new file mode 100644 index 0000000000000000000000000000000000000000..71459fe38de759c3bfddb58fd5c298996b440875 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/rom.v @@ -0,0 +1,19 @@ +/* +Example from: https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/EI/iCEcube201701UserGuide.ashx?document_id=52071 [p. 74]. +*/ +module top(data, addr); +output [3:0] data; // Note: this prompts a Yosys warning, but + // vendor doc does not contain 'reg' +input [4:0] addr; +always @(addr) begin +case (addr) +0 : data = 'h4; +1 : data = 'h9; +2 : data = 'h1; +15 : data = 'h8; +16 : data = 'h1; +17 : data = 'h0; +default : data = 'h0; +endcase +end +endmodule diff --git a/chips/yosys/tests/arch/ice40/rom.ys b/chips/yosys/tests/arch/ice40/rom.ys new file mode 100644 index 0000000000000000000000000000000000000000..d795e206b4a4216f2d9baf7d93164fbebc6cdfbe --- /dev/null +++ b/chips/yosys/tests/arch/ice40/rom.ys @@ -0,0 +1,8 @@ +read_verilog rom.v +proc +flatten +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-max 6 t:SB_LUT4 +select -assert-none t:SB_LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/shifter.ys b/chips/yosys/tests/arch/ice40/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..08ea64f3da45897e7620d410ce1be0241d22f252 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/shifter.ys @@ -0,0 +1,9 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/ice40/cells_sim.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 8 t:SB_DFF +select -assert-none t:SB_DFF %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/spram.v b/chips/yosys/tests/arch/ice40/spram.v new file mode 100644 index 0000000000000000000000000000000000000000..fb55aa7d9765ffc3bce3aa233ac3c497bc48dea0 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/spram.v @@ -0,0 +1,22 @@ +module top (clk, write_enable, read_enable, write_data, addr, read_data); +parameter DATA_WIDTH = 8; +parameter ADDR_WIDTH = 8; +parameter SKIP_RDEN = 1; + +input clk; +input write_enable, read_enable; +input [DATA_WIDTH - 1 : 0] write_data; +input [ADDR_WIDTH - 1 : 0] addr; +output [DATA_WIDTH - 1 : 0] read_data; + +(* ram_style = "huge" *) +reg [DATA_WIDTH - 1 : 0] mem [2**ADDR_WIDTH - 1 : 0]; + +always @(posedge clk) begin + if (write_enable) + mem[addr] <= write_data; + else if (SKIP_RDEN || read_enable) + read_data <= mem[addr]; +end + +endmodule diff --git a/chips/yosys/tests/arch/ice40/spram.ys b/chips/yosys/tests/arch/ice40/spram.ys new file mode 100644 index 0000000000000000000000000000000000000000..709c218621eec3c97ded0e355dd406c95810c7a1 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/spram.ys @@ -0,0 +1,15 @@ +read_verilog spram.v +hierarchy -top top +synth_ice40 +select -assert-count 1 t:SB_SPRAM256KA +select -assert-none t:SB_SPRAM256KA %% t:* %D + +# Testing with pattern as described in pattern document +design -reset +read_verilog spram.v +chparam -set SKIP_RDEN 0 +hierarchy -top top +synth_ice40 +select -assert-count 1 t:SB_SPRAM256KA +# Below fails due to extra SB_LUT4 +# select -assert-none t:SB_SPRAM256KA %% t:* %D diff --git a/chips/yosys/tests/arch/ice40/tribuf.ys b/chips/yosys/tests/arch/ice40/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..10cded9547e99a4fa4460e910be8a5c1dcfde527 --- /dev/null +++ b/chips/yosys/tests/arch/ice40/tribuf.ys @@ -0,0 +1,11 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/ice40/cells_sim.v -map +/simcells.v synth_ice40 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/add_sub.ys b/chips/yosys/tests/arch/intel_alm/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..cba33ac24b57c773b6c9d588e021703ed89f44d3 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/add_sub.ys @@ -0,0 +1,8 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +stat +select -assert-count 9 t:MISTRAL_ALUT_ARITH +select -assert-none t:MISTRAL_ALUT_ARITH %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/adffs.ys b/chips/yosys/tests/arch/intel_alm/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..4638358907fce6bc5f0e03affa9b07bba457c8b3 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/adffs.ys @@ -0,0 +1,47 @@ +read_verilog ../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF +select -assert-count 1 t:MISTRAL_NOT + +select -assert-none t:MISTRAL_FF t:MISTRAL_NOT %% t:* %D + + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF + +select -assert-none t:MISTRAL_FF %% t:* %D + + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF +select -assert-count 1 t:MISTRAL_ALUT2 + +select -assert-none t:MISTRAL_FF t:MISTRAL_ALUT2 %% t:* %D + + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF +select -assert-count 2 t:MISTRAL_NOT + +select -assert-none t:MISTRAL_FF t:MISTRAL_NOT %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/blockram.ys b/chips/yosys/tests/arch/intel_alm/blockram.ys new file mode 100644 index 0000000000000000000000000000000000000000..21b5ecbfb60f4c1a5cb5ccc65b444bbdfe935b33 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/blockram.ys @@ -0,0 +1,7 @@ +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 10 sync_ram_sdp +synth_intel_alm -top sync_ram_sdp -family cyclonev -noiopad -noclkbuf +cd sync_ram_sdp +select -assert-count 1 t:MISTRAL_NOT +select -assert-count 1 t:MISTRAL_M10K +select -assert-none t:MISTRAL_NOT t:MISTRAL_M10K %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/counter.ys b/chips/yosys/tests/arch/intel_alm/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..93a1300cdd9fe5694d2d984e297eef8f25d6925b --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/counter.ys @@ -0,0 +1,12 @@ +read_verilog ../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -async2sync -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 2 t:MISTRAL_NOT +select -assert-count 8 t:MISTRAL_ALUT_ARITH +select -assert-count 8 t:MISTRAL_FF +select -assert-none t:MISTRAL_NOT t:MISTRAL_ALUT_ARITH t:MISTRAL_FF %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/dffs.ys b/chips/yosys/tests/arch/intel_alm/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..32ed23860c71f135ea2617532beab1b83f3a8a5d --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/dffs.ys @@ -0,0 +1,20 @@ +read_verilog ../common/dffs.v +design -save read + +hierarchy -top dff +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dff # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF +select -assert-none t:MISTRAL_FF %% t:* %D + + +design -load read +hierarchy -top dffe +proc +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_FF +select -assert-none t:MISTRAL_FF %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/fsm.ys b/chips/yosys/tests/arch/intel_alm/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..defec72c1b60e1090fb06f3b54e3e338114d4bd7 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/fsm.ys @@ -0,0 +1,21 @@ +read_verilog ../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf +async2sync +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-count 6 t:MISTRAL_FF +select -assert-max 1 t:MISTRAL_NOT +select -assert-max 2 t:MISTRAL_ALUT2 # Clang returns 2, GCC returns 1 +select -assert-max 1 t:MISTRAL_ALUT3 +select -assert-max 2 t:MISTRAL_ALUT4 # Clang returns 0, GCC returns 1 +select -assert-max 6 t:MISTRAL_ALUT5 # Clang returns 5, GCC returns 4 +select -assert-max 2 t:MISTRAL_ALUT6 # Clang returns 1, GCC returns 2 +select -assert-none t:MISTRAL_FF t:MISTRAL_NOT t:MISTRAL_ALUT2 t:MISTRAL_ALUT3 t:MISTRAL_ALUT4 t:MISTRAL_ALUT5 t:MISTRAL_ALUT6 %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/generate_mk.py b/chips/yosys/tests/arch/intel_alm/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..06a6040ad48bae5c2ce7163455d96b2401a68986 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/intel_alm/logic.ys b/chips/yosys/tests/arch/intel_alm/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..65941543601da679550b34ec5dc6b758dae12eb5 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/logic.ys @@ -0,0 +1,11 @@ +read_verilog ../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 4 t:MISTRAL_NOT +select -assert-count 3 t:MISTRAL_ALUT2 +select -assert-count 2 t:MISTRAL_ALUT4 +select -assert-none t:MISTRAL_NOT t:MISTRAL_ALUT2 t:MISTRAL_ALUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/lutram.ys b/chips/yosys/tests/arch/intel_alm/lutram.ys new file mode 100644 index 0000000000000000000000000000000000000000..9ddb1ec874ebdcbd24aa7ebea12c010b1292178a --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/lutram.ys @@ -0,0 +1,39 @@ +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +proc +memory -nomap +equiv_opt -run :prove -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v -map +/intel_alm/common/mem_sim.v synth_intel_alm -family cyclonev -nobram -noiopad -noclkbuf +memory +opt -full + +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 3 -set-init-zero -show-inputs -show-outputs miter + +design -load postopt +cd lutram_1w1r +select -assert-count 16 t:MISTRAL_MLAB +select -assert-count 2 t:MISTRAL_ALUT2 +select -assert-count 8 t:MISTRAL_ALUT3 +select -assert-count 8 t:MISTRAL_FF +select -assert-none t:MISTRAL_ALUT2 t:MISTRAL_ALUT3 t:MISTRAL_FF t:MISTRAL_MLAB %% t:* %D + + +design -reset +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +proc +memory -nomap +equiv_opt -run :prove -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v -map +/intel_alm/common/mem_sim.v synth_intel_alm -family cyclonev -nobram -noiopad -noclkbuf +memory +opt -full + +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 3 -set-init-zero -show-inputs -show-outputs miter + +design -load postopt +cd lutram_1w1r +select -assert-count 16 t:MISTRAL_MLAB +select -assert-count 2 t:MISTRAL_ALUT2 +select -assert-count 8 t:MISTRAL_ALUT3 +select -assert-count 8 t:MISTRAL_FF +select -assert-none t:MISTRAL_ALUT2 t:MISTRAL_ALUT3 t:MISTRAL_FF t:MISTRAL_MLAB %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/mul.ys b/chips/yosys/tests/arch/intel_alm/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..cffd3222b810561ee09a1aa7dd15db8327f4ca82 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/mul.ys @@ -0,0 +1,34 @@ +read_verilog ../common/mul.v +chparam -set X_WIDTH 8 -set Y_WIDTH 8 -set A_WIDTH 16 +hierarchy -top top +proc +equiv_opt -assert -map +/intel_alm/common/dsp_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:MISTRAL_MUL9X9 +select -assert-none t:MISTRAL_MUL9X9 %% t:* %D + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 17 -set Y_WIDTH 17 -set A_WIDTH 34 +hierarchy -top top +proc +equiv_opt -assert -map +/intel_alm/common/dsp_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:MISTRAL_MUL18X18 +select -assert-none t:MISTRAL_MUL18X18 %% t:* %D + +design -reset +read_verilog ../common/mul.v +chparam -set X_WIDTH 26 -set Y_WIDTH 26 -set A_WIDTH 52 +hierarchy -top top +proc +equiv_opt -assert -map +/intel_alm/common/dsp_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:MISTRAL_MUL27X27 +select -assert-none t:MISTRAL_MUL27X27 %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/mux.ys b/chips/yosys/tests/arch/intel_alm/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..1fdc82ae54d0a3e6968339a3a53817dd82f4a277 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/mux.ys @@ -0,0 +1,44 @@ +read_verilog ../common/mux.v +design -save read + + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_ALUT3 +select -assert-none t:MISTRAL_ALUT3 %% t:* %D + + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_ALUT6 +select -assert-none t:MISTRAL_ALUT6 %% t:* %D + + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 1 t:MISTRAL_ALUT3 +select -assert-count 2 t:MISTRAL_ALUT6 +select -assert-none t:MISTRAL_ALUT3 t:MISTRAL_ALUT6 %% t:* %D + + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/intel_alm/common/alm_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # 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-max 1 t:MISTRAL_ALUT3 +select -assert-max 2 t:MISTRAL_ALUT5 +select -assert-max 5 t:MISTRAL_ALUT6 +select -assert-none t:MISTRAL_ALUT3 t:MISTRAL_ALUT5 t:MISTRAL_ALUT6 %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/shifter.ys b/chips/yosys/tests/arch/intel_alm/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..1a4ed463b7983943ebe01fcd73079c8ef7f45784 --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/shifter.ys @@ -0,0 +1,9 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -async2sync -assert -map +/intel_alm/common/alm_sim.v -map +/intel_alm/common/dff_sim.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 8 t:MISTRAL_FF +select -assert-none t:MISTRAL_FF %% t:* %D diff --git a/chips/yosys/tests/arch/intel_alm/tribuf.ys b/chips/yosys/tests/arch/intel_alm/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..50896a3d8274bb502a2fd22e39c5b741da680dfa --- /dev/null +++ b/chips/yosys/tests/arch/intel_alm/tribuf.ys @@ -0,0 +1,12 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/simcells.v synth_intel_alm -family cyclonev -noiopad -noclkbuf # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +#Internal cell type used. Need support it. +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/add_sub.ys b/chips/yosys/tests/arch/machxo2/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..cc6ffb41a29e57d618e0114c57ed762588883c90 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/add_sub.ys @@ -0,0 +1,8 @@ +read_verilog ../common/add_sub.v +hierarchy -top top +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 10 t:LUT4 +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/adffs.ys b/chips/yosys/tests/arch/machxo2/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..49e93f9ac30a57c361890504b2d4cecc3d844e79 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/adffs.ys @@ -0,0 +1,40 @@ +read_verilog ../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF +select -assert-none t:TRELLIS_FF %% t:* %D + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF +select -assert-count 1 t:LUT4 +select -assert-none t:TRELLIS_FF t:LUT4 %% t:* %D + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF +select -assert-count 1 t:LUT4 +select -assert-none t:TRELLIS_FF t:LUT4 %% t:* %D + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF +select -assert-count 1 t:LUT4 +select -assert-none t:TRELLIS_FF t:LUT4 %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/counter.ys b/chips/yosys/tests/arch/machxo2/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..3d68c9900fa4e36b20737b5f134e69d2c669f39c --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/counter.ys @@ -0,0 +1,10 @@ +read_verilog ../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 4 t:CCU2D +select -assert-count 8 t:TRELLIS_FF +select -assert-none t:CCU2D t:TRELLIS_FF %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/dffs.ys b/chips/yosys/tests/arch/machxo2/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..531d5ca5a274f26ce6a83c6531bc01d757e13066 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/dffs.ys @@ -0,0 +1,19 @@ +read_verilog ../common/dffs.v +design -save read + +hierarchy -top dff +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dff # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF +select -assert-none t:TRELLIS_FF t:TRELLIS_IO %% t:* %D + +design -load read +hierarchy -top dffe +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:TRELLIS_FF t:LUT4 +select -assert-none t:TRELLIS_FF t:LUT4 t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/fsm.ys b/chips/yosys/tests/arch/machxo2/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..3e10a069a746cbbfa41d60caf7caf6a367737a07 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/fsm.ys @@ -0,0 +1,15 @@ +read_verilog ../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-max 16 t:LUT4 +select -assert-count 6 t:TRELLIS_FF +select -assert-none t:TRELLIS_FF t:LUT4 t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/generate_mk.py b/chips/yosys/tests/arch/machxo2/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..06a6040ad48bae5c2ce7163455d96b2401a68986 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/machxo2/logic.ys b/chips/yosys/tests/arch/machxo2/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..dbd702f905ea1a78ba9cafd20279ca9487966d1c --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/logic.ys @@ -0,0 +1,8 @@ +read_verilog ../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 9 t:LUT4 +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/lutram.ys b/chips/yosys/tests/arch/machxo2/lutram.ys new file mode 100644 index 0000000000000000000000000000000000000000..34c95909c3801e4f9236570c77be0eb55a193795 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/lutram.ys @@ -0,0 +1,17 @@ +read_verilog ../common/lutram.v +hierarchy -top lutram_1w1r +proc +memory -nomap +equiv_opt -run :prove -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 +memory +opt -full + +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 5 -set-init-zero -show-inputs -show-outputs miter + +design -load postopt +cd lutram_1w1r +select -assert-count 28 t:LUT4 +select -assert-count 8 t:TRELLIS_DPR16X4 +select -assert-count 8 t:TRELLIS_FF +select -assert-none t:LUT4 t:TRELLIS_DPR16X4 t:TRELLIS_FF %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/mux.ys b/chips/yosys/tests/arch/machxo2/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..c2e6360081267f4152f1d551435c8de30a229539 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/mux.ys @@ -0,0 +1,40 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT4 +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 3 t:LUT4 + +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 6 t:LUT4 + +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # 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-max 13 t:LUT4 + +select -assert-none t:LUT4 t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/shifter.ys b/chips/yosys/tests/arch/machxo2/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..ca7abb8098baa4660af4963f8242985545127c02 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/shifter.ys @@ -0,0 +1,10 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/lattice/cells_sim_xo2.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 8 t:TRELLIS_FF +select -assert-none t:TRELLIS_FF t:TRELLIS_IO %% t:* %D diff --git a/chips/yosys/tests/arch/machxo2/tribuf.ys b/chips/yosys/tests/arch/machxo2/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..00c7012d748169d04deca1dd543f01c921f0b5f1 --- /dev/null +++ b/chips/yosys/tests/arch/machxo2/tribuf.ys @@ -0,0 +1,9 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +flatten +equiv_opt -assert -map +/lattice/cells_sim_xo2.v -map +/simcells.v synth_lattice -family xo2 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 1 t:$_TBUF_ +select -assert-none t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/microchip/.gitignore b/chips/yosys/tests/arch/microchip/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..cd6ed10276983fd73d46b6597c98ce17617a26d3 --- /dev/null +++ b/chips/yosys/tests/arch/microchip/.gitignore @@ -0,0 +1 @@ +*.vm diff --git a/chips/yosys/tests/arch/microchip/dff.ys b/chips/yosys/tests/arch/microchip/dff.ys new file mode 100644 index 0000000000000000000000000000000000000000..9b6e03f5aae87b788d6e50b1af7d6b6e120155e1 --- /dev/null +++ b/chips/yosys/tests/arch/microchip/dff.ys @@ -0,0 +1,76 @@ +# ISC License +# +# Copyright (C) 2024 Microchip Technology Inc. and its subsidiaries +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +# active low async reset with enable +read_verilog < pipelined 36X36 MULT +design -load pristine +hierarchy -top mul24_io +synth_nexus -family lifcl -top mul24_io +select -assert-count 1 t:MULT36X36 r:REGINPUTA=REGISTER r:REGINPUTB=REGISTER r:REGOUTPUT=REGISTER +select -assert-count 0 t:FD1P3* + +# 32x32 MUL -> pipelined 36X36 MULT +design -load pristine +hierarchy -top mul32_io +synth_nexus -family lifcl -top mul32_io +select -assert-count 1 t:MULT36X36 r:REGINPUTA=REGISTER r:REGINPUTB=REGISTER r:REGOUTPUT=REGISTER +select -assert-count 0 t:FD1P3* + +# reject +# DSP reg is rising-edge +design -load pristine +hierarchy -top mul18_negedge +synth_nexus -family lifcl -top mul18_negedge +select -assert-count 1 t:MULT18X18 r:REGINPUTA=BYPASS r:REGINPUTB=BYPASS r:REGOUTPUT=BYPASS +select -assert-min 1 t:FD1P3* + +# DSP reg only resets to 0 +design -load pristine +hierarchy -top mul18_rst_nonzero +synth_nexus -family lifcl -top mul18_rst_nonzero +select -assert-count 1 t:MULT18X18 r:REGINPUTA=BYPASS r:REGINPUTB=BYPASS r:REGOUTPUT=BYPASS +select -assert-min 1 t:FD1P3* + +# two clocks feeding input regs -> can't share one CLK pin +design -load pristine +hierarchy -top mul18_two_clock +synth_nexus -family lifcl -top mul18_two_clock +select -assert-count 1 t:MULT18X18 r:REGINPUTA=BYPASS r:REGINPUTB=BYPASS +select -assert-min 1 t:FD1P3* diff --git a/chips/yosys/tests/arch/nexus/shifter.ys b/chips/yosys/tests/arch/nexus/shifter.ys new file mode 100644 index 0000000000000000000000000000000000000000..a8e34b0f9dc0555821a1f1e13328e9568741f0c9 --- /dev/null +++ b/chips/yosys/tests/arch/nexus/shifter.ys @@ -0,0 +1,9 @@ +read_verilog ../common/shifter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -map +/nexus/cells_sim.v synth_nexus # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 8 t:FD1P3IX +select -assert-none t:FD1P3IX t:WIDEFN9 t:INV t:IB t:OB t:VLO t:VHI %% t:* %D diff --git a/chips/yosys/tests/arch/nexus/tribuf.ys b/chips/yosys/tests/arch/nexus/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..70fb7cb5fa2f99a8cdda5578b1109d205879f0b7 --- /dev/null +++ b/chips/yosys/tests/arch/nexus/tribuf.ys @@ -0,0 +1,12 @@ +read_verilog ../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/nexus/cells_sim.v -map +/simcells.v synth_nexus # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 1 t:OBZ +select -assert-count 1 t:INV +select -assert-none t:OBZ t:INV t:IB t:OB t:VLO t:VHI %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/.gitignore b/chips/yosys/tests/arch/quicklogic/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d9f7e276c696c7b6f40ee2ff3824c86af3e1985f --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/.gitignore @@ -0,0 +1,2 @@ ++*_synth.v ++*_testbench diff --git a/chips/yosys/tests/arch/quicklogic/pp3/add_sub.ys b/chips/yosys/tests/arch/quicklogic/pp3/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..c5e9fb29be8626eda19e81033554e42bd54222bd --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/add_sub.ys @@ -0,0 +1,11 @@ +read_verilog ../../common/add_sub.v +hierarchy -top top +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v synth_quicklogic -family pp3 # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 2 t:LUT2 +select -assert-count 8 t:LUT3 +select -assert-count 2 t:LUT4 +select -assert-count 8 t:inpad +select -assert-count 8 t:outpad +select -assert-none t:LUT2 t:LUT3 t:LUT4 t:inpad t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/adffs.ys b/chips/yosys/tests/arch/quicklogic/pp3/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..fb9f34df429aec04f5f5d0812fe2a1259aca28ed --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/adffs.ys @@ -0,0 +1,67 @@ +read_verilog ../../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 1 t:inpad +select -assert-count 1 t:outpad +select -assert-count 2 t:ckpad + +select -assert-none t:dffepc t:logic_0 t:logic_1 t:inpad t:outpad t:ckpad %% t:* %D + + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT1 +select -assert-count 1 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 2 t:inpad +select -assert-count 1 t:outpad +select -assert-count 1 t:ckpad + +select -assert-none t:LUT1 t:dffepc t:logic_0 t:logic_1 t:inpad t:outpad t:ckpad %% t:* %D + + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT2 +select -assert-count 1 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 3 t:inpad +select -assert-count 1 t:outpad +select -assert-count 1 t:ckpad + +select -assert-none t:LUT2 t:dffepc t:logic_0 t:logic_1 t:inpad t:outpad t:ckpad %% t:* %D + + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT1 +select -assert-count 1 t:LUT2 +select -assert-count 1 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 4 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT1 t:LUT2 t:dffepc t:logic_0 t:logic_1 t:inpad t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/counter.ys b/chips/yosys/tests/arch/quicklogic/pp3/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..5095cb8efe875e9eb24a8619262dac016882ad2c --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/counter.ys @@ -0,0 +1,18 @@ +read_verilog ../../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT1 +select -assert-count 3 t:LUT2 +select -assert-count 5 t:LUT3 +select -assert-count 1 t:LUT4 +select -assert-count 8 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 8 t:outpad +select -assert-count 2 t:ckpad + +select -assert-none t:LUT1 t:LUT2 t:LUT3 t:LUT4 t:dffepc t:logic_0 t:logic_1 t:outpad t:ckpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/dffs.ys b/chips/yosys/tests/arch/quicklogic/pp3/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..f5023e48e14d4f1a11cc4280ee23d8670a87b412 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/dffs.ys @@ -0,0 +1,33 @@ +read_verilog ../../common/dffs.v +rename dff my_dff # Work around conflicting module names between test and vendor cells +rename dffe my_dffe +design -save read + +hierarchy -top my_dff +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd my_dff # Constrain all select calls below inside the top module +select -assert-count 1 t:ckpad +select -assert-count 1 t:dffepc +select -assert-count 1 t:inpad +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 1 t:outpad + +select -assert-none t:ckpad t:dffepc t:inpad t:logic_0 t:logic_1 t:outpad %% t:* %D + +design -load read +hierarchy -top my_dffe +proc +equiv_opt -async2sync -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd my_dffe # Constrain all select calls below inside the top module + +select -assert-count 1 t:ckpad +select -assert-count 1 t:dffepc +select -assert-count 2 t:inpad +select -assert-count 1 t:logic_0 +select -assert-count 1 t:outpad + +select -assert-none t:ckpad t:dffepc t:inpad t:logic_0 t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/fsm.ys b/chips/yosys/tests/arch/quicklogic/pp3/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..3276e45c628cfdc3cab1e72455bb4a55d845bba0 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/fsm.ys @@ -0,0 +1,21 @@ +read_verilog ../../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic +async2sync +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-count 4 t:dffepc +select -assert-count 1 t:logic_0 +select -assert-count 1 t:logic_1 +select -assert-count 3 t:inpad +select -assert-count 2 t:outpad +select -assert-count 1 t:ckpad + +select -assert-none t:LUT2 t:LUT3 t:LUT4 t:dffepc t:logic_0 t:logic_1 t:inpad t:outpad t:ckpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/generate_mk.py b/chips/yosys/tests/arch/quicklogic/pp3/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..e001d7e4a3b464bbc45fa384a009a980bc673454 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/generate_mk.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../../..") + +import gen_tests_makefile + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/quicklogic/pp3/latches.ys b/chips/yosys/tests/arch/quicklogic/pp3/latches.ys new file mode 100644 index 0000000000000000000000000000000000000000..3ae61b90f735428aa29eb6df5ba39611201f9e99 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/latches.ys @@ -0,0 +1,40 @@ +read_verilog ../../common/latches.v +design -save read + +hierarchy -top latchp +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_quicklogic -latches info +cd latchp # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 3 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT3 t:inpad t:outpad %% t:* %D + + +design -load read +hierarchy -top latchn +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_quicklogic -latches info +cd latchn # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 3 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT3 t:inpad t:outpad %% t:* %D + + +design -load read +hierarchy -top latchsr +proc +# Can't run any sort of equivalence check because latches are blown to LUTs +synth_quicklogic -latches info +cd latchsr # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT2 +select -assert-count 1 t:LUT4 +select -assert-count 5 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT2 t:LUT4 t:inpad t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/logic.ys b/chips/yosys/tests/arch/quicklogic/pp3/logic.ys new file mode 100644 index 0000000000000000000000000000000000000000..bfbd439c8463d2d5fe0cf16031995df6ff1db5c5 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/logic.ys @@ -0,0 +1,14 @@ +read_verilog ../../common/logic.v +hierarchy -top top +proc +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 4 t:LUT1 +select -assert-count 3 t:LUT2 +select -assert-count 2 t:LUT3 +select -assert-count 8 t:inpad +select -assert-count 10 t:outpad + +select -assert-none t:LUT1 t:LUT2 t:LUT3 t:inpad t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/mux.ys b/chips/yosys/tests/arch/quicklogic/pp3/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..a3b12a73d2a261247604ca29613ace06ce597feb --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/mux.ys @@ -0,0 +1,52 @@ +read_verilog ../../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 3 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT3 t:inpad t:outpad %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 3 t:LUT3 +select -assert-count 6 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT3 t:inpad t:outpad %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT1 +select -assert-count 1 t:LUT3 +select -assert-count 2 t:mux4x0 +select -assert-count 11 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT1 t:LUT3 t:mux4x0 t:inpad t:outpad %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic # 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 1 t:LUT3 +select -assert-count 2 t:mux8x0 +select -assert-count 20 t:inpad +select -assert-count 1 t:outpad + +select -assert-none t:LUT3 t:mux8x0 t:inpad t:outpad %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/pp3/tribuf.ys b/chips/yosys/tests/arch/quicklogic/pp3/tribuf.ys new file mode 100644 index 0000000000000000000000000000000000000000..f68a0d7790e1a60087d5c10298cdddd651f32a0f --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/pp3/tribuf.ys @@ -0,0 +1,13 @@ +read_verilog ../../common/tribuf.v +hierarchy -top tristate +proc +tribuf +flatten +synth +equiv_opt -assert -map +/quicklogic/pp3/cells_sim.v -map +/quicklogic/common/cells_sim.v -map +/simcells.v synth_quicklogic # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd tristate # Constrain all select calls below inside the top module +select -assert-count 2 t:inpad +select -assert-count 1 t:outpad +select -assert-count 1 t:$_TBUF_ +select -assert-none t:inpad t:outpad t:$_TBUF_ %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/.gitignore b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..fb232f235f3885d85de2910fc2752daca09d4b10 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/.gitignore @@ -0,0 +1 @@ +t_*.ys diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/add_sub.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/add_sub.ys new file mode 100644 index 0000000000000000000000000000000000000000..30d9bbc9dc32c327bd4b75c1aee364d263236156 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/add_sub.ys @@ -0,0 +1,8 @@ +read_verilog ../../common/add_sub.v +hierarchy -top top +equiv_opt -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 9 t:$lut # OOT flow has 8 +select -assert-count 8 t:adder_carry +select -assert-none t:$lut t:adder_carry %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/adffs.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/adffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..475355d2bd012d8297aee45d0258aee358001250 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/adffs.ys @@ -0,0 +1,48 @@ +read_verilog ../../common/adffs.v +design -save read + +hierarchy -top adff +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adff # Constrain all select calls below inside the top module +select -assert-count 1 t:$lut r:WIDTH=1 %i +select -assert-none r:WIDTH>1 +select -assert-count 1 t:dffsre + +select -assert-none t:$lut t:dffsre %% t:* %D + + +design -load read +hierarchy -top adffn +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd adffn # Constrain all select calls below inside the top module +select -assert-count 1 t:dffsre + +select -assert-none t:dffsre %% t:* %D + + +design -load read +hierarchy -top dffs +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd dffs # Constrain all select calls below inside the top module +select -assert-count 1 t:$lut r:WIDTH=1 %i +select -assert-none r:WIDTH>1 +select -assert-count 1 t:sdffsre + +select -assert-none t:$lut t:sdffsre %% t:* %D + + +design -load read +hierarchy -top ndffnr +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd ndffnr # Constrain all select calls below inside the top module +select -assert-count 1 t:sdffnsre + +select -assert-none t:sdffnsre %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/counter.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/counter.ys new file mode 100644 index 0000000000000000000000000000000000000000..d1a9ec692d7790a8a88ab6580f0dc855b663488b --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/counter.ys @@ -0,0 +1,12 @@ +read_verilog ../../common/counter.v +hierarchy -top top +proc +flatten +equiv_opt -assert -multiclock -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f -noioff # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module +select -assert-count 4 t:$lut +select -assert-count 8 t:adder_carry +select -assert-count 8 t:dffsre + +select -assert-none t:$lut t:adder_carry t:dffsre %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/dffs.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/dffs.ys new file mode 100644 index 0000000000000000000000000000000000000000..78bd221cc780378040447993bb6679d18ab584c7 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/dffs.ys @@ -0,0 +1,21 @@ +read_verilog ../../common/dffs.v +rename dff my_dff # Work around conflicting module names between test and vendor cells +rename dffe my_dffe +design -save read + +hierarchy -top my_dff +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f -noioff # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd my_dff # Constrain all select calls below inside the top module +select -assert-count 1 t:sdffsre +select -assert-none t:sdffsre %% t:* %D + +design -load read +hierarchy -top my_dffe +proc +equiv_opt -async2sync -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f -noioff # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd my_dffe # Constrain all select calls below inside the top module +select -assert-count 1 t:sdffsre +select -assert-none t:sdffsre %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/div.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/div.ys new file mode 100644 index 0000000000000000000000000000000000000000..dd5de9d3a78d9d0cd67a67b6c86c73fa628ba366 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/div.ys @@ -0,0 +1,14 @@ +# division by constants should not infer carry chains. +read_verilog < 0) + assert(y == y_expected); + i <= i + 1; + end +end +endmodule +EOF +techmap -autoproc -map +/quicklogic/qlf_k6n10f/dsp_sim.v +hierarchy -top testbench +proc +async2sync +sim -assert -q -clock clk -n 20 diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/fsm.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/fsm.ys new file mode 100644 index 0000000000000000000000000000000000000000..e7a9d962d6e21a9a37bff6d72b89afa35701981a --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/fsm.ys @@ -0,0 +1,17 @@ +read_verilog ../../common/fsm.v +hierarchy -top fsm +proc +flatten + +equiv_opt -run :prove -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f +async2sync +miter -equiv -make_assert -flatten gold gate miter +sat -verify -prove-asserts -show-public -set-at 1 in_reset 1 -seq 20 -prove-skip 1 miter + +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd fsm # Constrain all select calls below inside the top module + +select -assert-count 9 t:$lut +select -assert-count 6 t:sdffsre + +select -assert-none t:$lut t:sdffsre %% t:* %D diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/generate_mk.py b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/generate_mk.py new file mode 100644 index 0000000000000000000000000000000000000000..e9abad21a381c9e089df60cc9d509fc3e931c54f --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/generate_mk.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +import sys +sys.path.append("../../..") + +import gen_tests_makefile +import mem_gen + +gen_tests_makefile.generate(["--yosys-scripts", "--bash", "--yosys-args", "-w 'Yosys has only limited support for tri-state logic at the moment.'" ]) diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/ioff.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/ioff.ys new file mode 100644 index 0000000000000000000000000000000000000000..da1fb2946d84a2439fc6d753af0d7085501199ac --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/ioff.ys @@ -0,0 +1,209 @@ +# test: acceptable for output IOFF promotion +read_verilog < 1: + top_list.pop(0) + + # iterate over string substitutions + for top in top_list: + # limit number of tests per file to allow parallel make + if not f: + fn = f"t_mem{i}.ys" + f = open(fn, mode="w") + j = 0 + + # output yosys script test file + print( + blockram_template.format(param_str=param_str, top=top), + file=f + ) + for assertion in sim_test.assertions: + print("log ** CHECKING CELL COUNTS FOR TEST {top} WITH PARAMS{param_str}".format(param_str=param_str, top=top), file=f) + print("select {}".format(assertion), file=f) + print("", file=f) + + # prepare simulation tests + test_steps = sim_test.test_steps + if test_steps: + if top == "sync_ram_sdp": + uut_submodule = sync_ram_sdp_submodule + elif top == "sync_ram_tdp": + uut_submodule = sync_ram_tdp_submodule + elif top == "sync_ram_sdp_wwr": + uut_submodule = sync_ram_sdp_wwr_submodule + elif top == "sync_ram_sdp_wrr": + uut_submodule = sync_ram_sdp_wrr_submodule + elif top == "double_sync_ram_sdp": + uut_submodule = double_sync_ram_sdp_submodule + else: + raise NotImplementedError(f"missing submodule header for {top}") + mem_test_vector = "" + for step, test in enumerate(test_steps): + for key, val in test.items(): + key = test_val_map[key] + mem_test_vector += f"\\\n{key}[{step}] = 'h{val:x};" + print( + sim_template.format( + top=top, + mem_test_vector=mem_test_vector, + uut_submodule=uut_submodule, + param_str=param_str, + vectorlen=len(test_steps) + 2 + ), file=f + ) + # simulation counts for 2 tests + j += 1 + + # increment test counter + j += 1 + if j >= max_j: + f = f.close() + i += 1 + +if f: + f.close() diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mem_tb.v b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mem_tb.v new file mode 100644 index 0000000000000000000000000000000000000000..988aceaca23a53f898105d333f01773ce4bfd4fe --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mem_tb.v @@ -0,0 +1,84 @@ +module TB(input clk); + +parameter ADDRESS_WIDTH = 10; +parameter ADDRESS_WIDTH_A = ADDRESS_WIDTH; +parameter ADDRESS_WIDTH_B = ADDRESS_WIDTH; +parameter DATA_WIDTH = 36; +parameter DATA_WIDTH_A = DATA_WIDTH; +parameter DATA_WIDTH_B = DATA_WIDTH; +parameter VECTORLEN = 16; +parameter SHIFT_VAL = 0; + +// intentionally keep expected values at full width precision to allow testing +// of truncation +localparam MAX_WIDTH = 36; + +reg rce_a_testvector [VECTORLEN-1:0]; +reg [ADDRESS_WIDTH_A-1:0] ra_a_testvector [VECTORLEN-1:0]; +reg [MAX_WIDTH-1:0] rq_a_expected [VECTORLEN-1:0]; + +reg wce_a_testvector [VECTORLEN-1:0]; +reg [ADDRESS_WIDTH_A-1:0] wa_a_testvector [VECTORLEN-1:0]; +reg [DATA_WIDTH_A-1:0] wd_a_testvector [VECTORLEN-1:0]; + +reg rce_b_testvector [VECTORLEN-1:0]; +reg [ADDRESS_WIDTH_B-1:0] ra_b_testvector [VECTORLEN-1:0]; +reg [MAX_WIDTH-1:0] rq_b_expected [VECTORLEN-1:0]; + +reg wce_b_testvector [VECTORLEN-1:0]; +reg [ADDRESS_WIDTH_B-1:0] wa_b_testvector [VECTORLEN-1:0]; +reg [DATA_WIDTH_B-1:0] wd_b_testvector [VECTORLEN-1:0]; + +reg [$clog2(VECTORLEN)-1:0] i = 0; + +integer j; +initial begin + for (j = 0; j < VECTORLEN; j = j + 1) begin + rce_a_testvector[j] = 1'b0; + ra_a_testvector[j] = 10'h0; + wce_a_testvector[j] = 1'b0; + wa_a_testvector[j] = 10'h0; + rce_b_testvector[j] = 1'b0; + ra_b_testvector[j] = 10'h0; + wce_b_testvector[j] = 1'b0; + wa_b_testvector[j] = 10'h0; + + end + + `MEM_TEST_VECTOR + +end + + +wire rce_a = rce_a_testvector[i]; +wire [ADDRESS_WIDTH_A-1:0] ra_a = ra_a_testvector[i]; +wire [MAX_WIDTH-1:0] rq_a_e = rq_a_expected[i]; +wire [DATA_WIDTH_A-1:0] rq_a; + +wire wce_a = wce_a_testvector[i]; +wire [ADDRESS_WIDTH_A-1:0] wa_a = wa_a_testvector[i]; +wire [DATA_WIDTH_A-1:0] wd_a = wd_a_testvector[i]; + +wire rce_b = rce_b_testvector[i]; +wire [ADDRESS_WIDTH_B-1:0] ra_b = ra_b_testvector[i]; +wire [MAX_WIDTH-1:0] rq_b_e = rq_b_expected[i]; +wire [DATA_WIDTH_B-1:0] rq_b; + +wire wce_b = wce_b_testvector[i]; +wire [ADDRESS_WIDTH_B-1:0] wa_b = wa_b_testvector[i]; +wire [DATA_WIDTH_B-1:0] wd_b = wd_b_testvector[i]; + +`UUT_SUBMODULE + +always @(posedge clk) begin + if (i < VECTORLEN-1) begin + if (i > 0) begin + if($past(rce_a)) + assert(rq_a == rq_a_e); + if($past(rce_b)) + assert(rq_b == rq_b_e); + end + i <= i + 1; + end +end +endmodule diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.v b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.v new file mode 100644 index 0000000000000000000000000000000000000000..afc52565695c9ee80e19a0e93bd61bdb0886d914 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.v @@ -0,0 +1,50 @@ +module top(clk); +parameter DEPTH_LOG2 = 10; +parameter WIDTH = 36; +parameter PRIME = 237481091; +localparam DEPTH = 2**DEPTH_LOG2; + +input wire clk; + +(* syn_ramstyle = "block_ram" *) +reg [WIDTH-1:0] mem [DEPTH-1:0]; + +integer i; +initial begin + for (i = 0; i < DEPTH; i = i + 1) begin + // Make up data by multiplying a large prime with the address, + // then cropping and retaining the lower bits + mem[i] = PRIME * i; + end +end + +reg [DEPTH_LOG2-1:0] counter = 0; +reg done = 1'b0; + +reg did_read = 1'b0; +reg [DEPTH_LOG2-1:0] read_addr; +reg [WIDTH-1:0] read_val; + +always @(posedge clk) begin + if (!done) begin + did_read <= 1'b1; + read_addr <= counter; + read_val <= mem[counter]; + end else begin + did_read <= 1'b0; + end + + if (!done) + counter = counter + 1; + if (counter == 0) + done = 1; +end + +wire [WIDTH-1:0] expect_val = PRIME * read_addr; +always @(posedge clk) begin + if (did_read) begin + $display("addr %x expected %x actual %x", read_addr, expect_val, read_val); + assert(read_val == expect_val); + end +end +endmodule diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.ys new file mode 100644 index 0000000000000000000000000000000000000000..8e9849c3b46715ca7d2c9efde128a7e989fca5a8 --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/meminit.ys @@ -0,0 +1,15 @@ +read_verilog -sv meminit.v +chparam -set DEPTH_LOG2 3 -set WIDTH 36 +prep +opt_dff +prep -rdff +synth_quicklogic -family qlf_k6n10f -run map_bram:map_bram +select -assert-none t:$mem_v2 t:$mem +select -assert-count 1 t:TDP36K +select -assert-count 1 t:TDP36K a:is_split=0 %i +select -assert-count 1 t:TDP36K a:was_split_candidate=0 %i +read_verilog +/quicklogic/common/cells_sim.v +/quicklogic/qlf_k6n10f/cells_sim.v +/quicklogic/qlf_k6n10f/brams_sim.v +/quicklogic/qlf_k6n10f/sram1024x18_mem.v +/quicklogic/qlf_k6n10f/ufifo_ctl.v +/quicklogic/qlf_k6n10f/TDP18K_FIFO.v +prep +async2sync +hierarchy -top top +sim -assert -q -n 12 -clock clk diff --git a/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mux.ys b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..633b5fc865687fc2f5484abcbd4e6dd923ea437c --- /dev/null +++ b/chips/yosys/tests/arch/quicklogic/qlf_k6n10f/mux.ys @@ -0,0 +1,40 @@ +read_verilog ../../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:$lut r:WIDTH=3 %i +select -assert-none t:$lut r:WIDTH=3 %i %% t:* %D + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:$lut r:WIDTH=6 %i +select -assert-none t:$lut r:WIDTH=6 %i %% t:* %D + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 2 t:$lut r:WIDTH=6 %i +select -assert-count 1 t:$lut r:WIDTH=3 %i +select -assert-none t:$lut r:WIDTH=6 r:WIDTH=3 %u %i %% t:* %D + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/quicklogic/qlf_k6n10f/cells_sim.v -map +/quicklogic/common/cells_sim.v synth_quicklogic -family qlf_k6n10f # 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-max 5 t:$lut r:WIDTH=6 %i # OOT flow does 2 +select -assert-max 1 t:$lut r:WIDTH=3 %i # and here 1 +select -assert-max 1 t:$lut r:WIDTH=4 r:WIDTH=5 %u %i +select -assert-none t:$lut r:WIDTH>2 %i %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/.gitignore b/chips/yosys/tests/arch/xilinx/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..15a12d049486cea6b2fcb41c059249235665695d --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/.gitignore @@ -0,0 +1,3 @@ +/run-test.mk +/*_uut.v +/test_macc diff --git a/chips/yosys/tests/arch/xilinx/abc9_dff.ys b/chips/yosys/tests/arch/xilinx/abc9_dff.ys new file mode 100644 index 0000000000000000000000000000000000000000..9101c6e4d574213dc2ae4542d1ca44d8c1951b84 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/abc9_dff.ys @@ -0,0 +1,142 @@ +logger -nowarn "Yosys has only limited support for tri-state logic at the moment\. .*" +logger -nowarn "Ignoring boxed module .*\." + +read_verilog < RAMB18E1 + +# w4b | r16b +design -reset +read_verilog asym_ram_sdp_read_wider.v +synth_xilinx -top asym_ram_sdp_read_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w8b | r16b +design -reset +read_verilog asym_ram_sdp_read_wider.v +chparam -set WIDTHA 8 -set SIZEA 512 -set ADDRWIDTHA 9 asym_ram_sdp_read_wider +synth_xilinx -top asym_ram_sdp_read_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w4b | r32b +design -reset +read_verilog asym_ram_sdp_read_wider.v +chparam -set WIDTHB 32 -set SIZEB 128 -set ADDRWIDTHB 7 asym_ram_sdp_read_wider +synth_xilinx -top asym_ram_sdp_read_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w16b | r4b +design -reset +read_verilog asym_ram_sdp_write_wider.v +synth_xilinx -top asym_ram_sdp_write_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w16b | r8b +design -reset +read_verilog asym_ram_sdp_write_wider.v +chparam -set WIDTHB 8 -set SIZEB 512 -set ADDRWIDTHB 9 asym_ram_sdp_read_wider +synth_xilinx -top asym_ram_sdp_write_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w32b | r4b +design -reset +read_verilog asym_ram_sdp_write_wider.v +chparam -set WIDTHA 32 -set SIZEA 128 -set ADDRWIDTHA 7 asym_ram_sdp_read_wider +synth_xilinx -top asym_ram_sdp_write_wider -noiopad +select -assert-count 1 t:RAMB18E1 + +# w4b | r24b +design -reset +read_verilog asym_ram_sdp_read_wider.v +chparam -set SIZEA 768 +chparam -set WIDTHB 24 -set SIZEB 128 -set ADDRWIDTHB 7 asym_ram_sdp_read_wider +synth_xilinx -top asym_ram_sdp_read_wider -noiopad +select -assert-count 1 t:RAMB18E1 diff --git a/chips/yosys/tests/arch/xilinx/asym_ram_sdp_read_wider.v b/chips/yosys/tests/arch/xilinx/asym_ram_sdp_read_wider.v new file mode 100644 index 0000000000000000000000000000000000000000..fec464e481ae568397e9d858786f06f9c0f03cff --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/asym_ram_sdp_read_wider.v @@ -0,0 +1,72 @@ +// Asymmetric port RAM +// Read Wider than Write. Read Statement in loop +//asym_ram_sdp_read_wider.v +module asym_ram_sdp_read_wider (clkA, clkB, enaA, weA, enaB, addrA, addrB, diA, doB); + parameter WIDTHA = 4; + parameter SIZEA = 1024; + parameter ADDRWIDTHA = 10; + + parameter WIDTHB = 16; + parameter SIZEB = 256; + parameter ADDRWIDTHB = 8; + + input clkA; + input clkB; + input weA; + input enaA, enaB; + input [ADDRWIDTHA-1:0] addrA; + input [ADDRWIDTHB-1:0] addrB; + input [WIDTHA-1:0] diA; + output [WIDTHB-1:0] doB; + + `define max(a,b) {(a) > (b) ? (a) : (b)} + `define min(a,b) {(a) < (b) ? (a) : (b)} + + function integer log2; + input integer value; + reg [31:0] shifted; + integer res; + begin + if (value < 2) + log2 = value; + else + begin + shifted = value-1; + for (res=0; shifted>0; res=res+1) + shifted = shifted>>1; + log2 = res; + end + end + endfunction + + localparam maxSIZE = `max(SIZEA, SIZEB); + localparam maxWIDTH = `max(WIDTHA, WIDTHB); + localparam minWIDTH = `min(WIDTHA, WIDTHB); + + localparam RATIO = maxWIDTH / minWIDTH; + localparam log2RATIO = log2(RATIO); + + reg [minWIDTH-1:0] RAM [0:maxSIZE-1]; + reg [WIDTHB-1:0] readB; + + always @(posedge clkA) + begin + if (enaA) begin + if (weA) + RAM[addrA] <= diA; + end + end + + always @(posedge clkB) + begin : ramread + integer i; + reg [log2RATIO-1:0] lsbaddr; + if (enaB) begin + for (i = 0; i < RATIO; i = i+1) begin + lsbaddr = i; + readB[(i+1)*minWIDTH-1 -: minWIDTH] <= RAM[{addrB, lsbaddr}]; + end + end + end + assign doB = readB; +endmodule diff --git a/chips/yosys/tests/arch/xilinx/asym_ram_sdp_write_wider.v b/chips/yosys/tests/arch/xilinx/asym_ram_sdp_write_wider.v new file mode 100644 index 0000000000000000000000000000000000000000..5492a6b3542f2f9d7b4bca71ce6e5a3030faaa11 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/asym_ram_sdp_write_wider.v @@ -0,0 +1,71 @@ +// Asymmetric port RAM +// Write wider than Read. Write Statement in a loop. +// asym_ram_sdp_write_wider.v +module asym_ram_sdp_write_wider (clkA, clkB, weA, enaA, enaB, addrA, addrB, diA, doB); + parameter WIDTHB = 4; + parameter SIZEB = 1024; + parameter ADDRWIDTHB = 10; + + parameter WIDTHA = 16; + parameter SIZEA = 256; + parameter ADDRWIDTHA = 8; + + input clkA; + input clkB; + input weA; + input enaA, enaB; + input [ADDRWIDTHA-1:0] addrA; + input [ADDRWIDTHB-1:0] addrB; + input [WIDTHA-1:0] diA; + output [WIDTHB-1:0] doB; + + `define max(a,b) {(a) > (b) ? (a) : (b)} + `define min(a,b) {(a) < (b) ? (a) : (b)} + + function integer log2; + input integer value; + reg [31:0] shifted; + integer res; + begin + if (value < 2) + log2 = value; + else + begin + shifted = value-1; + for (res=0; shifted>0; res=res+1) + shifted = shifted>>1; + log2 = res; + end + end + endfunction + + localparam maxSIZE = `max(SIZEA, SIZEB); + localparam maxWIDTH = `max(WIDTHA, WIDTHB); + localparam minWIDTH = `min(WIDTHA, WIDTHB); + + localparam RATIO = maxWIDTH / minWIDTH; + localparam log2RATIO = log2(RATIO); + + reg [minWIDTH-1:0] RAM [0:maxSIZE-1]; + reg [WIDTHB-1:0] readB; + + always @(posedge clkB) begin + if (enaB) begin + readB <= RAM[addrB]; + end + end + assign doB = readB; + + always @(posedge clkA) + begin : ramwrite + integer i; + reg [log2RATIO-1:0] lsbaddr; + for (i=0; i< RATIO; i= i+ 1) begin : write1 + lsbaddr = i; + if (enaA) begin + if (weA) + RAM[{addrA, lsbaddr}] <= diA[(i+1)*minWIDTH-1 -: minWIDTH]; + end + end + end +endmodule diff --git a/chips/yosys/tests/arch/xilinx/attributes_test.ys b/chips/yosys/tests/arch/xilinx/attributes_test.ys new file mode 100644 index 0000000000000000000000000000000000000000..16dad6dbf8f3a693af4a9e8e6f9a1c04c01478aa --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/attributes_test.ys @@ -0,0 +1,37 @@ +# Check that blockram memory without parameters is not modified +read_verilog ../common/memory_attributes/attributes_test.v +hierarchy -top block_ram +synth_xilinx -top block_ram -noiopad +cd block_ram # Constrain all select calls below inside the top module +select -assert-count 1 t:RAMB18E1 + +# Check that distributed memory without parameters is not modified +design -reset +read_verilog ../common/memory_attributes/attributes_test.v +hierarchy -top distributed_ram +synth_xilinx -top distributed_ram -noiopad +cd distributed_ram # Constrain all select calls below inside the top module +select -assert-count 1 t:RAM32M + +# Set ram_style distributed to blockram memory; will be implemented as distributed +design -reset +read_verilog ../common/memory_attributes/attributes_test.v +setattr -set ram_style "distributed" block_ram/m:* +synth_xilinx -top block_ram -noiopad +cd block_ram # Constrain all select calls below inside the top module +select -assert-count 16 t:RAM256X1S + +# Set synthesis, logic_block to blockram memory; will be implemented as distributed +design -reset +read_verilog ../common/memory_attributes/attributes_test.v +setattr -set logic_block 1 block_ram/m:* +synth_xilinx -top block_ram -noiopad +cd block_ram # Constrain all select calls below inside the top module +select -assert-count 0 t:RAMB18E1 + +# Set ram_style block to a distributed memory; will be implemented as blockram +design -reset +read_verilog ../common/memory_attributes/attributes_test.v +synth_xilinx -top distributed_ram_manual -noiopad +cd distributed_ram_manual # Constrain all select calls below inside the top module +select -assert-count 1 t:RAMB18E1 diff --git a/chips/yosys/tests/arch/xilinx/blockram.ys b/chips/yosys/tests/arch/xilinx/blockram.ys new file mode 100644 index 0000000000000000000000000000000000000000..96da72eaa68572797bc38fa1b86bb0a915feb1b8 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/blockram.ys @@ -0,0 +1,73 @@ +### TODO: Not running equivalence checking because BRAM models does not exists +### currently. Checking instance counts instead. +# Memory bits <= 18K; Data width <= 36; Address width <= 14: -> RAMB18E1 +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 12 -set DATA_WIDTH 1 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 + +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 8 -set DATA_WIDTH 18 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 + +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 14 -set DATA_WIDTH 1 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 + +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 9 -set DATA_WIDTH 36 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 + +# Anything memory bits < 1024 -> LUTRAM +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 8 -set DATA_WIDTH 2 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 0 t:RAMB18E1 +select -assert-count 4 t:RAM64M + +# More than 18K bits, data width <= 36 (TDP), and address width from 10 to 15b (non-cascaded) -> RAMB36E1 +design -reset +read_verilog ../common/blockram.v +chparam -set ADDRESS_WIDTH 10 -set DATA_WIDTH 36 sync_ram_sdp +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB36E1 + + +### With parameters + +design -reset +read_verilog ../common/blockram.v +hierarchy -top sync_ram_sdp -chparam ADDRESS_WIDTH 12 -chparam DATA_WIDTH 1 +setattr -set ram_style "block" m:memory +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 + +design -reset +read_verilog ../common/blockram.v +hierarchy -top sync_ram_sdp -chparam ADDRESS_WIDTH 12 -chparam DATA_WIDTH 1 +setattr -set logic_block 1 m:memory +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 0 t:RAMB18E1 + +design -reset +read_verilog ../common/blockram.v +hierarchy -top sync_ram_sdp -chparam ADDRESS_WIDTH 8 -chparam DATA_WIDTH 1 +setattr -set ram_style "block" m:memory +synth_xilinx -top sync_ram_sdp -noiopad +cd sync_ram_sdp +select -assert-count 1 t:RAMB18E1 diff --git a/chips/yosys/tests/arch/xilinx/bug1460.ys b/chips/yosys/tests/arch/xilinx/bug1460.ys new file mode 100644 index 0000000000000000000000000000000000000000..09935ccd80d510a246aac3ec913af79f01280744 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/bug1460.ys @@ -0,0 +1,34 @@ +read_verilog < DSP48E1.PCIN +# (i.e. Take all DSP48E1s, expand to find all wires connected +# to its PCOUT port, then remove all DSP48E1s from this +# selection, then expand again to find all cells where +# those wires are connected to the PCIN port, then remove +# all wires from this selection, and lastly intersect +# this selection with all DSP48E1 cells (to check that +# the connected cells are indeed DSPs) +select -assert-count 2 t:DSP48E1 %co:+[PCOUT] t:DSP48E1 %d %co:+[PCIN] w:* %d t:DSP48E1 %i + +design -load read +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc6s -noiopad +design -load postopt +cd cascade +select -assert-count 3 t:DSP48A1 +select -assert-count 5 t:FDRE # No cascade for A input +select -assert-none t:DSP48A1 t:BUFG t:FDRE %% t:* %D +# Very crude method of checking that DSP48E1.PCOUT -> DSP48E1.PCIN +# (see above for explanation) +select -assert-count 2 t:DSP48A1 %co:+[PCOUT] t:DSP48A1 %d %co:+[PCIN] w:* %d t:DSP48A1 %i + +design -reset +read_verilog < DSP48E1.PCIN +# (see above for explanation) +select -assert-count 1 t:DSP48E1 %co:+[PCOUT] t:DSP48E1 %d %co:+[PCIN] w:* %d t:DSP48E1 %i + +design -load read +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc6s -noiopad +design -load postopt +cd cascade +select -assert-count 2 t:DSP48A1 +select -assert-count 10 t:FDRE # Cannot cascade because first 'm' DSP + # uses both B0REG and B1REG, whereas 'o' + # only requires 1 +select -assert-none t:DSP48A1 t:BUFG t:FDRE %% t:* %D +# Very crude method of checking that DSP48E1.PCOUT -> DSP48E1.PCIN +# (see above for explanation) +select -assert-count 1 t:DSP48A1 %co:+[PCOUT] t:DSP48A1 %d %co:+[PCIN] w:* %d t:DSP48A1 %i diff --git a/chips/yosys/tests/arch/xilinx/dsp_fastfir.ys b/chips/yosys/tests/arch/xilinx/dsp_fastfir.ys new file mode 100644 index 0000000000000000000000000000000000000000..57fe49bde8f6adfaac03e5f2d1fbee1c9b1f94d6 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/dsp_fastfir.ys @@ -0,0 +1,69 @@ +read_verilog <= 2**(SIZEOUT-1)) | overflow_reg; + +// Output accumulation result +assign accum_out = overflow ? 2**(SIZEOUT-1)-1 : adder_out; + +endmodule diff --git a/chips/yosys/tests/arch/xilinx/macc.ys b/chips/yosys/tests/arch/xilinx/macc.ys new file mode 100644 index 0000000000000000000000000000000000000000..61a570f4812a670284ea90e0da94aa23443ac406 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/macc.ys @@ -0,0 +1,32 @@ +read_verilog macc.v +design -save read + +hierarchy -top macc +proc +#equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad ### TODO +equiv_opt -run :prove -map +/xilinx/cells_sim.v synth_xilinx -noiopad +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 3 -show-inputs -show-outputs miter +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd macc # Constrain all select calls below inside the top module +select -assert-count 1 t:BUFG +select -assert-count 1 t:FDRE +select -assert-count 1 t:DSP48E1 +select -assert-none t:BUFG t:FDRE t:DSP48E1 %% t:* %D + +design -load read +hierarchy -top macc2 +proc +#equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad ### TODO +equiv_opt -run :prove -map +/xilinx/cells_sim.v synth_xilinx -noiopad +miter -equiv -flatten -make_assert -make_outputs gold gate miter +sat -verify -prove-asserts -seq 4 -show-inputs -show-outputs miter +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd macc2 # Constrain all select calls below inside the top module + +select -assert-count 1 t:BUFG +select -assert-count 1 t:DSP48E1 +select -assert-count 1 t:FDRE +select -assert-count 1 t:LUT2 +select -assert-count 40 t:LUT3 +select -assert-none t:BUFG t:DSP48E1 t:FDRE t:LUT2 t:LUT3 %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/macc_tb.v b/chips/yosys/tests/arch/xilinx/macc_tb.v new file mode 100644 index 0000000000000000000000000000000000000000..64aed05c49abeb1e99418ec36952e81aef130c04 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/macc_tb.v @@ -0,0 +1,96 @@ +`timescale 1ns / 1ps + +module testbench; + + parameter SIZEIN = 16, SIZEOUT = 40; + reg clk, ce, rst; + reg signed [SIZEIN-1:0] a, b; + output signed [SIZEOUT-1:0] REF_accum_out, accum_out; + output REF_overflow, overflow; + + integer errcount = 0; + + reg ERROR_FLAG = 0; + + task clkcycle; + begin + #5; + clk = ~clk; + #10; + clk = ~clk; + #2; + ERROR_FLAG = 0; + if (REF_accum_out !== accum_out) begin + $display("ERROR at %1t: REF_accum_out=%b UUT_accum_out=%b DIFF=%b", $time, REF_accum_out, accum_out, REF_accum_out ^ accum_out); + errcount = errcount + 1; + ERROR_FLAG = 1; + end + if (REF_overflow !== overflow) begin + $display("ERROR at %1t: REF_overflow=%b UUT_overflow=%b DIFF=%b", $time, REF_overflow, overflow, REF_overflow ^ overflow); + errcount = errcount + 1; + ERROR_FLAG = 1; + end + #3; + end + endtask + + initial begin + //$dumpfile("test_macc.vcd"); + //$dumpvars(0, testbench); + + #2; + clk = 1'b0; + ce = 1'b0; + a = 0; + b = 0; + + rst = 1'b1; + repeat (10) begin + #10; + clk = 1'b1; + #10; + clk = 1'b0; + #10; + clk = 1'b1; + #10; + clk = 1'b0; + end + rst = 1'b0; + + repeat (10000) begin + clkcycle; + ce = 1; //$urandom & $urandom; + //rst = $urandom & $urandom & $urandom & $urandom & $urandom & $urandom; + a = $urandom & ~(1 << (SIZEIN-1)); + b = $urandom & ~(1 << (SIZEIN-1)); + end + + if (errcount == 0) begin + $display("All tests passed."); + $finish; + end else begin + $display("Caught %1d errors.", errcount); + $stop; + end + end + + macc2 ref ( + .clk(clk), + .ce(ce), + .rst(rst), + .a(a), + .b(b), + .accum_out(REF_accum_out), + .overflow(REF_overflow) + ); + + macc2_uut uut ( + .clk(clk), + .ce(ce), + .rst(rst), + .a(a), + .b(b), + .accum_out(accum_out), + .overflow(overflow) + ); +endmodule diff --git a/chips/yosys/tests/arch/xilinx/mul.ys b/chips/yosys/tests/arch/xilinx/mul.ys new file mode 100644 index 0000000000000000000000000000000000000000..490846ff1a621e9c44722ceda7ee0bafa27413ec --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/mul.ys @@ -0,0 +1,21 @@ +read_verilog ../common/mul.v +hierarchy -top top +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:DSP48E1 +select -assert-none t:DSP48E1 %% t:* %D + +design -reset + +read_verilog ../common/mul.v +hierarchy -top top +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc6s -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd top # Constrain all select calls below inside the top module + +select -assert-count 1 t:DSP48A1 +select -assert-none t:DSP48A1 %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/mul_unsigned.v b/chips/yosys/tests/arch/xilinx/mul_unsigned.v new file mode 100644 index 0000000000000000000000000000000000000000..e3713a6428174ddfb3c64db9bc8c4267e9c0e7b7 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/mul_unsigned.v @@ -0,0 +1,30 @@ +/* +Example from: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_1/ug901-vivado-synthesis.pdf [p. 89]. +*/ + +// Unsigned 16x24-bit Multiplier +// 1 latency stage on operands +// 3 latency stage after the multiplication +// File: multipliers2.v +// +module mul_unsigned (clk, A, B, RES); +parameter WIDTHA = /*16*/ 6; +parameter WIDTHB = /*24*/ 9; +input clk; +input [WIDTHA-1:0] A; +input [WIDTHB-1:0] B; +output [WIDTHA+WIDTHB-1:0] RES; +reg [WIDTHA-1:0] rA; +reg [WIDTHB-1:0] rB; +reg [WIDTHA+WIDTHB-1:0] M [3:0]; +integer i; +always @(posedge clk) + begin + rA <= A; + rB <= B; + M[0] <= rA * rB; + for (i = 0; i < 3; i = i+1) + M[i+1] <= M[i]; + end +assign RES = M[3]; +endmodule diff --git a/chips/yosys/tests/arch/xilinx/mul_unsigned.ys b/chips/yosys/tests/arch/xilinx/mul_unsigned.ys new file mode 100644 index 0000000000000000000000000000000000000000..980263cbd13c518225d113ca9dcbcac48e6eba93 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/mul_unsigned.ys @@ -0,0 +1,25 @@ +read_verilog mul_unsigned.v +hierarchy -top mul_unsigned +proc + +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned # Constrain all select calls below inside the top module +select -assert-count 1 t:BUFG +select -assert-count 1 t:DSP48E1 +select -assert-count 30 t:FDRE +select -assert-none t:DSP48E1 t:FDRE t:BUFG %% t:* %D + +design -reset + +read_verilog mul_unsigned.v +hierarchy -top mul_unsigned +proc + +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc6s -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mul_unsigned # Constrain all select calls below inside the top module +select -assert-count 1 t:BUFG +select -assert-count 1 t:DSP48A1 +select -assert-count 30 t:FDRE +select -assert-none t:DSP48A1 t:FDRE t:BUFG %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/mux.ys b/chips/yosys/tests/arch/xilinx/mux.ys new file mode 100644 index 0000000000000000000000000000000000000000..c2a23de6d966e1bdfb06e1a840512a9243786dc0 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/mux.ys @@ -0,0 +1,50 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 + +select -assert-none t:LUT3 %% t:* %D + + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT6 + +select -assert-none t:LUT6 %% t:* %D + + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 +select -assert-count 2 t:LUT6 + +select -assert-none t:LUT3 t:LUT6 %% t:* %D + + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -noiopad # 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-max 2 t:LUT3 +select -assert-max 2 t:LUT4 +select -assert-min 4 t:LUT6 +select -assert-max 7 t:LUT6 +select -assert-max 2 t:MUXF7 +dump + +select -assert-none t:LUT6 t:LUT4 t:LUT3 t:MUXF7 %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/mux_lut4.ys b/chips/yosys/tests/arch/xilinx/mux_lut4.ys new file mode 100644 index 0000000000000000000000000000000000000000..591289c26545784e71e467feb51c6077f0d5ca85 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/mux_lut4.ys @@ -0,0 +1,52 @@ +read_verilog ../common/mux.v +design -save read + +hierarchy -top mux2 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc3se -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux2 # Constrain all select calls below inside the top module +select -assert-count 1 t:LUT3 + +select -assert-none t:LUT3 %% t:* %D + + +design -load read +hierarchy -top mux4 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc3se -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux4 # Constrain all select calls below inside the top module +select -assert-count 4 t:LUT4 +select -assert-count 2 t:MUXF5 +select -assert-count 1 t:MUXF6 +select -assert-none t:LUT4 t:MUXF5 t:MUXF6 %% t:* %D + + +design -load read +hierarchy -top mux8 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc3se -noiopad # equivalency check +design -load postopt # load the post-opt design (otherwise equiv_opt loads the pre-opt design) +cd mux8 # Constrain all select calls below inside the top module +select -assert-max 1 t:LUT3 +select -assert-max 5 t:LUT4 +select -assert-max 1 t:MUXF5 + +select -assert-none t:LUT3 t:LUT4 t:MUXF5 %% t:* %D + + +design -load read +hierarchy -top mux16 +proc +equiv_opt -assert -map +/xilinx/cells_sim.v synth_xilinx -family xc3se -noiopad # 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-max 14 t:LUT3 +select -assert-max 20 t:LUT4 +select -assert-max 16 t:MUXF5 +select -assert-max 8 t:MUXF6 +select -assert-max 3 t:MUXF7 +select -assert-count 1 t:MUXF8 + +select -assert-none t:LUT3 t:LUT4 t:MUXF5 t:MUXF6 t:MUXF7 t:MUXF8 %% t:* %D diff --git a/chips/yosys/tests/arch/xilinx/nosrl.ys b/chips/yosys/tests/arch/xilinx/nosrl.ys new file mode 100644 index 0000000000000000000000000000000000000000..31bd5d377acddba127cf1715cd0a2d10d3491305 --- /dev/null +++ b/chips/yosys/tests/arch/xilinx/nosrl.ys @@ -0,0 +1,41 @@ +read_verilog < 0 && rx_cnt < 9) begin + rx_reg[rx_cnt - 1] <= rx_d2; + end + if (rx_cnt == 9) begin + rx_busy <= 0; + // Check if End of frame received correctly + if (rx_d2 == 0) begin + rx_frame_err <= 1; + end else begin + rx_empty <= 0; + rx_frame_err <= 0; + // Check if last rx data was not unloaded, + rx_over_run <= (rx_empty) ? 0 : 1; + end + end + end + end + end + end + if (!rx_enable) begin + rx_busy <= 0; + end +end + +// UART TX Logic +always @ (posedge txclk or posedge reset) +if (reset) begin + tx_reg <= 0; + tx_empty <= 1; + tx_over_run <= 0; + tx_out <= 1; + tx_cnt <= 0; +end else begin + if (ld_tx_data) begin + if (!tx_empty) begin + tx_over_run <= 0; + end else begin + tx_reg <= tx_data; + tx_empty <= 0; + end + end + if (tx_enable && !tx_empty) begin + tx_cnt <= tx_cnt + 1; + if (tx_cnt == 0) begin + tx_out <= 0; + end + if (tx_cnt > 0 && tx_cnt < 9) begin + tx_out <= tx_reg[tx_cnt -1]; + end + if (tx_cnt == 9) begin + tx_out <= 1; + tx_cnt <= 0; + tx_empty <= 1; + end + end + if (!tx_enable) begin + tx_cnt <= 0; + end +end + +endmodule diff --git a/chips/yosys/tests/asicworld/code_hdl_models_up_counter.v b/chips/yosys/tests/asicworld/code_hdl_models_up_counter.v new file mode 100644 index 0000000000000000000000000000000000000000..4ebd58b2115ca87b43962ed0f34fb1caab142031 --- /dev/null +++ b/chips/yosys/tests/asicworld/code_hdl_models_up_counter.v @@ -0,0 +1,28 @@ +//----------------------------------------------------- +// Design Name : up_counter +// File Name : up_counter.v +// Function : Up counter +// Coder : Deepak +//----------------------------------------------------- +module up_counter ( +out , // Output of the counter +enable , // enable for counter +clk , // clock Input +reset // reset Input +); +//----------Output Ports-------------- + output [7:0] out; +//------------Input Ports-------------- + input enable, clk, reset; +//------------Internal Variables-------- + reg [7:0] out; +//-------------Code Starts Here------- +always @(posedge clk) +if (reset) begin + out <= 8'b0 ; +end else if (enable) begin + out <= out + 1; +end + + +endmodule diff --git a/chips/yosys/tests/asicworld/code_hdl_models_up_counter_load.v b/chips/yosys/tests/asicworld/code_hdl_models_up_counter_load.v new file mode 100644 index 0000000000000000000000000000000000000000..89645db58660736650241991579970a0030527f3 --- /dev/null +++ b/chips/yosys/tests/asicworld/code_hdl_models_up_counter_load.v @@ -0,0 +1,32 @@ +//----------------------------------------------------- +// Design Name : up_counter_load +// File Name : up_counter_load.v +// Function : Up counter with load +// Coder : Deepak Kumar Tala +//----------------------------------------------------- +module up_counter_load ( +out , // Output of the counter +data , // Parallel load for the counter +load , // Parallel load enable +enable , // Enable counting +clk , // clock input +reset // reset input +); +//----------Output Ports-------------- +output [7:0] out; +//------------Input Ports-------------- +input [7:0] data; +input load, enable, clk, reset; +//------------Internal Variables-------- +reg [7:0] out; +//-------------Code Starts Here------- +always @(posedge clk) +if (reset) begin + out <= 8'b0 ; +end else if (load) begin + out <= data; +end else if (enable) begin + out <= out + 1; +end + +endmodule diff --git a/chips/yosys/tests/asicworld/code_hdl_models_up_down_counter.v b/chips/yosys/tests/asicworld/code_hdl_models_up_down_counter.v new file mode 100644 index 0000000000000000000000000000000000000000..9a634edeb89f3fcf92edced066b7410185edc6d7 --- /dev/null +++ b/chips/yosys/tests/asicworld/code_hdl_models_up_down_counter.v @@ -0,0 +1,29 @@ +//----------------------------------------------------- +// Design Name : up_down_counter +// File Name : up_down_counter.v +// Function : Up down counter +// Coder : Deepak Kumar Tala +//----------------------------------------------------- +module up_down_counter ( +out , // Output of the counter +up_down , // up_down control for counter +clk , // clock input +reset // reset input +); +//----------Output Ports-------------- +output [7:0] out; +//------------Input Ports-------------- +input up_down, clk, reset; +//------------Internal Variables-------- +reg [7:0] out; +//-------------Code Starts Here------- +always @(posedge clk) +if (reset) begin // active high reset + out <= 8'b0 ; +end else if (up_down) begin + out <= out + 1; +end else begin + out <= out - 1; +end + +endmodule diff --git a/chips/yosys/tests/asicworld/code_specman_switch_fabric.v b/chips/yosys/tests/asicworld/code_specman_switch_fabric.v new file mode 100644 index 0000000000000000000000000000000000000000..adf973798f4d3ccfe5b5340989d321fb649dc465 --- /dev/null +++ b/chips/yosys/tests/asicworld/code_specman_switch_fabric.v @@ -0,0 +1,82 @@ +module switch_fabric( + clk, reset, data_in0, data_in1, data_in2, + data_in3, data_in4, data_in5, data_in_valid0, + data_in_valid1, data_in_valid2, data_in_valid3, + data_in_valid4, data_in_valid5, data_out0, + data_out1, data_out2, data_out3, data_out4, + data_out5, data_out_ack0, data_out_ack1, + data_out_ack2, data_out_ack3, data_out_ack4, + data_out_ack5 +); + +input clk, reset; +input [7:0] data_in0, data_in1, data_in2, data_in3; +input [7:0] data_in4, data_in5; +input data_in_valid0, data_in_valid1, data_in_valid2; +input [7:0] data_in_valid3, data_in_valid4, data_in_valid5; +output [7:0] data_out0, data_out1, data_out2, data_out3; +output [7:0] data_out4, data_out5; +output data_out_ack0, data_out_ack1, data_out_ack2; +output [7:0] data_out_ack3, data_out_ack4, data_out_ack5; + +(* gentb_clock *) +wire clk; + +switch port_0 ( .clk(clk), .reset(reset), .data_in(data_in0), + .data_in_valid(data_in_valid0), .data_out(data_out0), + .data_out_ack(data_out_ack0)); + +switch port_1 ( .clk(clk), .reset(reset), .data_in(data_in1), + .data_in_valid(data_in_valid1), .data_out(data_out1), + .data_out_ack(data_out_ack1)); + +switch port_2 ( .clk(clk), .reset(reset), .data_in(data_in2), + .data_in_valid(data_in_valid2), .data_out(data_out2), . + data_out_ack(data_out_ack2)); + +switch port_3 ( .clk(clk), .reset(reset), .data_in(data_in3), + .data_in_valid(data_in_valid3), .data_out(data_out3), + .data_out_ack(data_out_ack3)); + +switch port_4 ( .clk(clk), .reset(reset), .data_in(data_in4), + .data_in_valid(data_in_valid4), .data_out(data_out4), + .data_out_ack(data_out_ack4)); + +switch port_5 ( .clk(clk), .reset(reset), .data_in(data_in5), + .data_in_valid(data_in_valid5), .data_out(data_out5), + .data_out_ack(data_out_ack5)); + +endmodule + +module switch ( + clk, + reset, + data_in, + data_in_valid, + data_out, + data_out_ack +); + +input clk; +input reset; +input [7:0] data_in; +input data_in_valid; +output [7:0] data_out; +output data_out_ack; + +reg [7:0] data_out; +reg data_out_ack; + +always @ (posedge clk) +if (reset) begin + data_out <= 0; + data_out_ack <= 0; +end else if (data_in_valid) begin + data_out <= data_in; + data_out_ack <= 1; +end else begin + data_out <= 0; + data_out_ack <= 0; +end + +endmodule diff --git a/chips/yosys/tests/asicworld/code_tidbits_asyn_reset.v b/chips/yosys/tests/asicworld/code_tidbits_asyn_reset.v new file mode 100644 index 0000000000000000000000000000000000000000..85bd71004bb6461623e1e6589fd93d195d17325f --- /dev/null +++ b/chips/yosys/tests/asicworld/code_tidbits_asyn_reset.v @@ -0,0 +1,18 @@ +module asyn_reset(clk,reset,a,c); + input clk; + input reset; + input a; + output c; + + wire clk; + wire reset; + wire a; + reg c; + +always @ (posedge clk or posedge reset) + if ( reset == 1'b1) begin + c <= 0; + end else begin + c <= a; + end +endmodule diff --git a/chips/yosys/tests/asicworld/code_tidbits_blocking.v b/chips/yosys/tests/asicworld/code_tidbits_blocking.v new file mode 100644 index 0000000000000000000000000000000000000000..79d67d9373d853174a48a4227ef460406b24a484 --- /dev/null +++ b/chips/yosys/tests/asicworld/code_tidbits_blocking.v @@ -0,0 +1,17 @@ +module blocking (clk,a,c); +input clk; +input a; +output c; + +wire clk; +wire a; +reg c; +reg b; + +always @ (posedge clk ) +begin + b = a; + c = b; +end + +endmodule diff --git a/chips/yosys/tests/asicworld/code_tidbits_fsm_using_always.v b/chips/yosys/tests/asicworld/code_tidbits_fsm_using_always.v new file mode 100644 index 0000000000000000000000000000000000000000..7162bfa619e2ac801ae28a1eaeed5f7db11a89fc --- /dev/null +++ b/chips/yosys/tests/asicworld/code_tidbits_fsm_using_always.v @@ -0,0 +1,91 @@ +//----------------------------------------------------- +// This is FSM demo program using always block +// Design Name : fsm_using_always +// File Name : fsm_using_always.v +//----------------------------------------------------- +module fsm_using_always ( +clock , // clock +reset , // Active high, syn reset +req_0 , // Request 0 +req_1 , // Request 1 +gnt_0 , // Grant 0 +gnt_1 +); +//-------------Input Ports----------------------------- +input clock,reset,req_0,req_1; + //-------------Output Ports---------------------------- +output gnt_0,gnt_1; +//-------------Input ports Data Type------------------- +wire clock,reset,req_0,req_1; +//-------------Output Ports Data Type------------------ +reg gnt_0,gnt_1; +//-------------Internal Constants-------------------------- +parameter SIZE = 3 ; +parameter IDLE = 3'b001,GNT0 = 3'b010,GNT1 = 3'b100 ; +//-------------Internal Variables--------------------------- +reg [SIZE-1:0] state ;// Seq part of the FSM +reg [SIZE-1:0] next_state ;// combo part of FSM +//----------Code startes Here------------------------ +always @ (state or req_0 or req_1) +begin : FSM_COMBO + next_state = 3'b000; + case(state) + IDLE : if (req_0 == 1'b1) begin + next_state = GNT0; + end else if (req_1 == 1'b1) begin + next_state= GNT1; + end else begin + next_state = IDLE; + end + GNT0 : if (req_0 == 1'b1) begin + next_state = GNT0; + end else begin + next_state = IDLE; + end + GNT1 : if (req_1 == 1'b1) begin + next_state = GNT1; + end else begin + next_state = IDLE; + end + default : next_state = IDLE; + endcase +end +//----------Seq Logic----------------------------- +always @ (posedge clock) +begin : FSM_SEQ + if (reset == 1'b1) begin + state <= #1 IDLE; + end else begin + state <= #1 next_state; + end +end +//----------Output Logic----------------------------- +always @ (posedge clock) +begin : OUTPUT_LOGIC +if (reset == 1'b1) begin + gnt_0 <= #1 1'b0; + gnt_1 <= #1 1'b0; +end +else begin + case(state) + IDLE : begin + gnt_0 <= #1 1'b0; + gnt_1 <= #1 1'b0; + end + GNT0 : begin + gnt_0 <= #1 1'b1; + gnt_1 <= #1 1'b0; + end + GNT1 : begin + gnt_0 <= #1 1'b0; + gnt_1 <= #1 1'b1; + end + default : begin + gnt_0 <= #1 1'b0; + gnt_1 <= #1 1'b0; + end + endcase +end +end // End Of Block OUTPUT_LOGIC + +endmodule // End of Module arbiter