Raw data file
/raw_data - This is the file which was parsed, it shows the 128 main ascii characters in binary pixel representation, the ascii characters can be found here - http://www.lookuptables.com/
Parser
The following script was used to parse the .coe file with the binary representation of each ascii character:
#!/usr/bin/python
import sys,os,os.path,traceback
mname = 'font'
# read in memory contents
coename = mname + ".coe"
if not os.path.exists(coename):
print "Oops: can't find %s" % coename
sys.exit(0)
try:
f = open(coename)
contents = f.read() # read in entire file
f.close()
except Exception,e:
print "Oops:",e
sys.exit(0)
contents = contents.replace(',','')
contents = contents.replace(';','')
characters = []
character = ''
for line in contents:
try:
if line == '\n': continue
character += line
if (len(character) == 96):
characters.append(character)
character = ''
except Exception,e:
print "Oops: error reading location",(len(characters)+1),": ",e
sys.exit(0)
print characters
# ready to create appropriate Verilog module
try:
vname = 'font.v'
v = open(vname,'w')
# output standard module prologue
v.write("""// 8x12 font memory for 128 chars
module font(ascii, pixel_rep);
input [7:0] ascii;
output reg [95:0] pixel_rep;
always @ (ascii) begin
case (ascii)
""")
dec = 0
for character in characters:
v.write("""
%s : pixel_rep <= 96'b%s;
""" % (dec, character))
#if (dec < 10):
# v.write("""
# 1'd%s : pixel_rep <= 96'b%s;
# """ % (dec, character))
#if (dec < 100 and dec > 9):
# v.write("""
# 2'd%s : pixel_rep <= 96'b%s;
# """ % (dec, character))
#if (dec > 99):
# v.write("""
# 3'd%s : pixel_rep <= 96'b%s;
# """ % (dec, character))
dec += 1
# dec will end before characters does
v.write("""
endcase // case(ascii)
end // always @ (ascii)
endmodule // font
""")
except Exception,e:
print "Oops:",e
sys.exit(0)