From 8b66865106b5c8dac0b1537ce8b10d52d0536a13 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Thu, 17 Jan 2019 15:31:50 +0100 Subject: [PATCH 1/3] 01x-clb/top.py: Added CLBN increment from env var Signed-off-by: Alessandro Comodi --- fuzzers/011-clb-ffconfig/top.py | 7 +++++-- fuzzers/012-clb-n5ffmux/top.py | 7 +++++-- fuzzers/013-clb-ncy0/top.py | 9 ++++++--- fuzzers/014-clb-ffsrcemux/top.py | 5 ++++- fuzzers/015-clb-nffmux/top.py | 7 +++++-- fuzzers/016-clb-noutmux/top.py | 7 +++++-- fuzzers/017-clb-precyinit/top.py | 5 ++++- fuzzers/018-clb-ram/top.py | 7 +++++-- fuzzers/019-clb-ndi1mux/top.py | 7 +++++-- 9 files changed, 44 insertions(+), 17 deletions(-) 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)) From 13e5fbdf992233acf940f4e072c108834f69764a Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Thu, 17 Jan 2019 15:35:29 +0100 Subject: [PATCH 2/3] clb.mk and fuzzer.mk: rerun the fuzzer in case of failure Signed-off-by: Alessandro Comodi --- fuzzers/clb.mk | 8 ++++++++ fuzzers/fuzzer.mk | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fuzzers/clb.mk b/fuzzers/clb.mk index 08dbacb3..a9c15d12 100644 --- a/fuzzers/clb.mk +++ b/fuzzers/clb.mk @@ -4,6 +4,14 @@ 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)" + include ../fuzzer.mk database: build/segbits_clbx.db diff --git a/fuzzers/fuzzer.mk b/fuzzers/fuzzer.mk index 0e52ffda..49c8f5b1 100644 --- a/fuzzers/fuzzer.mk +++ b/fuzzers/fuzzer.mk @@ -1,17 +1,27 @@ N ?= 1 SPECIMENS := $(addprefix build/specimen_,$(shell seq -f '%03.0f' $(N))) SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS)) +ENV_VAR ?= +VAR ?= +ITER ?= 0 +MAX_ITER ?= 10 all: database $(SPECIMENS_OK): mkdir -p build - bash ${XRAY_DIR}/utils/top_generate.sh $(subst /OK,,$@) + if [ -f `pwd`/generate.sh ]; then export $(ENV_VAR); bash `pwd`/generate.sh $(subst /OK,,$@); else bash ${XRAY_DIR}/utils/top_generate.sh $(subst /OK,,$@); fi run: + # 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) clean $(MAKE) database - $(MAKE) pushdb + $(MAKE) pushdb || $(MAKE) $(VAR) ITER=$$(($(ITER) + 1)) run touch run.ok clean: From b8d645fc21e5e40ed5ec5d9733d2869bc34e8048 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Thu, 17 Jan 2019 18:33:11 +0100 Subject: [PATCH 3/3] clb.mk and fuzzer.mk: checking only local db with parsedb Signed-off-by: Alessandro Comodi --- fuzzers/clb.mk | 19 +++++++++++++++++-- fuzzers/fuzzer.mk | 15 ++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fuzzers/clb.mk b/fuzzers/clb.mk index a9c15d12..a2a55182 100644 --- a/fuzzers/clb.mk +++ b/fuzzers/clb.mk @@ -11,6 +11,9 @@ CLBN ?= 0 INC ?= 50 VAR ?= "CLBN=$$(($(CLBN) + $(INC)))" ENV_VAR ?= "CLBN=$(CLBN)" +ITER ?= 0 +MAX_ITER ?= 10 +FUZDIR = ${PWD} include ../fuzzer.mk @@ -34,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 @@ -46,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 49c8f5b1..a819a12f 100644 --- a/fuzzers/fuzzer.mk +++ b/fuzzers/fuzzer.mk @@ -2,26 +2,19 @@ N ?= 1 SPECIMENS := $(addprefix build/specimen_,$(shell seq -f '%03.0f' $(N))) SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS)) ENV_VAR ?= -VAR ?= -ITER ?= 0 -MAX_ITER ?= 10 +FUZDIR ?= ${PWD} all: database $(SPECIMENS_OK): + echo ${ENV_VAR} mkdir -p build - if [ -f `pwd`/generate.sh ]; then export $(ENV_VAR); bash `pwd`/generate.sh $(subst /OK,,$@); else bash ${XRAY_DIR}/utils/top_generate.sh $(subst /OK,,$@); fi + 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: - # 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) clean $(MAKE) database - $(MAKE) pushdb || $(MAKE) $(VAR) ITER=$$(($(ITER) + 1)) run + $(MAKE) pushdb touch run.ok clean: