Commit 0a225384 authored by Iulian Gheorghiu's avatar Iulian Gheorghiu

Add -b parameter, to setup the base address of the firmware.

parent 6dfc408f
No preview for this file type
......@@ -11,6 +11,7 @@ namespace IntelHexToVerilogMem
static string inputPath = "";
static string outputPath = "";
static string outHexGroupLenBytes = "2";
static UInt32 baseAddress = 0;
static void Main(string[] args)
{
......@@ -40,6 +41,11 @@ namespace IntelHexToVerilogMem
argsCntInt++;
outHexGroupLenBytes = args[argsCntInt];
}
else if (args[argsCntInt] == "-b")
{
argsCntInt++;
baseAddress = System.Convert.ToUInt32(args[argsCntInt], 16);
}
}
if (inputPath.Length == 0 || outputPath.Length == 0)
{
......@@ -59,7 +65,7 @@ namespace IntelHexToVerilogMem
Console.WriteLine("Invalid file input.");
return;
}
UInt32 extendedAddress = 0;
UInt32 extendedAddress = baseAddress;
List<string> rom = new List<string>();
foreach (string line in lines)
{
......@@ -83,7 +89,7 @@ namespace IntelHexToVerilogMem
string lineType = line.Substring(7, 2);
if (lineType == "00") // Data line//Contains data and 16-bit address. The format described above.
{
UInt32 lineAddrLowInt = extendedAddress + Convert.ToUInt32(line.Substring(3, 4), 16);
UInt32 lineAddrLowInt = (extendedAddress - baseAddress) + Convert.ToUInt32(line.Substring(3, 4), 16);
string lineData = line.Substring(9, Convert.ToInt32(lineLenInt));
if(rom.Count < lineAddrLowInt + (lineLenInt / 2))
{
......
......@@ -3,8 +3,10 @@ This application is made to convert from Intel hex format to Verilog memory file
You need to put the EXE in your Debug directory.
Down is an example of usage from Atmel Studio on Post build command line:
IntelHexToVerilogMem.exe -i "$(OutputFileName).hex" -o "C:\GitHub\XMEGA-CORE-IP-TST\core1ROM.mem" -g 2
IntelHexToVerilogMem.exe -i "$(OutputFileName).hex" -o "C:\GitHub\XMEGA-CORE-IP-TST\core1ROM.mem" -g "2" -b "0x20000000"
the -g argument is optional (default is 2) and indicate the length in bytes on a row, values supported are 1, 2 or 4.
the -b argument is the offset of the memore, for example if the rom memory start from 0x20000000 the addresses from 0 to 0x1fffffff is not included in output file.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment