#.hexファイルを読んで、命令をidram.vhdの分散RAMの初期値として書き込む
def usage
STDERR.print "usage : #$0 [input .hex file name] [output init_idram.txt file] \n"
exit 1
end
if ARGV.size < 2
usage
else
mem_data = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
file = File.open(ARGV[0], 'r')
while line=file.gets
if line[0, 1] == ':' then # intel hex code
max = line[1,2].hex
address = (line[3,4].hex)/4
if line[7,2] == "00" then # normal data record
for i in 1..max/4 do
mem_data[address] = line[9+(i-1)*8,8].hex
address += 1
end
end
end
end
file.close
## mem_data.each do |i|
## printf("%0.8X", *i)
## print "\n"
# end
init_data_file = File.open(ARGV[1], 'w') # RAMの初期化データファイルを出力でオープン
i = 0
while i < mem_data.size
init_data_file.printf("%.8X\r\n", *mem_data[i])
i += 1
end
init_data_file.close
end
ocra-1.2.0 Documentation
rubyforge.org/projects/ocra
github.com/larsch/ocra
..\Ruby-1.9.1-p378\bin\ruby.exe ocrasa.rb inst_load_hex.rb
inst_load_hex.exe disp_test2.hex init_idram.txt
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 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 | - | - | - | - | - | - |