diff --git a/fuzzers/011-clb-ffconfig/top.py b/fuzzers/011-clb-ffconfig/top.py index 87106984..e403081a 100644 --- a/fuzzers/011-clb-ffconfig/top.py +++ b/fuzzers/011-clb-ffconfig/top.py @@ -1,11 +1,14 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog from prims import * -CLBN = 600 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 600 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) f = open("top.txt", "w") diff --git a/fuzzers/012-clb-n5ffmux/top.py b/fuzzers/012-clb-n5ffmux/top.py index 8d2ec5d9..a2be2d3d 100644 --- a/fuzzers/012-clb-n5ffmux/top.py +++ b/fuzzers/012-clb-n5ffmux/top.py @@ -1,9 +1,12 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 40 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 40 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/013-clb-ncy0/top.py b/fuzzers/013-clb-ncy0/top.py index 1510ca77..65949a7f 100644 --- a/fuzzers/013-clb-ncy0/top.py +++ b/fuzzers/013-clb-ncy0/top.py @@ -1,9 +1,12 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 400 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 400 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) @@ -107,7 +110,7 @@ module clb_NCY0_O5 (input clk, input [7:0] din, output [7:0] dout); always @(*) begin s = din[7:4]; s[N] = o6; - + di = {din[3:0]}; di[N] = o5; end diff --git a/fuzzers/014-clb-ffsrcemux/top.py b/fuzzers/014-clb-ffsrcemux/top.py index f56c3029..e0112629 100644 --- a/fuzzers/014-clb-ffsrcemux/top.py +++ b/fuzzers/014-clb-ffsrcemux/top.py @@ -5,7 +5,10 @@ import re from prjxray import util from prjxray import verilog -CLBN = 600 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 600 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/015-clb-nffmux/top.py b/fuzzers/015-clb-nffmux/top.py index d233b89f..90769867 100644 --- a/fuzzers/015-clb-nffmux/top.py +++ b/fuzzers/015-clb-nffmux/top.py @@ -1,9 +1,12 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 400 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 400 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/016-clb-noutmux/top.py b/fuzzers/016-clb-noutmux/top.py index 4cc660c0..808ef73c 100644 --- a/fuzzers/016-clb-noutmux/top.py +++ b/fuzzers/016-clb-noutmux/top.py @@ -1,9 +1,12 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 400 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 400 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/017-clb-precyinit/top.py b/fuzzers/017-clb-precyinit/top.py index 348ec7e4..2edb311c 100644 --- a/fuzzers/017-clb-precyinit/top.py +++ b/fuzzers/017-clb-precyinit/top.py @@ -5,7 +5,10 @@ import re from prjxray import verilog from prjxray import util -CLBN = 400 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 400 + int(INCREMENT) SLICEX, SLICEY = util.site_xy_minmax([ 'SLICEL', 'SLICEM', diff --git a/fuzzers/018-clb-ram/top.py b/fuzzers/018-clb-ram/top.py index a7a02280..c96db4d7 100644 --- a/fuzzers/018-clb-ram/top.py +++ b/fuzzers/018-clb-ram/top.py @@ -15,12 +15,15 @@ SRLC32E_N Note: LUT6 was added to try to simplify reduction, although it might not be needed ''' -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 50 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 50 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/019-clb-ndi1mux/top.py b/fuzzers/019-clb-ndi1mux/top.py index 5966a563..f9ce5224 100644 --- a/fuzzers/019-clb-ndi1mux/top.py +++ b/fuzzers/019-clb-ndi1mux/top.py @@ -1,9 +1,12 @@ -import random +import os, random random.seed(0) from prjxray import util from prjxray import verilog -CLBN = 50 +# INCREMENT is the amount of additional CLBN to be instantiated in the design. +# This makes the fuzzer compilation more robust against failures. +INCREMENT = os.getenv('CLBN', 0) +CLBN = 50 + int(INCREMENT) print('//Requested CLBs: %s' % str(CLBN)) diff --git a/fuzzers/clb.mk b/fuzzers/clb.mk index 08dbacb3..a2a55182 100644 --- a/fuzzers/clb.mk +++ b/fuzzers/clb.mk @@ -4,6 +4,17 @@ CLB_DBFIXUP ?= # ie set to N if only for SLICEM SLICEL ?= Y +# This set of variables are used to store the increment +# in the number of CLBs in case they are not enough and +# the generated database is inconsistent +CLBN ?= 0 +INC ?= 50 +VAR ?= "CLBN=$$(($(CLBN) + $(INC)))" +ENV_VAR ?= "CLBN=$(CLBN)" +ITER ?= 0 +MAX_ITER ?= 10 +FUZDIR = ${PWD} + include ../fuzzer.mk database: build/segbits_clbx.db @@ -26,7 +37,19 @@ else endif ${XRAY_MASKMERGE} build/mask_clbx.db $(SEGDATAS) -pushdb: +checkdb: + # If the database presents errors or is incomplete, the fuzzer is rerun. + # When it reaches the maximum number of iterations it fails. + @if [ $(ITER) -gt $(MAX_ITER) ]; then \ + echo "Max Iterations reached. Fuzzer unsolvable."; \ + exit 1; \ + fi + $(MAKE) parsedb || $(MAKE) $(VAR) ITER=$$(($(ITER) + 1)) run + +parsedb: + ${XRAY_PARSEDB} --strict build/segbits_clbx.db + +pushdb: checkdb ifeq ($(SLICEL),Y) ${XRAY_MERGEDB} clbll_l build/segbits_clbx.db ${XRAY_MERGEDB} clbll_r build/segbits_clbx.db @@ -38,5 +61,5 @@ endif ${XRAY_MERGEDB} mask_clblm_l build/mask_clbx.db ${XRAY_MERGEDB} mask_clblm_r build/mask_clbx.db -.PHONY: database pushdb +.PHONY: database pushdb checkdb parsedb diff --git a/fuzzers/fuzzer.mk b/fuzzers/fuzzer.mk index 0e52ffda..a819a12f 100644 --- a/fuzzers/fuzzer.mk +++ b/fuzzers/fuzzer.mk @@ -1,12 +1,15 @@ N ?= 1 SPECIMENS := $(addprefix build/specimen_,$(shell seq -f '%03.0f' $(N))) SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS)) +ENV_VAR ?= +FUZDIR ?= ${PWD} all: database $(SPECIMENS_OK): + echo ${ENV_VAR} mkdir -p build - bash ${XRAY_DIR}/utils/top_generate.sh $(subst /OK,,$@) + if [ -f $(FUZDIR)/generate.sh ]; then export $(ENV_VAR); bash $(FUZDIR)/generate.sh $(subst /OK,,$@); else bash ${XRAY_DIR}/utils/top_generate.sh $(subst /OK,,$@); fi run: $(MAKE) clean