Commit 132c96eb authored by Iulian Gheorghiu's avatar Iulian Gheorghiu

Initial release

parent a9b6ddfd

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntelHexToVerilogMem", "IntelHexToVerilogMem\IntelHexToVerilogMem.csproj", "{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}.Debug|x86.ActiveCfg = Debug|x86
{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}.Debug|x86.Build.0 = Debug|x86
{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}.Release|x86.ActiveCfg = Release|x86
{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FF5283F2-2E76-44A8-BBCC-88CB03C2F710}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IntelHexToVerilogMem</RootNamespace>
<AssemblyName>IntelHexToVerilogMem</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>-i Z:\FPGA\AvrUc\TestAvrUc\TestAvrUc\Debug\TestAvrUc.hex -o bb.mem</StartArguments>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace IntelHexToVerilogMem
{
class Program
{
static string inputPath = "";
static string outputPath = "";
static string outHexGroupLenBytes = "2";
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage:");
Console.WriteLine(" -i <file in>");
Console.WriteLine(" -o <file out>");
Console.WriteLine(" -g <nr of bytes on one row> (optional, default 2)");
Environment.Exit(-1);
}
int argsCntInt = 0;
for (; argsCntInt < args.Length; argsCntInt++)
{
if (args[argsCntInt] == "-i")
{
argsCntInt++;
inputPath = args[argsCntInt];
}
else if (args[argsCntInt] == "-o")
{
argsCntInt++;
outputPath = args[argsCntInt];
}
else if (args[argsCntInt] == "-g")
{
argsCntInt++;
outHexGroupLenBytes = args[argsCntInt];
}
}
if (inputPath.Length == 0 || outputPath.Length == 0)
{
Console.WriteLine("Usage:");
Console.WriteLine(" -i <file in>");
Console.WriteLine(" -o <file out>");
Console.WriteLine(" -g <nr of gytes on one row> (optional, default 2)");
Environment.Exit(-1);
}
string[] lines;
try
{
lines = File.ReadAllLines(inputPath);
}
catch
{
Console.WriteLine("Invalid file input.");
return;
}
UInt32 extendedAddress = 0;
List<string> rom = new List<string>();
foreach (string line in lines)
{
if (line[0] == ':')
{
UInt32 lineLenInt = (Convert.ToUInt32(line.Substring(1, 2), 16) * Convert.ToUInt32(2));
if (lineLenInt == line.Length - 11)
{
int cnt = 1;
byte chk = (byte)0;
for (; cnt < line.Length - 2; cnt += 2)
{
chk -= Convert.ToByte(line.Substring(cnt, 2), 16);
}
byte chkCalc = Convert.ToByte(line.Substring((int)lineLenInt + 9, 2), 16);
if (chkCalc != (byte)chk)
{
Console.WriteLine("Invalid checksum.");
return;
}
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);
string lineData = line.Substring(9, Convert.ToInt32(lineLenInt));
if(rom.Count < lineAddrLowInt + (lineLenInt / 2))
{
int lineNr = rom.Count;
for (; lineNr < lineAddrLowInt + (lineLenInt / 2); lineNr = rom.Count)
{
rom.Add("FF");
}
lineNr = 0;
for (; lineNr < lineLenInt / 2; lineNr++)
{
rom[(int)lineAddrLowInt + lineNr] = lineData.Substring(lineNr * 2, 2);
}
}
}
else if (lineType == "01") //End of file//A file termination record. No data. Has to be the last line of the file, only one per file permitted. Usually ':00000001FF'. Originally the End Of File record could contain a start address for the program being loaded, e.g. :00AB2F0125 would make a jump to address AB2F. This was convenient when programs were loaded from punched paper tape.
{
List<string> outRom = new List<string>();
int cntOutRomInt = 0;
for (; cntOutRomInt < rom.Count; cntOutRomInt += Convert.ToInt32(outHexGroupLenBytes, 10))
{
int cntOutRomByteInt = Convert.ToInt32(outHexGroupLenBytes, 10);
string tmp = "";
for(;cntOutRomByteInt > 0; cntOutRomByteInt--)
{
tmp += rom[cntOutRomInt + cntOutRomByteInt - 1];
}
outRom.Add(tmp);
}
File.WriteAllLines(outputPath, outRom.ToArray());
Environment.Exit(0);
}
else if (lineType == "02") //Extended segment address//Segment-base address. Used when 16 bits are not enough, identical to 80x86 real mode addressing. The address specified by the 02 record is multiplied by 16 (shifted 4 bits left) and added to the subsequent 00 record addresses. This allows addressing of up to a megabyte of address space. The address field of this record has to be 0000, the byte count is 02 (the segment is 16-bit). The least significant hex digit of the segment address is always 0.
{
extendedAddress = Convert.ToUInt32(line.Substring(3, 4), 16) << 16;
}
else if (lineType == "03") //Start segment address//For 80x86 processors, it specifies the initial content of the CS:IP registers. The address field is 0000, the byte count is 04, the first two bytes are the CS value, the latter two are the IP value.
{
}
else if (lineType == "04") //Extended line address//Allowing for fully 32 bit addressing. The address field is 0000, the byte count is 02. The two data bytes represent the upper 16 bits of the 32 bit address, when combined with the address of the 00 type record.
{
}
else if (lineType == "05") //Start line address//The address field is 0000, the byte count is 04. The 4 data bytes represent the 32-bit value loaded into the EIP register of the 80386 and higher CPU.
{
}
}
else
{
Console.WriteLine("Invalid hex line lenght.");
Environment.Exit(-3);
}
}
}
Environment.Exit(-2);
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IntelHexToVerilogMem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IntelHexToVerilogMem")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("92716055-d108-4b36-b0bc-2a3709819165")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
c:\users\work\documents\visual studio 2010\Projects\IntelHexToVerilogMem\IntelHexToVerilogMem\bin\Debug\IntelHexToVerilogMem.exe
c:\users\work\documents\visual studio 2010\Projects\IntelHexToVerilogMem\IntelHexToVerilogMem\bin\Debug\IntelHexToVerilogMem.pdb
c:\users\work\documents\visual studio 2010\Projects\IntelHexToVerilogMem\IntelHexToVerilogMem\obj\x86\Debug\IntelHexToVerilogMem.exe
c:\users\work\documents\visual studio 2010\Projects\IntelHexToVerilogMem\IntelHexToVerilogMem\obj\x86\Debug\IntelHexToVerilogMem.pdb
C:\Users\Work\documents\visual studio 2010\Projects\IntelHexToVerilogMem\IntelHexToVerilogMem\obj\x86\Debug\IntelHexToVerilogMem.csprojResolveAssemblyReference.cache
C:\GitHub\INTEL-HEX-TO-VERILOG-MEM\IntelHexToVerilogMem\obj\x86\Debug\IntelHexToVerilogMem.exe
C:\GitHub\INTEL-HEX-TO-VERILOG-MEM\IntelHexToVerilogMem\obj\x86\Debug\IntelHexToVerilogMem.pdb
This application is made to convert from Intel hex format to Verilog memory file format and is intended to be call by the compiler after HEX file was generated.
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
the -g argument is optional (default is 2) and indicate the length in bytes on a row, values supported are 1, 2 or 4.
* BTC: 1DcDgSzbZmY8P88H6VBS4r8npAWD1mhVSw
* BCH: 1BfFr6sN3bodNn5muU6BWyAQjMGUwNkbCL
* ETH: 0x10297A810cbe74B4f53455B05507F8929B22dC97
* DASH: Xr6u7C4t9DoffYG5PfWPD92iWqGtwwzdNA
* LTC: LXR5YomhnnVaKSxu4dsthbAc2ABuVpYg73
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