Shop OBEX P1 Docs P2 Docs Learn Events
ROM Hex file format required for Quartus Verilog — Parallax Forums

ROM Hex file format required for Quartus Verilog

Cluso99Cluso99 Posts: 18,069
edited 2015-04-11 16:21 in Propeller 1
Today I noticed the hub_rom_high.hex and hub_rom_low.hex files have invalid addresses in the intel hex format.
eg the length of each line is $20, and the first address is $0000. But the next address is $0008, then $0010, then $0018.
Obviously Verilog doesn't care.


Postedit: See Post #33 for the Intel Hex file format required by Quartus II v14.0 (Windows 8.1 64-bit)
http://forums.parallax.com/showthread.php/160734-Has-anyone-noticed-the-ROM-hex-files-have-invalid-addresses-(the-git-version)?p=1325747&viewfull=1#post1325747

I have renamed this thread's heading to be more appropriate to the topic.
«1

Comments

  • jac_goudsmitjac_goudsmit Posts: 418
    edited 2015-04-09 14:40
    The addresses are intended to be long-word based addresses, I suppose.

    I think Quartus generates a warning about the files, but it converts the long words to bytes and stores them correctly using "ram_init_file" directives in the source code. However, this method is Quartus-specific and isn't compatible with the Xilinx tools. The old Github tree (from before Parallax created their community) contains a change where the Intel files were converted to hex files, and where the initialization was changed to use $readmemh. We also de-scrambled the code and split the files up into smaller parts to make it easier to do cherry-picking. I intend to integrate those changes into the current P1V repo but I've been very busy with work, a move from Arizona to California, and other projects.

    ===Jac
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-09 19:02
    Thanks Jac,
    Yes, I just realised that the addresses were >>2 for long addresses. But the length is in bytes. Curious format!!!
    Quartus cannot handle comments at the end of a line eg // -ascii-, but its fine with single line comments beginning with //.
    I have yet to determine if it does not like the spaces between bytes, or if its the address it is complaining about.

    I created the various scrambled and unscrambled files. I used $readmemb, but that required 4 byte files for my byte-configured hub memory.
    The advantage of having the hub ROM byte-configured is that you can then permit writes to the ROM section of the hub memory.
    Therefore, you can loadup the default ROM, but permit the user to overwrite it and use it as RAM. Sort of an each-way bet.

    Before you put them in the repo, I am in the process of re-generating them again.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-09 22:41
    Going back a few yaers when EPROM programmers were part of daily life I remember having drama between
    the different programmers as to what they considered to be the "correct" Intel hex format.
    Some of these programmers even had tools to convert Intel hex files into other formats.
    IIRC some hex file generators used little endian, some big endian, some words etc.
    Depending on the programmer used dictated the file format required.
    It never was as simple as it should have been.

    Quartus seems to give warnings for all the different formats I have tried.
    In the end the format used in Chips original hex files works fine so I went back to that.
    I wonder what method Chip used to generate his files?
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-09 23:43
    Oh, its even worse than this.
    I have done a comparison between my files, both identical. The original gives no warnings and the new file gives a warning about incorrect lengths on each line

    The warning is
    113015 Width of data items in "...filename..." is greater than the memory width. Wrapping data items to subsequent addresses. Found 512 warnings, reporting 10.

    I just tried cutting/pasting into Notepad. Still fails. It isn't the sort of warning that you should ignore.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 01:00
    I've been generating hex files from my code generator in the same format as the original files (with the warnings).
    All sorts of modified booters and spin hacks that have loaded correctly to the right destination.
    From my experience all the failures I encountered were related to bad coding on my part.
    I gave up fighting Quartus on the "warning" front as the proof is in the download to the fpga target.
    All attempts at including timing files in my case made the warning count worse.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 02:38
    Well, I found a way to get a clean intel hex file for the clean P1V from git (it's not clean BTW)...

    Open the hex file with Win8.1 Notepad. (I create this via a spin program and cut/paste from PST to PropTool and save. It is a complete ROM file).
    Cut the desired section (from the start of the desired line to the end of the last desired line)
    Paste New in Notepad
    Save As rom_low/high_xxx.hex as a Unicode, *.txt file
    Close Notepad (this is important)
    Open the saved file with Notepad,
    Save As rom_low/high_xxx.hex as an ANSI, *.txt file, replace=yes
    Close Notepad. Your file is now ready for Verilog.

    Note that I have Notepad selected as the default program for *.hex files, so the above Save As does not append .txt to the filename.

    At least this process works. There must be some file header info in windows that quartus does not like ???
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 02:44
    ozpropdev wrote: »
    I've been generating hex files from my code generator in the same format as the original files (with the warnings).
    All sorts of modified booters and spin hacks that have loaded correctly to the right destination.
    From my experience all the failures I encountered were related to bad coding on my part.
    I gave up fighting Quartus on the "warning" front as the proof is in the download to the fpga target.
    All attempts at including timing files in my case made the warning count worse.
    Unfortunately it does not instill confidence when we cannot get rid of the errors.
    I have also had an attempt (months ago) to get rid of the errors, but had no success.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 07:01
    I had another look at the hex file format and finally generated a format that made Quartus happy :)
    :0400000000BCFFFF42
    :04000100A0FC00055A
    :04000200A0BC03F0AB
    :0400030080FC020279
    
    Changed from 16 32 bytes to 4 and also changed address indexing from 8 to 1.
    This addressing change was the only one that worked in the FPGA target.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 07:58
    I used 32 bytes per line. I cannot tell the difference between good and bad files.

    I am preparing to load my faster spin interpreter :)
  • jmgjmg Posts: 15,173
    edited 2015-04-10 15:29
    ozpropdev wrote: »
    I had another look at the hex file format and finally generated a format that made Quartus happy :)
    :0400000000BCFFFF42
    :04000100A0FC00055A
    :04000200A0BC03F0AB
    :0400030080FC020279
    
    Changed from 16 bytes to 4 and also changed address indexing from 8 to 1.
    This addressing change was the only one that worked in the FPGA target.
    Wow, that is broken enough, it should be called a .qex file, not a .hex file.

    Still, as long as users know what works with no errors, and that variant looks easy enough to convert to.

    One now hopes that some intern at Altrea does not fix the 'hex' file reader, to actually read hex files ! ;)
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 16:42
    Cluso99 wrote: »
    I used 32 bytes per line.

    Oops! 32 bytes. I corrected my post. :)

    Are you saying that the Notepad procesdure eliminates the following warning???
    Width of data items in "...filename..." is greater than the memory width. Wrapping data items to subsequent addresses.


    jmg wrote: »
    Still, as long as users know what works with no errors, and that variant looks easy enough to convert to.

    Both methods work fine in the FPGA target but the 32 byte variant produces the above warning.
  • jmgjmg Posts: 15,173
    edited 2015-04-10 17:02
    ozpropdev wrote: »
    Both methods work fine in the FPGA target but the 32 byte variant produces the above warning.
    Strange, as one is clearly not intex hex.
    However, no warning is always better than confusing warnings, so that promotes the 'fixed' version, but I would rename the files .qex. & maybe check every 6-12 months to see if Quartus removes the warning on a valid .hex file.
    Other toolchains may need valid hex files, so that needs to also be possible.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 17:18
    ozpropdev wrote: »
    Oops! 32 bytes. I corrected my post. :)

    Are you saying that the Notepad procesdure eliminates the following warning???
    Width of data items in "...filename..." is greater than the memory width. Wrapping data items to subsequent addresses.





    Both methods work fine in the FPGA target but the 32 byte variant produces the above warning.
    Yes, it stops that error!

    My rom high file has 2 lines where the length is 4 bytes and 28 bytes (needed for the SIN table). This works fine too.
    It seems that there is something wrong with the actual file header (not the data in the file).

    I now have unscrambled roms working again. I will post them shortly as the files are based on the latest git files.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 17:21
    jmg wrote: »
    Strange, as one is clearly not intex hex.
    However, no warning is always better than confusing warnings, so that promotes the 'fixed' version, but I would rename the files .qex. & maybe check every 6-12 months to see if Quartus removes the warning on a valid .hex file.
    Other toolchains may need valid hex files, so that needs to also be possible.
    They are valid intel hex files apart from the requirement that the addresses be in longs, not bytes.
    Quartus is obviously checking something else to do with the file header (ie file label, not data).
  • KeithEKeithE Posts: 957
    edited 2015-04-10 18:00
    Stupid question - why use Intel hex instead of Verilog hex? We use Verilog hex files in both simulation and synthesis flow with ModelSim and Quartus. Quartus knows how to deal with $readmemh. We don't have any warnings in the simulation flow, but I can't say that for sure about the synthesis flow off the top of my head.
  • jmgjmg Posts: 15,173
    edited 2015-04-10 18:18
    Cluso99 wrote: »
    They are valid intel hex files apart from the requirement that the addresses be in longs, not bytes.
    Nope - If the address are in longs, they are no longer valid intel hex files, they have become some derivative/variant offshoot 'based on' intel hex.
    The correct intel hex file format has means to manage 32b address, Altera should properly follow that.
    I still say name these Quartus variants .qex, to avoid confusion.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 18:26
    Here are two identical files. The "x" variant gives a warning about the length as described above.

    I created the "x" variant by opening the non-x file with Notepad, did Ctl-A to select all, and Ctl-C to copy all, then file/new, Ctl-V to paste all, and then Save As ANSI *.txt with the filename rom_high_v028x.hex
    Notepad does not add ".txt" as I have made Notepad my default editor for ".hex" files.

    Can anyone see any difference in the two files???
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 18:45
    KeithE wrote: »
    Stupid question - why use Intel hex instead of Verilog hex? We use Verilog hex files in both simulation and synthesis flow with ModelSim and Quartus. Quartus knows how to deal with $readmemh. We don't have any warnings in the simulation flow, but I can't say that for sure about the synthesis flow off the top of my head.
    I guess because it is supposed to work.
    It is well documented.
    Because the addresses are contained in each line, it is easy to merge two or more file sections with an editor.

    I found similar problems with getting the syntax correct with $readmemb/h months ago.IIRC in the end I had to just use straight hex without any @ or addresses.
  • jmgjmg Posts: 15,173
    edited 2015-04-10 18:52
    Cluso99 wrote: »
    Here are two identical files. The "x" variant gives a warning about the length as described above.

    I created the "x" variant by opening the non-x file with Notepad, did Ctl-A to select all, and Ctl-C to copy all, then file/new, Ctl-V to paste all, and then Save As ANSI *.txt with the filename rom_high_v028x.hex
    Notepad does not add ".txt" as I have made Notepad my default editor for ".hex" files.

    Can anyone see any difference in the two files???

    Notepad++ File Compare plugin says they are identical (39448 bytes, 514 lines)- however, I notice they both do lack CRLF on the last line, and some readers may not like that.
    If you add a CrLf to the last line, does the difference persist ?
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 18:56
    I just compiled with you rom_high_v-28.hex file from the zipped foler on your other thread.
    It still produces the warning at this end.
    Warning (113015): Width of data items in "rom_high_v028.hex" is greater than the memory width. Wrapping data items to subsequent addresses. Found 128 warnings, reporting 10
    

    The Quartus "Vortex of weirdness!"
  • jmgjmg Posts: 15,173
    edited 2015-04-10 19:19
    ozpropdev wrote: »
    I just compiled with you rom_high_v-28.hex file from the zipped foler on your other thread.
    It still produces the warning at this end.
    Warning (113015): Width of data items in "rom_high_v028.hex" is greater than the memory width. Wrapping data items to subsequent addresses. Found 128 warnings, reporting 10
    

    The Quartus "Vortex of weirdness!"
    Maybe the memory width they talk of, is the word-size, which is why your short-hex lines are ok ?
    If it loads ok in both cases, suggests they are doing the right thing, just giving a bonus/bogus warning set then they do the bleedin' obvious of "Wrapping data items to subsequent addresses"
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 20:14
    ozpropdev wrote: »
    I just compiled with you rom_high_v-28.hex file from the zipped foler on your other thread.
    It still produces the warning at this end.
    Warning (113015): Width of data items in "rom_high_v028.hex" is greater than the memory width. Wrapping data items to subsequent addresses. Found 128 warnings, reporting 10
    

    The Quartus "Vortex of weirdness!"
    Gets even more curious. I am using Windows 8.1 64-bit and Quartus 14.0.
    BTW I get 512 warnings, reporting 10.

    I might try (later) to just output 4 bytes per line, but I need to do that with TeraTerm or equiv. The PST window is not long enough.

    I just unzipped and the file works fine here. Thought it may be the recreating of the file header.
    jmg,
    I thought it worked better with the last cr removed.

    BTW I am generating an FDX output to PST (with cr only, no lf). Then I copy and paste into Notepad.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 20:45
    Here's is the unscrambled rom in 32 byte and 4 byte formats
    Both work but the 32 byte version produces the warning.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 20:53
    Cluso99 wrote: »
    BTW I get 512 warnings, reporting 10.
    .
    Sorry, I pasted the wrong result (That's was a 4k high rom in 32 byte format)
    I also get 512 warnings from your file too. :(
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 21:37
    BTW
    A quick way to check how Quartus will react to the hex files is to use the following function from the top menu
    >Processing>Update Memory Initialization File
    Info: *******************************************************************
    Info: Running Quartus II 32-bit MIF/HEX Update
    	Info: Version 13.1.0 Build 162 10/23/2013 SJ Web Edition
    	Info: Processing started: Sat Apr 11 14:13:24 2015
    Info: Command: quartus_cdb top -c top --update_mif
    Warning (113015): Width of data items in "hub_rom_low.hex" is greater than the memory width. Wrapping data items to subsequent addresses. Found 512 warnings, reporting 10
    	Warning (113009): Data at line (1) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (2) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (3) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (4) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (5) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (6) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (7) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (8) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (9) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (10) of memory initialization file "hub_rom_low.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    Warning (113015): Width of data items in "rom_high_32.hex" is greater than the memory width. Wrapping data items to subsequent addresses. Found 512 warnings, reporting 10
    	Warning (113009): Data at line (1) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (2) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (3) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (4) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (5) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (6) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (7) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (8) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (9) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    	Warning (113009): Data at line (10) of memory initialization file "rom_high_32.hex" is too wide to fit in one memory word. Wrapping data to subsequent addresses.
    Info (39024): Processed the following Memory Initialization File(s)
    	Info (39025): Processed Memory Initialization File C:/p1_fpga/jjj/hub_rom_low.hex
    	Info (39025): Processed Memory Initialization File C:/p1_fpga/jjj/rom_high_32.hex
    Info: Quartus II 32-bit MIF/HEX Update was successful. 0 errors, 22 warnings
    	Info: Peak virtual memory: 429 megabytes
    	Info: Processing ended: Sat Apr 11 14:13:27 2015
    	Info: Elapsed time: 00:00:03
    	Info: Total CPU time (on all processors): 00:00:03
    
    
  • jmgjmg Posts: 15,173
    edited 2015-04-10 21:43
    That's a slightly different message to the others, and very close to what I presumed in #22.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 21:54
    jmg wrote: »
    I still say name these Quartus variants .qex, to avoid confusion.

    Quartus doesn't like ypur idea jmg.
    Error (113025): Missing syntax END in the Memory Initialization File "rom_high_32.gex"
    Error (127000): Can't read Memory Initialization File or Hexadecimal (Intel-Format) File rom_high_32.gex for ROM instance . If the file exists, it is not in correct format.
    
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-10 22:40
    I have just regenerated the high rom as 4 bytes per line.
    I used TeraTerm to save the logfile and edited it down with Notepad.
    Now works fine without complaints, including permitting the comments beginning with // to remain. Never could do this before! :)

    Just regenerated the rom_low_v029.hex and rom_high_v029.hex files.

    [/Oops! I goofed up and the extract didn't unscramble correctly.I]
  • jmgjmg Posts: 15,173
    edited 2015-04-10 22:50
    ozpropdev wrote: »
    Quartus doesn't like ypur idea jmg.

    My suggestion was .QEX not GEX, but it should not care what extension the file has, surely - if you give it a full file name?
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-10 22:58
    Tried .qex too. Same result. File must use .hex extension.
Sign In or Register to comment.