2015-08-22 09:36:28 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-07-18 13:10:40 +02:00
|
|
|
|
|
|
|
|
from fuzzconfig import *
|
|
|
|
|
import numpy as np
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
os.system("rm -rf work_io")
|
|
|
|
|
os.mkdir("work_io")
|
|
|
|
|
|
2017-06-23 02:38:38 +02:00
|
|
|
w = num_iobanks
|
2017-03-07 22:39:04 +01:00
|
|
|
|
2015-07-18 13:10:40 +02:00
|
|
|
for idx in range(num):
|
|
|
|
|
with open("work_io/io_%02d.v" % idx, "w") as f:
|
2015-08-22 09:36:28 +02:00
|
|
|
glbs = np.random.permutation(list(range(8)))
|
2015-07-18 13:10:40 +02:00
|
|
|
print("""
|
|
|
|
|
module top (
|
2017-03-07 22:39:04 +01:00
|
|
|
inout [%s:0] pin,
|
|
|
|
|
input [%s:0] latch_in,
|
|
|
|
|
input [%s:0] clk_en,
|
|
|
|
|
input [%s:0] clk_in,
|
|
|
|
|
input [%s:0] clk_out,
|
|
|
|
|
input [%s:0] oen,
|
|
|
|
|
input [%s:0] dout_0,
|
|
|
|
|
input [%s:0] dout_1,
|
|
|
|
|
output [%s:0] din_0,
|
|
|
|
|
output [%s:0] din_1
|
2015-07-18 13:10:40 +02:00
|
|
|
);
|
|
|
|
|
SB_IO #(
|
|
|
|
|
.PIN_TYPE(6'b %s_%s),
|
|
|
|
|
.PULLUP(1'b %s),
|
|
|
|
|
.NEG_TRIGGER(1'b %s),
|
|
|
|
|
.IO_STANDARD("SB_LVCMOS")
|
2017-03-07 22:39:04 +01:00
|
|
|
) PINS [%s:0] (
|
2015-07-18 13:10:40 +02:00
|
|
|
.PACKAGE_PIN(pin),
|
|
|
|
|
.LATCH_INPUT_VALUE(latch_in),
|
|
|
|
|
.CLOCK_ENABLE(clk_en),
|
|
|
|
|
.INPUT_CLK(clk_in),
|
|
|
|
|
.OUTPUT_CLK(clk_out),
|
|
|
|
|
.OUTPUT_ENABLE(oen),
|
|
|
|
|
.D_OUT_0(dout_0),
|
|
|
|
|
.D_OUT_1(dout_1),
|
|
|
|
|
.D_IN_0(din_0),
|
|
|
|
|
.D_IN_1(din_1)
|
|
|
|
|
);
|
|
|
|
|
endmodule
|
|
|
|
|
""" % (
|
2017-03-07 22:39:04 +01:00
|
|
|
w-1, w-1, w-1, w-1, w-1, w-1, w-1, w-1, w-1, w-1,
|
2015-07-18 13:10:40 +02:00
|
|
|
np.random.choice(["0000", "0110", "1010", "1110", "0101", "1001", "1101", "0100", "1000", "1100", "0111", "1111"]),
|
2017-03-07 22:39:04 +01:00
|
|
|
np.random.choice(["00", "01", "10", "11"]), np.random.choice(["0", "1"]), np.random.choice(["0", "1"]), w-1
|
2015-07-18 13:10:40 +02:00
|
|
|
), file=f)
|
|
|
|
|
with open("work_io/io_%02d.pcf" % idx, "w") as f:
|
|
|
|
|
p = list(np.random.permutation(pins))
|
|
|
|
|
for k in ["pin", "latch_in", "clk_en", "clk_in", "clk_out", "oen", "dout_0", "dout_1", "din_0", "din_1"]:
|
2017-03-07 22:39:04 +01:00
|
|
|
for i in range(w):
|
2015-07-18 13:10:40 +02:00
|
|
|
print("set_io %s[%d] %s" % (k, i, p.pop()), file=f)
|
|
|
|
|
|
|
|
|
|
with open("work_io/Makefile", "w") as f:
|
|
|
|
|
print("all: %s" % " ".join(["io_%02d.bin" % i for i in range(num)]), file=f)
|
|
|
|
|
for i in range(num):
|
|
|
|
|
print("io_%02d.bin:" % i, file=f)
|
|
|
|
|
print("\t-bash ../icecube.sh io_%02d > io_%02d.log 2>&1 && rm -rf io_%02d.tmp || tail io_%02d.log" % (i, i, i, i), file=f)
|