icebox: Put .hlc converters under ISC license

This commit is contained in:
Roland Lutz 2017-09-02 14:45:03 +02:00
commit c9c181fef2
6 changed files with 2403 additions and 1 deletions

View File

@ -18,6 +18,11 @@ chipdb-8k.txt: icebox.py iceboxdb.py icebox_chipdb.py
python3 icebox_chipdb.py -8 > chipdb-8k.new
mv chipdb-8k.new chipdb-8k.txt
check: all
python3 tc_xlat_netnames.py
python3 tc_rxlat_netnames.py
python3 tc_logic_xpr.py
clean:
rm -f chipdb-1k.txt chipdb-8k.txt chipdb-384.txt chipdb-5k.txt
rm -f icebox.pyc iceboxdb.pyc
@ -33,6 +38,8 @@ install: all
cp icebox_chipdb.py $(DESTDIR)$(PREFIX)/bin/icebox_chipdb$(PY_EXE)
cp icebox_diff.py $(DESTDIR)$(PREFIX)/bin/icebox_diff$(PY_EXE)
cp icebox_explain.py $(DESTDIR)$(PREFIX)/bin/icebox_explain$(PY_EXE)
cp icebox_asc2hlc.py $(DESTDIR)$(PREFIX)/bin/icebox_asc2hlc$(PY_EXE)
cp icebox_hlc2asc.py $(DESTDIR)$(PREFIX)/bin/icebox_hlc2asc$(PY_EXE)
cp icebox_colbuf.py $(DESTDIR)$(PREFIX)/bin/icebox_colbuf$(PY_EXE)
cp icebox_html.py $(DESTDIR)$(PREFIX)/bin/icebox_html$(PY_EXE)
cp icebox_maps.py $(DESTDIR)$(PREFIX)/bin/icebox_maps$(PY_EXE)
@ -45,6 +52,8 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_chipdb$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_diff$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_explain$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_asc2hlc$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_hlc2asc$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_colbuf$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_html$(PY_EXE)
rm -f $(DESTDIR)$(PREFIX)/bin/icebox_maps$(PY_EXE)
@ -55,4 +64,4 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/share/icebox/chipdb-8k.txt
-rmdir $(DESTDIR)$(PREFIX)/share/icebox
.PHONY: all clean install uninstall
.PHONY: all check clean install uninstall

1134
icebox/icebox_asc2hlc.py Executable file

File diff suppressed because it is too large Load Diff

1063
icebox/icebox_hlc2asc.py Executable file

File diff suppressed because it is too large Load Diff

44
icebox/tc_logic_xpr.py Normal file
View File

@ -0,0 +1,44 @@
# Test case for `icebox_asc2hlc' and `icebox_hlc2asc': Does conversion
# from LUT strings to logic expressions and back work correctly?
# Copyright (C) 2017 Roland Lutz
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import sys
import icebox
from icebox_asc2hlc import lut_to_logic_expression
from icebox_hlc2asc import logic_expression_to_lut
def main():
sys.stderr.write("testing conversion from LUT strings "
"to logic expressions and back")
for i in range(65536):
if i % 4096 == 0:
sys.stderr.write(".")
sys.stderr.flush()
lut = bin(i)[2:].zfill(16)
s = lut_to_logic_expression(lut, ('a', 'b', 'c', 'd'))
l = logic_expression_to_lut(s, ('a', 'b', 'c', 'd'))
if l != lut:
sys.stderr.write("\nERROR at LUT = %s\n" % lut)
sys.stderr.write("stringified = %s\n" % s)
sys.stderr.write("resulting LUT = %s\n" % l)
sys.exit(1)
sys.stderr.write("\n")
if __name__ == '__main__':
main()

View File

@ -0,0 +1,71 @@
# Test case for `icebox_hlc2asc': Does net name translation work correctly?
# Copyright (C) 2017 Roland Lutz
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import sys
import icebox
from icebox_asc2hlc import translate_netname
from icebox_hlc2asc import untranslate_netname
def test_netname_translation(ic):
sys.stderr.write("testing backward netname translation "
"for the `%s' device...\n" % ic.device)
all_tiles = set()
for x in range(ic.max_x + 1):
for y in range(ic.max_y + 1):
if ic.tile(x, y) is not None:
all_tiles.add((x, y))
netnames = set()
failed = False
for group in ic.group_segments(all_tiles, connect_gb = False):
is_span = set(net.startswith('sp') for x, y, net in group)
assert len(is_span) == 1
if True not in is_span:
# only span nets are interesting here
continue
netname = translate_netname(group[0][0], group[0][1],
ic.max_x - 1, ic.max_y - 1, group[0][2])
if netname in netnames:
failed = True
print("duplicate netname: %s" % netname)
netnames.add(netname)
for x, y, net in group:
s = untranslate_netname(x, y, ic.max_x - 1, ic.max_y - 1, netname)
if s != net:
failed = True
print("%-20s %s -> %s" % ("%d %d %s" % (x, y, net), netname, s))
if failed:
sys.stderr.write("ERROR\n")
sys.exit(1)
def main():
ic = icebox.iceconfig()
ic.setup_empty_384()
test_netname_translation(ic)
ic = icebox.iceconfig()
ic.setup_empty_1k()
test_netname_translation(ic)
ic = icebox.iceconfig()
ic.setup_empty_8k()
test_netname_translation(ic)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,81 @@
# Test case for `icebox_asc2hlc': Does net name translation work correctly?
# Copyright (C) 2017 Roland Lutz
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import sys
import icebox
from icebox_asc2hlc import translate_netname
def test_netname_translation(ic):
sys.stderr.write("testing forward netname translation "
"for the `%s' device...\n" % ic.device)
all_tiles = set()
for x in range(ic.max_x + 1):
for y in range(ic.max_y + 1):
if ic.tile(x, y) is not None:
all_tiles.add((x, y))
netnames = set()
failed = False
for group in ic.group_segments(all_tiles, connect_gb = False):
is_span = set(net.startswith('sp') for x, y, net in group)
assert len(is_span) == 1
if True not in is_span:
# only span nets are interesting here
continue
s = set()
for seg in group:
s.add(translate_netname(seg[0], seg[1],
ic.max_x - 1, ic.max_y - 1, seg[2]))
if len(s) != 1:
failed = True
print("translated netnames don't match")
for seg in group:
print("%d %d %s" % seg, "->",
translate_netname(seg[0], seg[1],
ic.max_x - 1, ic.max_y - 1, seg[2]))
print()
for dulpicate_netname in netnames.intersection(s):
failed = True
print("duplicate netname: %s" % dulpicate_netname)
for seg in group:
print("%d %d %s" % seg, "->",
translate_netname(seg[0], seg[1],
ic.max_x - 1, ic.max_y - 1, seg[2]))
print()
netnames.update(s)
if failed:
sys.stderr.write("ERROR\n")
sys.exit(1)
def main():
ic = icebox.iceconfig()
ic.setup_empty_384()
test_netname_translation(ic)
ic = icebox.iceconfig()
ic.setup_empty_1k()
test_netname_translation(ic)
ic = icebox.iceconfig()
ic.setup_empty_8k()
test_netname_translation(ic)
if __name__ == '__main__':
main()