FC2ブログ

[LM32].mem to Intel-Hex変換Ruby

Lattice MicoSystemBuilder(MSB)のSW開発ウィンドウにおいて、Software Deploymentを実行すると、
hex形式と指定出来るものの、生成された.memファイルは、16進数のプログラムデータの羅列。

一方、アルテラメモリで扱えるIntel-HEX形式はもう少し複雑。

Latticeからアルテラのメモリ初期値ファイルの橋渡しとして、変換Rubyを作成した。
altsyncramが読み込めるのは確認したが、正しく変換出来ているかはこれから確認。

(2014.9.14追記)
Intel-HEX形式の理解間違えていたので変換Ruby修正。
データの長さの部分を文字数として長さ書いていたが、これはByte数との事。
また、以前QuartusIIが自動生成した.hex見た時に1行に32bit(=4byte)x4のデータ書かれていた。
これを真似したが、.hexをaltsyncramが読み込んで.verを自動生成する時、正しくメモリ初期値が格納されてなかった。
1行に32bit(4byte)づつ書くやり方で作ったら正しく変換された模様。


print "START: ",Time.now,"\n"

file_in, file_out = ARGV

hex_file = File::open(file_out, "a")

record_type = "00"
adr_cnt = 0

line_data = ""
File.foreach(file_in) do |line|
line_data = line_data + line.chomp

# data byte num = 0x04 = 4byte
data_length = "04"

address = "%04X" % adr_cnt

#---------------------------------------------
# calculate check sum
#---------------------------------------------
str_for_chksum = data_length + address + record_type + line_data
sum = 0
while (str_for_chksum.size != 0)
temp = str_for_chksum.slice!(0,2)
sum = sum + temp.hex
end
hex_under_2bit = sum.to_s(16).slice(-2, 2)
dec_under_2bit = hex_under_2bit.hex
chksum_temp = "%02X" % (256 - dec_under_2bit)
chksum = chksum_temp.slice(-2,2)

#---------------------------------------------
# output to file
#---------------------------------------------
hex_file.print ":", data_length, address, record_type, line_data, chksum, "\n"
adr_cnt = adr_cnt + 1
end

# 2014.9.22追記 Intel-HEX用最終行のレコードが抜けてたので以下追記。
hex_file.print ":00000001FF"

hex_file.close

print "END : ",Time.now,"\n"



<上のRubyに入力する元.mem>
98000000
d0000000
d0200000
78010000
38210000
d0e10000
f800003a
34000000
90e03800
34e70020
c0e00000
  :
00000020
00000001
00000001
00000000
00000020
00000000
00000000
00000000
00000000
00000000
00000000
00000000
<最終行=714行>


<.memからRubyで変換された.hex>
:040000009800000064
:04000100d00000002B
:04000200d02000000A
:040003007801000080
:04000400382100009F
:04000500d0e1000046
:04000600f800003aC4
:0400070034000000C1
:0400080090e038004C
  :
:0402BD00000000003D
:0402BE00000000201C
:0402BF00000000013A
:0402C0000000000139
:0402C1000000000039
:0402C2000000002018
:0402C3000000000037
:0402C4000000000036
:0402C5000000000035
:0402C6000000000034
:0402C7000000000033
:0402C8000000000032
:0402C9000000000031
:00000001FF → 2014.9.22 Intel-HEX用最終行が抜けてたのでRubyに加えここに追記。
<最終行=714行>


<Ruby変換後の.hexからaltsyncramが自動生成した.ver>
@0
98000000
@1
d0000000
@2
d0200000
@3
78010000
@4
38210000
@5
d0e10000
@6
f800003a
@7
34000000
@8
90e03800
@9
34e70020
@a
c0e00000
@b
34000000
@c
34000000
@d
34000000
@e
34000000
@f
34000000
  :
@2ba
00000001
@2bb
00000000
@2bc
00000000
@2bd
00000000
@2be
00000020
@2bf
00000001
@2c0
00000001
@2c1
00000000
@2c2
00000020
@2c3
00000000
@2c4
00000000
@2c5
00000000
@2c6
00000000
@2c7
00000000
@2c8
00000000
@2c9
00000000
<最終行=1428行(アドレスとデータ別行でちょうど714の倍)>



Latticeメモリからアルテラメモリへ置き換えるために、
Lattice生成.memから.hex(Intel-HEX)へ変換して、
LEDチカチカのシミュレーションはアルテラメモリでも動いた。
しかし、チカチカ開始の時間が違う。

っと記事書いてたら、時間全く同じだな。
Latticeの方は4.3msあたりでチカチカしてたと記憶してたので、以下の記事書いてしまった。
もったいないので、そのまま残しておく。

Latticeメモリ=592501ns
アルテラメモリ=592501ns

プログラムメモリebrの信号ダンプは以下でやっているが、Latticeメモリの時とは211行目以降で
EBR_DAT_Oに違いが出るが、LatticeはXであるのに対してアルテラは0が出力されてる。
オリジナルがX不定なので、不定が0になっても動作に問題は無いと思うが、ここがチカチカ開始
異なる原因か??(上記の通り動作同じでした)

always begin
@(negedge tb.uut.clk_i );
if (start) begin
#1 $fdisplay(W_OVEC1, "%t %h %h %h %h %h %h %h %h %h %h"
, $time
, tb.uut.reset_n
, tb.uut.ebr.EBR_WE_I
, tb.uut.ebr.EBR_CYC_I
, tb.uut.ebr.EBR_STB_I
, tb.uut.ebr.EBR_SEL_I
, tb.uut.ebr.EBR_CTI_I
, tb.uut.ebr.EBR_BTE_I
, tb.uut.ebr.EBR_ADR_I
, tb.uut.ebr.EBR_DAT_I
, tb.uut.ebr.EBR_DAT_O





