From 7377b2e83143fc45f83b0abc974aafbf6b6a3dfe Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 18 Sep 2019 19:06:44 +0200 Subject: Add more scripts --- scripts/config.toml | 40 ++++++++++++++++++++ scripts/main.v | 27 ++++++++++++++ scripts/parallelsets.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/scale.py | 26 +++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 scripts/config.toml create mode 100644 scripts/main.v create mode 100755 scripts/parallelsets.py create mode 100755 scripts/scale.py diff --git a/scripts/config.toml b/scripts/config.toml new file mode 100644 index 0000000..edc094d --- /dev/null +++ b/scripts/config.toml @@ -0,0 +1,40 @@ + +[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 = 5 + moditem.combinational = 1 + moditem.instantiation = 1 + moditem.sequential = 1 + statement.blocking = 0 + statement.conditional = 1 + statement.forloop = 0 + statement.nonblocking = 3 + +[property] + module.depth = 2 + module.max = 1 + size = 10 + statement.depth = 3 + +[[synthesiser]] + description = "yosys" + name = "yosys" + output = "syn_yosys.v" + +[[synthesiser]] + description = "vivado" + name = "vivado" + output = "syn_vivado.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/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]) -- cgit