examples/versa5g: Improved make_14seg.py from @ldoolitt
Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/examples/versa5g/make_14seg.py b/examples/versa5g/make_14seg.py
index f31ee5b..da6b234 100644
--- a/examples/versa5g/make_14seg.py
+++ b/examples/versa5g/make_14seg.py
@@ -1,6 +1,7 @@
import sys
# From http://www.plusea.at/downloads/print/AllMySegment-handout.pdf
-# NB odd numbering
+# and https://en.wikipedia.org/wiki/File:14_Segment_LCD_characters.jpg
+# N.B. segment labeling as documented in Versa Dev Board User Guide (schematic)
font = {
"A": ['e', 'f', 'a', 'b', 'c', 'p', 'k'],
"B": ['e', 'f', 'a', 'j', 'p', 'l', 'd'],
@@ -28,15 +29,26 @@
"X": ['g', 'l', 'n', 'j'],
"Y": ['g', 'j', 'm'],
"Z": ['a', 'j', 'n', 'd'],
+ "0": ['e', 'f', 'a', 'b', 'c', 'd'],
+ "1": ['j', 'b', 'c'],
+ "2": ['a', 'b', 'k', 'p', 'e', 'd'],
+ "3": ['a', 'b', 'k', 'c', 'd'],
+ "4": ['f', 'p', 'k', 'b', 'c'],
+ "5": ['a', 'f', 'p', 'k', 'c', 'd'],
+ "6": ['a', 'f', 'e', 'd', 'c', 'k', 'p'],
+ "7": ['a', 'j', 'n'],
+ "8": ['a', 'b', 'c', 'd', 'e', 'f', 'p', 'k'],
+ "9": ['a', 'b', 'c', 'f', 'p', 'k'],
" ": [],
"\n": []
}
seg_names = "abcdefghjklmnp"
text = sys.stdin.read()
-print (" localparam pat_len = {};".format(len(text)))
-print (" wire [13:0] display_pat[0:pat_len-1];")
+print(" localparam pat_len = {};".format(len(text)))
+print(" wire [13:0] display_pat[0:pat_len-1];")
for i in range(len(text)):
segs = font[text[i]]
+ comment = " // {}".format(text[i]) if segs else ""
bits = [(seg_names[k] in segs) for k in range(14)]
- bit_lit = "14'b{}".format("".join(reversed(["1" if b else "0" for b in bits])))
- print (" assign display_pat[{}] = {};".format(i, bit_lit))
\ No newline at end of file
+ bit_lit = "14'b" + "".join(reversed(["1" if b else "0" for b in bits]))
+ print(" assign display_pat[{}] = {};{}".format(i, bit_lit, comment))