diff options
author | Yann Herklotz <git@yannherklotz.com> | 2019-10-29 12:06:05 +0000 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2019-10-29 12:06:05 +0000 |
commit | 4ee6646b8a78d4c20fe0b89d95f23d382e1c47fc (patch) | |
tree | 9b02e1b92f8abf0baf3dc108ab7f4fb8f33e753a /scripts | |
parent | 1aaff80235237507572e0fb4be86f34cb1829b68 (diff) | |
parent | 01c2ab3f6a58d416528efce3057e2cf2f1604489 (diff) | |
download | verismith-feature/nondeterminism.tar.gz verismith-feature/nondeterminism.zip |
Merge branch 'master' into HEADfeature/nondeterminism
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/config.toml | 37 | ||||
-rw-r--r-- | scripts/main.v | 27 | ||||
-rwxr-xr-x | scripts/parallelsets.py | 97 | ||||
-rwxr-xr-x | scripts/run.py | 37 | ||||
-rwxr-xr-x | scripts/scale.py | 26 | ||||
-rw-r--r-- | scripts/setup.sh | 6 | ||||
-rwxr-xr-x | scripts/size.py | 2 | ||||
-rwxr-xr-x | scripts/swarm.py | 4 |
8 files changed, 215 insertions, 21 deletions
diff --git a/scripts/config.toml b/scripts/config.toml new file mode 100644 index 0000000..15e961f --- /dev/null +++ b/scripts/config.toml @@ -0,0 +1,37 @@ + +[info] + commit = "562f0da77e0464bfc21e8753070aec1cf9e60cf2" + version = "0.2.0.0" + +[probability] + expr.binary = 5 + expr.concatenation = 3 + expr.number = 1 + expr.rangeselect = 5 + expr.signed = 5 + expr.string = 0 + expr.ternary = 5 + expr.unary = 5 + expr.unsigned = 5 + expr.variable = 5 + moditem.assign = 2 + moditem.combinational = 0 + moditem.instantiation = 1 + moditem.sequential = 3 + statement.blocking = 0 + statement.conditional = 1 + statement.forloop = 1 + statement.nonblocking = 2 + +[property] + module.depth = 2 + module.max = 5 + size = 20 + statement.depth = 5 + sample.method = "hat" + sample.size = 10 + +[[synthesiser]] + description = "yosys" + name = "yosys" + output = "syn_yosys.v" diff --git a/scripts/main.v b/scripts/main.v new file mode 100644 index 0000000..452d2bf --- /dev/null +++ b/scripts/main.v @@ -0,0 +1,27 @@ +module top +#( parameter param9 = ((~(((8'ha3) >= (8'ha4)) <= (~&(8'ha4)))) ? ((((8'h9e) ? (8'h9c) : (8'h9c)) ? {(8'hb0)} : ((8'ha2) ? (8'ha8) : (8'hae))) ? (((8'h9c) ? (8'h9d) : (8'hae)) >>> ((8'hae) ? (8'had) : (8'h9e))) : (((8'ha1) ? (8'ha8) : (8'h9c)) < ((8'h9f) <= (8'hb0)))) : (!(!(8'hb0)))) +, parameter param10 = param9 +, parameter param11 = (param9 >= (8'ha1)) +, parameter param12 = {((param11 != (8'h9f)) ? (^(^~(8'ha9))) : (+{param11}))} ) +(y, clk, wire0, wire1); + output wire [(32'h34):(32'h0)] y ; + input wire [(1'h0):(1'h0)] clk ; + input wire [(4'h9):(1'h0)] wire0 ; + input wire [(3'h7):(1'h0)] wire1 ; + wire signed [(3'h4):(1'h0)] wire8 ; + wire signed [(4'h8):(1'h0)] wire7 ; + wire [(3'h7):(1'h0)] wire6 ; + wire signed [(4'ha):(1'h0)] wire5 ; + wire [(4'h8):(1'h0)] wire4 ; + wire [(4'h9):(1'h0)] wire3 ; + wire signed [(3'h5):(1'h0)] wire2 ; + assign wire2 = ((^wire0) >> $signed(wire1[(3'h4):(1'h0)])) ; + assign wire3 = (~|$signed(wire0)) ; + assign wire4 = $signed({wire0}) ; + assign wire5 = (&($unsigned((wire4 <<< wire4)) ^ $unsigned(((8'ha3) * wire0)))) ; + assign wire6 = $signed(({(wire5 ? + wire2 : wire1)} >>> (^~((8'hac) + wire3)))) ; + assign wire7 = wire4[(2'h3):(1'h1)] ; + assign wire8 = {{wire0}} ; + assign y = {wire8, wire7, wire6, wire5, wire4, wire3, wire2, (1'h0)} ; +endmodule
\ No newline at end of file diff --git a/scripts/parallelsets.py b/scripts/parallelsets.py new file mode 100755 index 0000000..d7d4636 --- /dev/null +++ b/scripts/parallelsets.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 + +import os +import re +from pathlib import Path +import itertools +import subprocess + +def iterdir(currdir): + return [x for x in currdir.iterdir() if x.is_dir()] + +def identify_vivado(current, name): + v2018 = re.compile(".*2018.2") + v2017 = re.compile(".*2017.4") + v20161 = re.compile(".*2016.1") + v20162 = re.compile(".*2016.2") + + if v2018.match(name): + current[3] = 1 + elif v2017.match(name): + current[2] = 1 + elif v20162.match(name): + current[1] = 1 + elif v20161.match(name): + current[0] = 1 + + return current + +def identify_general(current, name): + yosys = re.compile(".*yosys") + vivado = re.compile(".*vivado") + xst = re.compile(".*xst") + quartus = re.compile(".*quartus") + + if yosys.match(name): + current[3] = 1 + elif vivado.match(name): + current[2] = 1 + elif xst.match(name): + current[1] = 1 + elif quartus.match(name): + current[0] = 1 + + return current + +def get_group(val): + return val[0] + +def get_freq(val): + return val[1] + +def timeout_present(directory): + return subprocess.run([ "grep", "-r", "--include", "symbiyosys.log" + , "-m", "1", "-q", "Keyboard interrupt" + , directory.as_posix() + ]).returncode == 0 + +def find_reduce_dirs(start_dir=".", prefix="reduce"): + matcher = re.compile(prefix + ".*") + fuzzmatch = re.compile("fuzz.*") + initdir = Path(start_dir) + + sets = [] + for dirlevel1 in iterdir(initdir): + for dirlevel2 in iterdir(dirlevel1): + current_set = [0, 0, 0, 0] + update = True + for dirlevel3 in iterdir(dirlevel2): + if matcher.match(dirlevel3.name): + if timeout_present(dirlevel2): + current_set = [2, 2, 2, 2] + continue + current_set = identify_vivado( + current_set, dirlevel3.name) + elif fuzzmatch.match(dirlevel3.name): + current_set = [0, 0, 0, 0] + for dirlevel4 in iterdir(dirlevel3): + if timeout_present(dirlevel3): + current_set = [2, 2, 2, 2] + break + if matcher.match(dirlevel4.name): + current_set = identify_vivado( + current_set, dirlevel4.name) + sets.append((current_set, dirlevel3)) + update = False + if update: + sets.append((current_set, dirlevel2)) + freqs = [(x, len(list(y))) for x, y in + itertools.groupby(sorted(sets, key=get_group), + get_group)] + print(sorted(freqs, key=get_freq)) + +def main(): + find_reduce_dirs(".", "reduce") + +if __name__ == "__main__": + main() diff --git a/scripts/run.py b/scripts/run.py index 63295af..3930ca7 100755 --- a/scripts/run.py +++ b/scripts/run.py @@ -2,21 +2,28 @@ import subprocess import os +import sys +import datetime -def main(): - i = 0 - name = "mediumB" - config = "experiments/config_yosys.toml" - iterations = 50 - directory = "yosys_all" - if not os.path.exists(directory): - os.makedirs(directory) - while True: - subprocess.call(["verifuzz", "fuzz" - , "-o", directory + "/" + name + str(i) - , "-c", config - , "-n", str(iterations)]) - i += 1 +def main(run_id): + i = 0 + name = "medium_{}_".format(run_id) + config = "config.toml" + iterations = 100 + directory = "yosys_all" + try: + os.makedirs(directory) + except IOError: + pass + while True: + output_directory = directory + "/" + name + str(i) + print("{} :: {}".format(datetime.datetime.now(), output_directory)) + with open(output_directory + ".log", "w") as f: + subprocess.call(["cabal", "run", "-O2", "verismith", "--", "fuzz" + , "-o", output_directory + , "-c", config + , "-n", str(iterations)], stdout=f) + i += 1 if __name__ == '__main__': - main() + main(sys.argv[1]) diff --git a/scripts/scale.py b/scripts/scale.py new file mode 100755 index 0000000..7dbc155 --- /dev/null +++ b/scripts/scale.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import csv +import sys +import random + +def main(filename, output_file): + with open(filename, "r") as f: + reader = list(csv.reader(f)) + newreader = [] + for row in reader: + try: + if float(row[4]) > 900: + row[4] = "900" + if float(row[3]) > 900: + row[3] = "900" + if random.random() < 0.25: + newreader.append(row) + except: + newreader.append(row) + with open(output_file, "w") as f: + writer = csv.writer(f) + writer.writerows(newreader) + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) diff --git a/scripts/setup.sh b/scripts/setup.sh index cef1cbc..6f6243e 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -16,14 +16,14 @@ sudo chown -R ec2-user:ec2-user /mnt/tools/home/ec2-user sudo chown -R ec2-user:ec2-user /mnt/work curl https://nixos.org/nix/install | sh -. $HOME/.nix-profile/etc/profile.d/nix.sh { cat <<EOF +. $HOME/.nix-profile/etc/profile.d/nix.sh + export PATH="/mnt/tools/opt/yosys/master/bin:\${PATH}" export PATH="\${PATH}:/mnt/tools/bin" export PATH="\${PATH}:/mnt/tools/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64" export PATH="\${PATH}:/mnt/tools/opt/Xilinx/Vivado/2018.3/bin" +export AFL_PATH=/mnt/tools/lib/afl EOF } >> $HOME/.bashrc - -source $HOME/.bashrc diff --git a/scripts/size.py b/scripts/size.py index d6d7466..bd83862 100755 --- a/scripts/size.py +++ b/scripts/size.py @@ -14,7 +14,7 @@ def file_len(fname): def main(c, n): l = [] for x in range(0, n): - subprocess.call(["verifuzz", "generate", "-o", "main.v", "-c", c]) + subprocess.call(["verismith", "generate", "-o", "main.v", "-c", c]) l.append(file_len("main.v")) os.remove("main.v") print("mean: ", statistics.mean(l)) diff --git a/scripts/swarm.py b/scripts/swarm.py index 99b0c54..1441121 100755 --- a/scripts/swarm.py +++ b/scripts/swarm.py @@ -12,11 +12,11 @@ def main(): if not os.path.exists(directory): os.makedirs(directory) while True: - subprocess.call(["verifuzz", "config" + subprocess.call(["verismith", "config" , "-c", config , "-o", directory + "/config_medium_random.toml" , "--randomise"]) - subprocess.call([ "verifuzz", "fuzz" + subprocess.call([ "verismith", "fuzz" , "-o", directory + "/" + name + str(i) , "-c", directory + "/config_medium_random.toml" , "-n", str(iterations)]) |