TkDiff 4.2 report

File A: tb.dump.lattice_ram_ok
File B: tb.dump.altera_ram_ok

number of diffs: 85
0 regions were deleted
1 regions were added
84 regions were changed


1 P3 1 P3
2 # Created by tb_DE2_115 Simulation output file 2 # Created by tb_DE2_115 Simulation output file
3 640 600 3 640 600
4 255 4 255
5 + 1000 0 x x x x x 0 xxxxxxxx xxxxxxxx 00000000
5 201000 0 0 0 0 0 0 0 00000000 00000000 00000000 6 201000 0 0 0 0 0 0 0 00000000 00000000 00000000
6 401000 0 0 0 0 0 0 0 00000000 00000000 00000000 7 401000 0 0 0 0 0 0 0 00000000 00000000 00000000
7 601000 0 0 0 0 0 0 0 00000000 00000000 00000000 8 601000 0 0 0 0 0 0 0 00000000 00000000 00000000
8 801000 0 0 0 0 0 0 0 00000000 00000000 00000000 9 801000 0 0 0 0 0 0 0 00000000 00000000 00000000
9 1001000 1 0 0 0 0 0 0 00000000 00000000 00000000 10 1001000 1 0 0 0 0 0 0 00000000 00000000 00000000
10 1201000 1 0 0 0 0 0 0 00000000 00000000 00000000 11 1201000 1 0 0 0 0 0 0 00000000 00000000 00000000
11 1401000 1 0 0 0 0 0 0 00000000 00000000 00000000 12 1401000 1 0 0 0 0 0 0 00000000 00000000 00000000
12 1601000 1 0 0 0 0 0 0 00000000 00000000 00000000 13 1601000 1 0 0 0 0 0 0 00000000 00000000 00000000
13 1801000 1 0 0 0 0 0 0 00000000 00000000 00000000 14 1801000 1 0 0 0 0 0 0 00000000 00000000 00000000
14 2001000 1 0 0 0 0 0 0 00000000 00000000 98000000 15 2001000 1 0 0 0 0 0 0 00000000 00000000 98000000
15 2201000 1 0 1 1 f 7 0 00000000 00000000 98000000 16 2201000 1 0 1 1 f 7 0 00000000 00000000 98000000
16 2401000 1 0 1 1 f 7 0 00000000 00000000 98000000 17 2401000 1 0 1 1 f 7 0 00000000 00000000 98000000
17 2601000 1 0 0 0 0 0 0 00000000 00000000 d0000000 18 2601000 1 0 0 0 0 0 0 00000000 00000000 d0000000
18 2801000 1 0 0 0 0 0 0 00000000 00000000 98000000 19 2801000 1 0 0 0 0 0 0 00000000 00000000 98000000
19 3001000 1 0 1 1 f 7 0 00000004 00000000 98000000 20 3001000 1 0 1 1 f 7 0 00000004 00000000 98000000
20 3201000 1 0 1 1 f 7 0 00000004 00000000 d0000000 21 3201000 1 0 1 1 f 7 0 00000004 00000000 d0000000
21 3401000 1 0 0 0 0 0 0 00000000 00000000 d0200000 22 3401000 1 0 0 0 0 0 0 00000000 00000000 d0200000
22 3601000 1 0 0 0 0 0 0 00000000 00000000 98000000 23 3601000 1 0 0 0 0 0 0 00000000 00000000 98000000
23 3801000 1 0 1 1 f 7 0 00000008 00000000 98000000 24 3801000 1 0 1 1 f 7 0 00000008 00000000 98000000
24 4001000 1 0 1 1 f 7 0 00000008 00000000 d0200000 25 4001000 1 0 1 1 f 7 0 00000008 00000000 d0200000
25 4201000 1 0 0 0 0 0 0 00000000 00000000 78010000 26 4201000 1 0 0 0 0 0 0 00000000 00000000 78010000
26 4401000 1 0 0 0 0 0 0 00000000 00000000 98000000 27 4401000 1 0 0 0 0 0 0 00000000 00000000 98000000
27 4601000 1 0 1 1 f 7 0 0000000c 00000000 98000000 28 4601000 1 0 1 1 f 7 0 0000000c 00000000 98000000
28 4801000 1 0 1 1 f 7 0 0000000c 00000000 78010000 29 4801000 1 0 1 1 f 7 0 0000000c 00000000 78010000
29 5001000 1 0 0 0 0 0 0 00000000 00000000 38210000 30 5001000 1 0 0 0 0 0 0 00000000 00000000 38210000
30 5201000 1 0 0 0 0 0 0 00000000 00000000 98000000 31 5201000 1 0 0 0 0 0 0 00000000 00000000 98000000
31 5401000 1 0 1 1 f 7 0 00000010 00000000 98000000 32 5401000 1 0 1 1 f 7 0 00000010 00000000 98000000
32 5601000 1 0 1 1 f 7 0 00000010 00000000 38210000 33 5601000 1 0 1 1 f 7 0 00000010 00000000 38210000
33 5801000 1 0 0 0 0 0 0 00000000 00000000 d0e10000 34 5801000 1 0 0 0 0 0 0 00000000 00000000 d0e10000
34 6001000 1 0 0 0 0 0 0 00000000 00000000 98000000 35 6001000 1 0 0 0 0 0 0 00000000 00000000 98000000
35 6201000 1 0 1 1 f 7 0 00000014 00000000 98000000 36 6201000 1 0 1 1 f 7 0 00000014 00000000 98000000
36 6401000 1 0 1 1 f 7 0 00000014 00000000 d0e10000 37 6401000 1 0 1 1 f 7 0 00000014 00000000 d0e10000
37 6601000 1 0 0 0 0 0 0 00000000 00000000 f800003a 38 6601000 1 0 0 0 0 0 0 00000000 00000000 f800003a
38 6801000 1 0 0 0 0 0 0 00000000 00000000 98000000 39 6801000 1 0 0 0 0 0 0 00000000 00000000 98000000
39 7001000 1 0 1 1 f 7 0 00000018 00000000 98000000 40 7001000 1 0 1 1 f 7 0 00000018 00000000 98000000
40 7201000 1 0 1 1 f 7 0 00000018 00000000 f800003a 41 7201000 1 0 1 1 f 7 0 00000018 00000000 f800003a
41 7401000 1 0 0 0 0 0 0 00000000 00000000 34000000 42 7401000 1 0 0 0 0 0 0 00000000 00000000 34000000
42 7601000 1 0 0 0 0 0 0 00000000 00000000 98000000 43 7601000 1 0 0 0 0 0 0 00000000 00000000 98000000
43 7801000 1 0 1 1 f 7 0 0000001c 00000000 98000000 44 7801000 1 0 1 1 f 7 0 0000001c 00000000 98000000
44 8001000 1 0 1 1 f 7 0 0000001c 00000000 34000000 45 8001000 1 0 1 1 f 7 0 0000001c 00000000 34000000
45 8201000 1 0 0 0 0 0 0 00000000 00000000 90e03800 46 8201000 1 0 0 0 0 0 0 00000000 00000000 90e03800
46 8401000 1 0 0 0 0 0 0 00000000 00000000 98000000 47 8401000 1 0 0 0 0 0 0 00000000 00000000 98000000
47 8601000 1 0 1 1 f 7 0 00000020 00000000 98000000 48 8601000 1 0 1 1 f 7 0 00000020 00000000 98000000
48 8801000 1 0 1 1 f 7 0 00000020 00000000 90e03800 49 8801000 1 0 1 1 f 7 0 00000020 00000000 90e03800
49 9001000 1 0 0 0 0 0 0 00000000 00000000 34e70020 50 9001000 1 0 0 0 0 0 0 00000000 00000000 34e70020
50 9201000 1 0 0 0 0 0 0 00000000 00000000 98000000 51 9201000 1 0 0 0 0 0 0 00000000 00000000 98000000
51 9401000 1 0 1 1 f 7 0 00000024 00000000 98000000 52 9401000 1 0 1 1 f 7 0 00000024 00000000 98000000
52 9601000 1 0 1 1 f 7 0 00000024 00000000 34e70020 53 9601000 1 0 1 1 f 7 0 00000024 00000000 34e70020
53 9801000 1 0 0 0 0 0 0 00000000 00000000 c0e00000 54 9801000 1 0 0 0 0 0 0 00000000 00000000 c0e00000
54 10001000 1 0 0 0 0 0 0 00000000 00000000 98000000 55 10001000 1 0 0 0 0 0 0 00000000 00000000 98000000
55 10201000 1 0 1 1 f 7 0 00000100 00000000 98000000 56 10201000 1 0 1 1 f 7 0 00000100 00000000 98000000
56 10401000 1 0 1 1 f 7 0 00000100 00000000 98000000 57 10401000 1 0 1 1 f 7 0 00000100 00000000 98000000
57 10601000 1 0 0 0 0 0 0 00000000 00000000 781c0000 58 10601000 1 0 0 0 0 0 0 00000000 00000000 781c0000
58 10801000 1 0 0 0 0 0 0 00000000 00000000 98000000 59 10801000 1 0 0 0 0 0 0 00000000 00000000 98000000
59 11001000 1 0 1 1 f 7 0 00000104 00000000 98000000 60 11001000 1 0 1 1 f 7 0 00000104 00000000 98000000
60 11201000 1 0 1 1 f 7 0 00000104 00000000 781c0000 61 11201000 1 0 1 1 f 7 0 00000104 00000000 781c0000
61 11401000 1 0 0 0 0 0 0 00000000 00000000 3b9c3ffc 62 11401000 1 0 0 0 0 0 0 00000000 00000000 3b9c3ffc
62 11601000 1 0 0 0 0 0 0 00000000 00000000 98000000 63 11601000 1 0 0 0 0 0 0 00000000 00000000 98000000
63 11801000 1 0 1 1 f 7 0 00000108 00000000 98000000 64 11801000 1 0 1 1 f 7 0 00000108 00000000 98000000
64 12001000 1 0 1 1 f 7 0 00000108 00000000 3b9c3ffc 65 12001000 1 0 1 1 f 7 0 00000108 00000000 3b9c3ffc
65 12201000 1 0 0 0 0 0 0 00000000 00000000 781a0000 66 12201000 1 0 0 0 0 0 0 00000000 00000000 781a0000
66 12401000 1 0 0 0 0 0 0 00000000 00000000 98000000 67 12401000 1 0 0 0 0 0 0 00000000 00000000 98000000
67 12601000 1 0 1 1 f 7 0 0000010c 00000000 98000000 68 12601000 1 0 1 1 f 7 0 0000010c 00000000 98000000
68 12801000 1 0 1 1 f 7 0 0000010c 00000000 781a0000 69 12801000 1 0 1 1 f 7 0 0000010c 00000000 781a0000
69 13001000 1 0 0 0 0 0 0 00000000 00000000 3b5a8b20 70 13001000 1 0 0 0 0 0 0 00000000 00000000 3b5a8b20
70 13201000 1 0 0 0 0 0 0 00000000 00000000 98000000 71 13201000 1 0 0 0 0 0 0 00000000 00000000 98000000
71 13401000 1 0 1 1 f 7 0 00000110 00000000 98000000 72 13401000 1 0 1 1 f 7 0 00000110 00000000 98000000
72 13601000 1 0 1 1 f 7 0 00000110 00000000 3b5a8b20 73 13601000 1 0 1 1 f 7 0 00000110 00000000 3b5a8b20
73 13801000 1 0 0 0 0 0 0 00000000 00000000 78010000 74 13801000 1 0 0 0 0 0 0 00000000 00000000 78010000
74 14001000 1 0 0 0 0 0 0 00000000 00000000 98000000 75 14001000 1 0 0 0 0 0 0 00000000 00000000 98000000
75 14201000 1 0 1 1 f 7 0 00000114 00000000 98000000 76 14201000 1 0 1 1 f 7 0 00000114 00000000 98000000
76 14401000 1 0 1 1 f 7 0 00000114 00000000 78010000 77 14401000 1 0 1 1 f 7 0 00000114 00000000 78010000
77 14601000 1 0 0 0 0 0 0 00000000 00000000 382102a4 78 14601000 1 0 0 0 0 0 0 00000000 00000000 382102a4
78 14801000 1 0 0 0 0 0 0 00000000 00000000 98000000 79 14801000 1 0 0 0 0 0 0 00000000 00000000 98000000
79 15001000 1 0 1 1 f 7 0 00000118 00000000 98000000 80 15001000 1 0 1 1 f 7 0 00000118 00000000 98000000
80 15201000 1 0 1 1 f 7 0 00000118 00000000 382102a4 81 15201000 1 0 1 1 f 7 0 00000118 00000000 382102a4
81 15401000 1 0 0 0 0 0 0 00000000 00000000 78020000 82 15401000 1 0 0 0 0 0 0 00000000 00000000 78020000
82 15601000 1 0 0 0 0 0 0 00000000 00000000 98000000 83 15601000 1 0 0 0 0 0 0 00000000 00000000 98000000
83 15801000 1 0 1 1 f 7 0 0000011c 00000000 98000000 84 15801000 1 0 1 1 f 7 0 0000011c 00000000 98000000
84 16001000 1 0 1 1 f 7 0 0000011c 00000000 78020000 85 16001000 1 0 1 1 f 7 0 0000011c 00000000 78020000
85 16201000 1 0 0 0 0 0 0 00000000 00000000 384202a4 86 16201000 1 0 0 0 0 0 0 00000000 00000000 384202a4
86 16401000 1 0 0 0 0 0 0 00000000 00000000 98000000 87 16401000 1 0 0 0 0 0 0 00000000 00000000 98000000
87 16601000 1 0 1 1 f 7 0 00000120 00000000 98000000 88 16601000 1 0 1 1 f 7 0 00000120 00000000 98000000
88 16801000 1 0 1 1 f 7 0 00000120 00000000 384202a4 89 16801000 1 0 1 1 f 7 0 00000120 00000000 384202a4
89 17001000 1 0 0 0 0 0 0 00000000 00000000 44220004 90 17001000 1 0 0 0 0 0 0 00000000 00000000 44220004
90 17201000 1 0 0 0 0 0 0 00000000 00000000 98000000 91 17201000 1 0 0 0 0 0 0 00000000 00000000 98000000
91 17401000 1 0 1 1 f 7 0 00000124 00000000 98000000 92 17401000 1 0 1 1 f 7 0 00000124 00000000 98000000
92 17601000 1 0 1 1 f 7 0 00000124 00000000 44220004 93 17601000 1 0 1 1 f 7 0 00000124 00000000 44220004
93 17801000 1 0 0 0 0 0 0 00000000 00000000 78030000 94 17801000 1 0 0 0 0 0 0 00000000 00000000 78030000
94 18001000 1 0 0 0 0 0 0 00000000 00000000 98000000 95 18001000 1 0 0 0 0 0 0 00000000 00000000 98000000
95 18201000 1 0 1 1 f 7 0 00000128 00000000 98000000 96 18201000 1 0 1 1 f 7 0 00000128 00000000 98000000
96 18401000 1 0 1 1 f 7 0 00000128 00000000 78030000 97 18401000 1 0 1 1 f 7 0 00000128 00000000 78030000
97 18601000 1 0 0 0 0 0 0 00000000 00000000 38630ab8 98 18601000 1 0 0 0 0 0 0 00000000 00000000 38630ab8
98 18801000 1 0 0 0 0 0 0 00000000 00000000 98000000 99 18801000 1 0 0 0 0 0 0 00000000 00000000 98000000
99 19001000 1 0 1 1 f 7 0 0000012c 00000000 98000000 100 19001000 1 0 1 1 f 7 0 0000012c 00000000 98000000
100 19201000 1 0 1 1 f 7 0 0000012c 00000000 38630ab8 101 19201000 1 0 1 1 f 7 0 0000012c 00000000 38630ab8
101 19401000 1 0 0 0 0 0 0 00000000 00000000 f8000030 102 19401000 1 0 0 0 0 0 0 00000000 00000000 f8000030
102 19601000 1 0 0 0 0 0 0 00000000 00000000 98000000 103 19601000 1 0 0 0 0 0 0 00000000 00000000 98000000
103 19801000 1 0 1 1 f 7 0 00000130 00000000 98000000 104 19801000 1 0 1 1 f 7 0 00000130 00000000 98000000
104 20001000 1 0 1 1 f 7 0 00000130 00000000 f8000030 105 20001000 1 0 1 1 f 7 0 00000130 00000000 f8000030
105 20201000 1 0 0 0 0 0 0 00000000 00000000 78010000 106 20201000 1 0 0 0 0 0 0 00000000 00000000 78010000
106 20401000 1 0 0 0 0 0 0 00000000 00000000 98000000 107 20401000 1 0 0 0 0 0 0 00000000 00000000 98000000
107 20601000 1 0 1 1 f 7 0 00000134 00000000 98000000 108 20601000 1 0 1 1 f 7 0 00000134 00000000 98000000
108 20801000 1 0 1 1 f 7 0 00000134 00000000 78010000 109 20801000 1 0 1 1 f 7 0 00000134 00000000 78010000
109 21001000 1 0 0 0 0 0 0 00000000 00000000 38210ab8 110 21001000 1 0 0 0 0 0 0 00000000 00000000 38210ab8
110 21201000 1 0 0 0 0 0 0 00000000 00000000 98000000 111 21201000 1 0 0 0 0 0 0 00000000 00000000 98000000
111 21401000 1 0 1 1 f 7 0 00000138 00000000 98000000 112 21401000 1 0 1 1 f 7 0 00000138 00000000 98000000
112 21601000 1 0 1 1 f 7 0 00000138 00000000 38210ab8 113 21601000 1 0 1 1 f 7 0 00000138 00000000 38210ab8
113 21801000 1 0 0 0 0 0 0 00000000 00000000 78020000 114 21801000 1 0 0 0 0 0 0 00000000 00000000 78020000
114 22001000 1 0 0 0 0 0 0 00000000 00000000 98000000 115 22001000 1 0 0 0 0 0 0 00000000 00000000 98000000
115 22201000 1 0 1 1 f 7 0 0000013c 00000000 98000000 116 22201000 1 0 1 1 f 7 0 0000013c 00000000 98000000
116 22401000 1 0 1 1 f 7 0 0000013c 00000000 78020000 117 22401000 1 0 1 1 f 7 0 0000013c 00000000 78020000
117 22601000 1 0 0 0 0 0 0 00000000 00000000 38420ab8 118 22601000 1 0 0 0 0 0 0 00000000 00000000 38420ab8
118 22801000 1 0 0 0 0 0 0 00000000 00000000 98000000 119 22801000 1 0 0 0 0 0 0 00000000 00000000 98000000
119 23001000 1 0 1 1 f 7 0 00000140 00000000 98000000 120 23001000 1 0 1 1 f 7 0 00000140 00000000 98000000
120 23201000 1 0 1 1 f 7 0 00000140 00000000 38420ab8 121 23201000 1 0 1 1 f 7 0 00000140 00000000 38420ab8
121 23401000 1 0 0 0 0 0 0 00000000 00000000 44220008 122 23401000 1 0 0 0 0 0 0 00000000 00000000 44220008
122 23601000 1 0 0 0 0 0 0 00000000 00000000 98000000 123 23601000 1 0 0 0 0 0 0 00000000 00000000 98000000
123 23801000 1 0 1 1 f 7 0 00000144 00000000 98000000 124 23801000 1 0 1 1 f 7 0 00000144 00000000 98000000
124 24001000 1 0 1 1 f 7 0 00000144 00000000 44220008 125 24001000 1 0 1 1 f 7 0 00000144 00000000 44220008
125 24201000 1 0 0 0 0 0 0 00000000 00000000 78030000 126 24201000 1 0 0 0 0 0 0 00000000 00000000 78030000
126 24401000 1 0 0 0 0 0 0 00000000 00000000 98000000 127 24401000 1 0 0 0 0 0 0 00000000 00000000 98000000
127 24601000 1 0 1 1 f 7 0 00000148 00000000 98000000 128 24601000 1 0 1 1 f 7 0 00000148 00000000 98000000
128 24801000 1 0 1 1 f 7 0 00000148 00000000 78030000 129 24801000 1 0 1 1 f 7 0 00000148 00000000 78030000
129 25001000 1 0 0 0 0 0 0 00000000 00000000 38630ad4 130 25001000 1 0 0 0 0 0 0 00000000 00000000 38630ad4
130 25201000 1 0 0 0 0 0 0 00000000 00000000 98000000 131 25201000 1 0 0 0 0 0 0 00000000 00000000 98000000
131 25401000 1 0 1 1 f 7 0 0000014c 00000000 98000000 132 25401000 1 0 1 1 f 7 0 0000014c 00000000 98000000
132 25601000 1 0 1 1 f 7 0 0000014c 00000000 38630ad4 133 25601000 1 0 1 1 f 7 0 0000014c 00000000 38630ad4
133 25801000 1 0 0 0 0 0 0 00000000 00000000 44230005 134 25801000 1 0 0 0 0 0 0 00000000 00000000 44230005
134 26001000 1 0 0 0 0 0 0 00000000 00000000 98000000 135 26001000 1 0 0 0 0 0 0 00000000 00000000 98000000
135 26201000 1 0 1 1 f 7 0 00000150 00000000 98000000 136 26201000 1 0 1 1 f 7 0 00000150 00000000 98000000
136 26401000 1 0 1 1 f 7 0 00000150 00000000 44230005 137 26401000 1 0 1 1 f 7 0 00000150 00000000 44230005
137 26601000 1 0 0 0 0 0 0 00000000 00000000 c8611800 138 26601000 1 0 0 0 0 0 0 00000000 00000000 c8611800
138 26801000 1 0 0 0 0 0 0 00000000 00000000 98000000 139 26801000 1 0 0 0 0 0 0 00000000 00000000 98000000
139 27001000 1 0 1 1 f 7 0 00000164 00000000 98000000 140 27001000 1 0 1 1 f 7 0 00000164 00000000 98000000
140 27201000 1 0 1 1 f 7 0 00000164 00000000 78010000 141 27201000 1 0 1 1 f 7 0 00000164 00000000 78010000
141 27401000 1 0 0 0 0 0 0 00000000 00000000 38210ad4 142 27401000 1 0 0 0 0 0 0 00000000 00000000 38210ad4
142 27601000 1 0 0 0 0 0 0 00000000 00000000 98000000 143 27601000 1 0 0 0 0 0 0 00000000 00000000 98000000
143 27801000 1 0 1 1 f 7 0 00000168 00000000 98000000 144 27801000 1 0 1 1 f 7 0 00000168 00000000 98000000
144 28001000 1 0 1 1 f 7 0 00000168 00000000 38210ad4 145 28001000 1 0 1 1 f 7 0 00000168 00000000 38210ad4
145 28201000 1 0 0 0 0 0 0 00000000 00000000 78020000 146 28201000 1 0 0 0 0 0 0 00000000 00000000 78020000
146 28401000 1 0 0 0 0 0 0 00000000 00000000 98000000 147 28401000 1 0 0 0 0 0 0 00000000 00000000 98000000
147 28601000 1 0 1 1 f 7 0 0000016c 00000000 98000000 148 28601000 1 0 1 1 f 7 0 0000016c 00000000 98000000
148 28801000 1 0 1 1 f 7 0 0000016c 00000000 78020000 149 28801000 1 0 1 1 f 7 0 0000016c 00000000 78020000
149 29001000 1 0 0 0 0 0 0 00000000 00000000 38420ad4 150 29001000 1 0 0 0 0 0 0 00000000 00000000 38420ad4
150 29201000 1 0 0 0 0 0 0 00000000 00000000 98000000 151 29201000 1 0 0 0 0 0 0 00000000 00000000 98000000
151 29401000 1 0 1 1 f 7 0 00000170 00000000 98000000 152 29401000 1 0 1 1 f 7 0 00000170 00000000 98000000
152 29601000 1 0 1 1 f 7 0 00000170 00000000 38420ad4 153 29601000 1 0 1 1 f 7 0 00000170 00000000 38420ad4
153 29801000 1 0 0 0 0 0 0 00000000 00000000 44220008 154 29801000 1 0 0 0 0 0 0 00000000 00000000 44220008
154 30001000 1 0 0 0 0 0 0 00000000 00000000 98000000 155 30001000 1 0 0 0 0 0 0 00000000 00000000 98000000
155 30201000 1 0 1 1 f 7 0 00000174 00000000 98000000 156 30201000 1 0 1 1 f 7 0 00000174 00000000 98000000
156 30401000 1 0 1 1 f 7 0 00000174 00000000 44220008 157 30401000 1 0 1 1 f 7 0 00000174 00000000 44220008
157 30601000 1 0 0 0 0 0 0 00000000 00000000 78030000 158 30601000 1 0 0 0 0 0 0 00000000 00000000 78030000
158 30801000 1 0 0 0 0 0 0 00000000 00000000 98000000 159 30801000 1 0 0 0 0 0 0 00000000 00000000 98000000
159 31001000 1 0 1 1 f 7 0 00000178 00000000 98000000 160 31001000 1 0 1 1 f 7 0 00000178 00000000 98000000
160 31201000 1 0 1 1 f 7 0 00000178 00000000 78030000 161 31201000 1 0 1 1 f 7 0 00000178 00000000 78030000
161 31401000 1 0 0 0 0 0 0 00000000 00000000 38630b28 162 31401000 1 0 0 0 0 0 0 00000000 00000000 38630b28
162 31601000 1 0 0 0 0 0 0 00000000 00000000 98000000 163 31601000 1 0 0 0 0 0 0 00000000 00000000 98000000
163 31801000 1 0 1 1 f 7 0 0000017c 00000000 98000000 164 31801000 1 0 1 1 f 7 0 0000017c 00000000 98000000
164 32001000 1 0 1 1 f 7 0 0000017c 00000000 38630b28 165 32001000 1 0 1 1 f 7 0 0000017c 00000000 38630b28
165 32201000 1 0 0 0 0 0 0 00000000 00000000 44230005 166 32201000 1 0 0 0 0 0 0 00000000 00000000 44230005
166 32401000 1 0 0 0 0 0 0 00000000 00000000 98000000 167 32401000 1 0 0 0 0 0 0 00000000 00000000 98000000
167 32601000 1 0 1 1 f 7 0 00000180 00000000 98000000 168 32601000 1 0 1 1 f 7 0 00000180 00000000 98000000
168 32801000 1 0 1 1 f 7 0 00000180 00000000 44230005 169 32801000 1 0 1 1 f 7 0 00000180 00000000 44230005
169 33001000 1 0 0 0 0 0 0 00000000 00000000 c8611800 170 33001000 1 0 0 0 0 0 0 00000000 00000000 c8611800
170 33201000 1 0 0 0 0 0 0 00000000 00000000 98000000 171 33201000 1 0 0 0 0 0 0 00000000 00000000 98000000
171 33401000 1 0 1 1 f 7 0 00000194 00000000 98000000 172 33401000 1 0 1 1 f 7 0 00000194 00000000 98000000
172 33601000 1 0 1 1 f 7 0 00000194 00000000 78010000 173 33601000 1 0 1 1 f 7 0 00000194 00000000 78010000
173 33801000 1 0 0 0 0 0 0 00000000 00000000 38210b28 174 33801000 1 0 0 0 0 0 0 00000000 00000000 38210b28
174 34001000 1 0 0 0 0 0 0 00000000 00000000 98000000 175 34001000 1 0 0 0 0 0 0 00000000 00000000 98000000
175 34201000 1 0 1 1 f 7 0 00000198 00000000 98000000 176 34201000 1 0 1 1 f 7 0 00000198 00000000 98000000
176 34401000 1 0 1 1 f 7 0 00000198 00000000 38210b28 177 34401000 1 0 1 1 f 7 0 00000198 00000000 38210b28
177 34601000 1 0 0 0 0 0 0 00000000 00000000 78030000 178 34601000 1 0 0 0 0 0 0 00000000 00000000 78030000
178 34801000 1 0 0 0 0 0 0 00000000 00000000 98000000 179 34801000 1 0 0 0 0 0 0 00000000 00000000 98000000
179 35001000 1 0 1 1 f 7 0 0000019c 00000000 98000000 180 35001000 1 0 1 1 f 7 0 0000019c 00000000 98000000
180 35201000 1 0 1 1 f 7 0 0000019c 00000000 78030000 181 35201000 1 0 1 1 f 7 0 0000019c 00000000 78030000
181 35401000 1 0 0 0 0 0 0 00000000 00000000 38630c40 182 35401000 1 0 0 0 0 0 0 00000000 00000000 38630c40
182 35601000 1 0 0 0 0 0 0 00000000 00000000 98000000 183 35601000 1 0 0 0 0 0 0 00000000 00000000 98000000
183 35801000 1 0 1 1 f 7 0 000001a0 00000000 98000000 184 35801000 1 0 1 1 f 7 0 000001a0 00000000 98000000
184 36001000 1 0 1 1 f 7 0 000001a0 00000000 38630c40 185 36001000 1 0 1 1 f 7 0 000001a0 00000000 38630c40
185 36201000 1 0 0 0 0 0 0 00000000 00000000 44230004 186 36201000 1 0 0 0 0 0 0 00000000 00000000 44230004
186 36401000 1 0 0 0 0 0 0 00000000 00000000 98000000 187 36401000 1 0 0 0 0 0 0 00000000 00000000 98000000
187 36601000 1 0 1 1 f 7 0 000001a4 00000000 98000000 188 36601000 1 0 1 1 f 7 0 000001a4 00000000 98000000
188 36801000 1 0 1 1 f 7 0 000001a4 00000000 44230004 189 36801000 1 0 1 1 f 7 0 000001a4 00000000 44230004
189 37001000 1 0 0 0 0 0 0 00000000 00000000 58200000 190 37001000 1 0 0 0 0 0 0 00000000 00000000 58200000
190 37201000 1 0 0 0 0 0 0 00000000 00000000 98000000 191 37201000 1 0 0 0 0 0 0 00000000 00000000 98000000
191 37401000 1 0 1 1 f 7 0 000001a8 00000000 98000000 192 37401000 1 0 1 1 f 7 0 000001a8 00000000 98000000
192 37601000 1 0 1 1 f 7 0 000001a8 00000000 58200000 193 37601000 1 0 1 1 f 7 0 000001a8 00000000 58200000
193 37801000 1 0 0 0 0 0 0 00000000 00000000 34210004 194 37801000 1 0 0 0 0 0 0 00000000 00000000 34210004
194 38001000 1 0 0 0 0 0 0 00000000 00000000 98000000 195 38001000 1 0 0 0 0 0 0 00000000 00000000 98000000
195 38201000 1 0 1 1 f 7 0 000001ac 00000000 98000000 196 38201000 1 0 1 1 f 7 0 000001ac 00000000 98000000
196 38401000 1 0 1 1 f 7 0 000001ac 00000000 34210004 197 38401000 1 0 1 1 f 7 0 000001ac 00000000 34210004
197 38601000 1 0 0 0 0 0 0 00000000 00000000 e3fffffd 198 38601000 1 0 0 0 0 0 0 00000000 00000000 e3fffffd
198 38801000 1 0 0 0 0 0 0 00000000 00000000 98000000 199 38801000 1 0 0 0 0 0 0 00000000 00000000 98000000
199 39001000 1 0 1 1 f 7 0 000001b0 00000000 98000000 200 39001000 1 0 1 1 f 7 0 000001b0 00000000 98000000
200 39201000 1 0 1 1 f 7 0 000001b0 00000000 e3fffffd 201 39201000 1 0 1 1 f 7 0 000001b0 00000000 e3fffffd
201 39401000 1 0 0 0 0 0 0 00000000 00000000 78040000 202 39401000 1 0 0 0 0 0 0 00000000 00000000 78040000
202 39601000 1 0 0 0 0 0 0 00000000 00000000 98000000 203 39601000 1 0 0 0 0 0 0 00000000 00000000 98000000
203 39801000 1 0 1 1 f 7 0 000001b4 00000000 98000000 204 39801000 1 0 1 1 f 7 0 000001b4 00000000 98000000
204 40001000 1 0 1 1 f 7 0 000001b4 00000000 78040000 205 40001000 1 0 1 1 f 7 0 000001b4 00000000 78040000
205 40201000 1 0 0 0 0 0 0 00000000 00000000 38840a70 206 40201000 1 0 0 0 0 0 0 00000000 00000000 38840a70
206 40401000 1 0 0 0 0 0 0 00000000 00000000 98000000 207 40401000 1 0 0 0 0 0 0 00000000 00000000 98000000
207 40601000 1 0 1 1 f 7 0 000001a4 00000000 98000000 208 40601000 1 0 1 1 f 7 0 000001a4 00000000 98000000
208 40801000 1 0 1 1 f 7 0 000001a4 00000000 44230004 209 40801000 1 0 1 1 f 7 0 000001a4 00000000 44230004
209 41001000 1 0 0 0 0 0 0 00000000 00000000 58200000 210 41001000 1 0 0 0 0 0 0 00000000 00000000 58200000
210 41201000 1 1 1 1 f 7 0 00000b28 00000000 98000000 211 41201000 1 1 1 1 f 7 0 00000b28 00000000 98000000
211 ! 41401000 1 1 1 1 f 7 0 00000b28 00000000 xxxxxxxx 212 ! 41401000 1 1 1 1 f 7 0 00000b28 00000000 00000000
212 ! 41601000 1 0 0 0 0 0 0 00000000 00000000 xxxxxxxx 213 ! 41601000 1 0 0 0 0 0 0 00000000 00000000 00000000
213 41801000 1 0 1 1 f 7 0 000001a8 00000000 98000000 214 41801000 1 0 1 1 f 7 0 000001a8 00000000 98000000



