2 """converts NIOLIB and NSXLIB from VBE into VHDL
8 # use the chroot to set up
9 # https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=coriolis2-chroot;hb=HEAD
10 # reason for using the chroot: it's standardised across the ls180 project
12 VASY_CMD
= "schroot -c coriolis -d /tmp -- ~/alliance/install/bin/vasy"
13 ALLIANCEBASE
= "../alliance-check-toolkit/cells"
14 ALLIANCE_LIBS
= ['nsxlib', 'niolib']
16 yosys_ghdl_template
= "ghdl --std=08 -g %s\n"
17 yosys_ghdl_footer
= """proc
22 for libname
in ALLIANCE_LIBS
:
24 NSXLIB
= "%s/%s" % (ALLIANCEBASE
, libname
)
26 os
.system("mkdir -p %s" % libname
)
28 # yosys ghdl loader script
29 ghdl_txt
= "plugin -i ghdl\n"
31 for fname
in os
.listdir(NSXLIB
):
32 if not fname
.endswith(".vbe"):
35 prefix
= fname
[:-4] # strip ".vbe"
36 os
.system("cp %s/%s /tmp" % (NSXLIB
, fname
))
37 os
.system("rm -f /tmp/%s.vhd" % (prefix
))
38 os
.system("%s -s -I vbe %s %s" % (VASY_CMD
, fname
, prefix
))
39 os
.system("cp /tmp/%s.vhd %s" % (prefix
, libname
))
40 # add loader template for this module
41 if fname
== 'sff1r_x4.vbe':
43 #ghdl_txt += 'read_verilog freepdk_45/sff1r_x4.v\n'
44 os
.system("cp freepdk_45/%s.vhd %s" % (prefix
, libname
))
45 ghdl_txt
+= yosys_ghdl_template
% prefix
47 ghdl_txt
+= yosys_ghdl_footer
% (libname
, libname
)
49 # write out the ghdl script
50 fname
= "%s/ghdl.ys" % libname
51 print ("text to %s\n" % fname
, ghdl_txt
)
52 with
open(fname
, "w") as f
: