aboutsummaryrefslogtreecommitdiffstats
path: root/icefuzz/make_fanout.py
blob: 1102cc09b4890590cc43705f72c8e8ceba722965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3

from fuzzconfig import *
import numpy as np
import os

os.system("rm -rf work_fanout")
os.mkdir("work_fanout")

for idx in range(num):
    with open("work_fanout/fanout_%02d.v" % idx, "w") as f:
        if os.getenv('ICE384PINS'):
            print("module top(input [1:0] a, output [15:0] y);", file=f)
            print("  assign y = {8{a}};", file=f)
        else:
            print("module top(input [1:0] a, output [63:0] y);", file=f)
            print("  assign y = {32{a}};", file=f)
        print("endmodule", file=f)
    with open("work_fanout/fanout_%02d.pcf" % idx, "w") as f:
        p = np.random.permutation(pins)
        r = 16 if os.getenv('ICE384PINS') else 64
        for i in range(r):
            print("set_io y[%d] %s" % (i, p[i]), file=f)
        print("set_io a[0] %s" % p[r], file=f)
        print("set_io a[1] %s" % p[r+1], file=f)

with open("work_fanout/Makefile", "w") as f:
    print("all: %s" % " ".join(["fanout_%02d.bin" % i for i in range(num)]), file=f)
    for i in range(num):
        print("fanout_%02d.bin:" % i, file=f)
        print("\t-bash ../icecube.sh fanout_%02d > fanout_%02d.log 2>&1 && rm -rf fanout_%02d.tmp || tail fanout_%02d.log" % (i, i, i, i), file=f)