(2014.10.5追記)
ただのLEDチカチカなのに、NEEKでやってみるとチカチカしない。
シミュレーションではLED用のGPIOが動くのだが、NEEK上では、SignalTapでキャプチャしようとしても、
一切動いてないみたい。

シミュレーションで動いてたので安心していたが、QuartusIIでこんなワーニング発見。これが原因か?

Critical Warning (127005): Memory depth (4096) in the design file differs from memory depth (2566) in the Memory Initialization File "C:/user/googledrive/vm_share/micosystem/lm32_altera_ram_ok/quartus_neek/led_test.hex" -- setting initial value for remaining addresses to 0



ターゲットメモリサイズまで00000000データで埋めるバージョンを作成。
尚、checksum計算部をメソッド化してる。これでQuartusIIワーニング消えた。


print "START: ",Time.now,"\n"

def calc_chk_sum(str_for_chksum)
#---------------------------------------------
# calculate check sum
#---------------------------------------------
sum = 0
while (str_for_chksum.size != 0)
temp = str_for_chksum.slice!(0,2)
sum = sum + temp.hex
end

# 2014.9.27 for support to 1 char
if (sum.to_s(16).size == 1)
hex_under_2bit = "0" + sum.to_s(16)
else
hex_under_2bit = sum.to_s(16).slice(-2, 2)
end

