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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/env python3
import os, sys
device = "u4k"
if not os.path.exists("./work_osc"):
os.mkdir("./work_osc")
def run(route_fabric):
name = "./work_osc/osc_cbit_fabric_%d" % route_fabric
with open(name+'.v',"w") as f:
print("""
module top(
input clkhfpu,
input clkhfen,
input clklfpu,
input clklfen,
output pin,
output pin2,
input data
);
wire clkhf;
SB_HFOSC #(
.CLKHF_DIV("%s")
) hfosc (
.CLKHFPU(clkhfpu),
.CLKHFEN(clkhfen),
.CLKHF(clkhf)
); /* synthesis ROUTE_THROUGH_FABRIC = %d */
SB_IO #(
.PIN_TYPE(6'b 0101_00)
) pin_obuf (
.PACKAGE_PIN(pin),
.OUTPUT_CLK(clkhf),
.D_OUT_0(data)
);
wire clklf;
SB_LFOSC lfosc (
.CLKLFPU(clklfpu),
.CLKLFEN(clklfen),
.CLKLF(clklf)
); /* synthesis ROUTE_THROUGH_FABRIC = %d */
SB_IO #(
.PIN_TYPE(6'b 0101_00)
) pin2_obuf (
.PACKAGE_PIN(pin2),
.OUTPUT_CLK(clklf),
.D_OUT_0(data)
);
endmodule
""" % (
"0b11", route_fabric, route_fabric
), file=f)
retval = os.system("bash ../../icecube.sh -" + device + " " + name+".v > ./work_osc/icecube.log 2>&1")
if retval != 0:
sys.stderr.write('ERROR: icecube returned non-zero error code\n')
sys.exit(1)
retval = os.system("../../../icebox/icebox_explain.py " + name+".asc > " + name+".exp")
if retval != 0:
sys.stderr.write('ERROR: icebox_explain returned non-zero error code\n')
sys.exit(1)
retval = os.system("../../../icebox/icebox_vlog.py " + name+".asc > " + name+".ve")
if retval != 0:
sys.stderr.write('ERROR: icebox_vlog returned non-zero error code\n')
sys.exit(1)
run(0)
run(1)
|