dec_under_2bit = hex_under_2bit.hex
chksum_temp = "%02X" % (256 - dec_under_2bit)
chksum = chksum_temp.slice(-2,2)
end

file_in, file_out = ARGV

hex_file = File::open(file_out, "a")

@tgt_mem_depth = 4096
record_type = "00"
adr_cnt = 0

line_data = ""
File.foreach(file_in) do |line|
line_data = line_data + line.chomp
data_length = "04"
address = "%04X" % adr_cnt

#---------------------------------------------
# calculate check sum
#---------------------------------------------
str_for_chksum = data_length + address + record_type + line_data
chksum = calc_chk_sum(str_for_chksum)

#---------------------------------------------
# output to file
#---------------------------------------------
hex_file.print ":", data_length, address, record_type, line_data, chksum, "\n"
adr_cnt = adr_cnt + 1
line_data = ""
end

# to fill up to target memory depth 2014.10.5
while (adr_cnt != @tgt_mem_depth)
data_length = "04"
address = "%04X" % adr_cnt
line_data = "00000000"

str_for_chksum = data_length + address + record_type + line_data
chksum = calc_chk_sum(str_for_chksum)

hex_file.print ":", data_length, address, record_type, line_data, chksum, "\n"
adr_cnt = adr_cnt + 1
end

# 2014.9.22 Intel-HEX last line
hex_file.print ":00000001FF"
hex_file.close

print "END : ",Time.now,"\n"

スポンサーサイト



コメントの投稿

非公開コメント

カレンダー
10 | 2019/11 | 12
- - - - - 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
累積訪問者
現在の訪問者
現在の閲覧者数:
最新記事
最新トラックバック
最新コメント
月別アーカイブ
カテゴリ
プロフィール

bobgosso

Author:bobgosso
FPGAのブログへようこそ!

検索フォーム
RSSリンクの表示
リンク
ブロとも申請フォーム

この人とブロともになる

QRコード
QRコード