OpenCores
URL https://opencores.org/ocsvn/t80/t80/trunk

Subversion Repositories t80

[/] [t80/] [trunk/] [sw/] [hex2rom.cpp] - Diff between revs 6 and 38

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 6 Rev 38
Line 1... Line 1...
//
//
// Binary and intel/motorola hex to VHDL ROM converter
// Binary and intel/motorola hex to VHDL ROM converter
//
//
// Version : 0221
// Version : 0244
//
//
// Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
// Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
//
//
// All rights reserved
// All rights reserved
//
//
Line 56... Line 56...
//
//
// 0220 : Changed array ROM format, added support for Xilinx .UCF generation
// 0220 : Changed array ROM format, added support for Xilinx .UCF generation
//
//
// 0221 : Fixed small .UCF generation for small ROMs
// 0221 : Fixed small .UCF generation for small ROMs
//
//
 
// 0244 : Added Leonardo .UCF option
 
//
 
 
#include <stdio.h>
#include <stdio.h>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <iostream>
#include <iostream>
Line 585... Line 587...
};
};
 
 
 
 
int main (int argc, char *argv[])
int main (int argc, char *argv[])
{
{
        cerr << "Hex to VHDL ROM converter by Daniel Wallner. Version 0221\n";
        cerr << "Hex to VHDL ROM converter by Daniel Wallner. Version 0244\n";
 
 
        try
        try
        {
        {
                unsigned long aWidth;
                unsigned long aWidth;
                unsigned long dWidth;
                unsigned long dWidth;
Line 607... Line 609...
                        cerr << "  D = Data bits\n";
                        cerr << "  D = Data bits\n";
                        cerr << "  O = ROM type: (one optional character)\n";
                        cerr << "  O = ROM type: (one optional character)\n";
                        cerr << "      z for tri-state output\n";
                        cerr << "      z for tri-state output\n";
                        cerr << "      a for array ROM\n";
                        cerr << "      a for array ROM\n";
                        cerr << "      s for synchronous ROM\n";
                        cerr << "      s for synchronous ROM\n";
                        cerr << "      u for xilinx ucf\n";
                        cerr << "      u for XST ucf\n";
 
                        cerr << "      l for Leonardo ucf\n";
                        cerr << "  S = SelectRAM usage in 1/16 parts (only used when O = u)\n";
                        cerr << "  S = SelectRAM usage in 1/16 parts (only used when O = u)\n";
                        cerr << "\nExample:\n";
                        cerr << "\nExample:\n";
                        cerr << "  hex2rom test.hex Test_ROM 18b16z\n\n";
                        cerr << "  hex2rom test.hex Test_ROM 18b16z\n\n";
                        return -1;
                        return -1;
                }
                }
Line 636... Line 639...
                if (result < 3)
                if (result < 3)
                {
                {
                        throw "Error in output format argument!\n";
                        throw "Error in output format argument!\n";
                }
                }
 
 
                if (aWidth > 32 || (endian != 'l' && endian != 'b') || dWidth > 32 || (result > 3 && O != 'z' && O != 'a' && O != 's' && O != 'u'))
                if (aWidth > 32 || (endian != 'l' && endian != 'b') || dWidth > 32 || (result > 3 && O != 'z' && O != 'a' && O != 's' && O != 'u' && O != 'l'))
                {
                {
                        throw "Error in output format argument!\n";
                        throw "Error in output format argument!\n";
                }
                }
                inFileName = argv[argc - 3];
                inFileName = argv[argc - 3];
                outFileName = argv[argc - 2];
                outFileName = argv[argc - 2];
Line 668... Line 671...
                {
                {
                        i >>= 1;
                        i >>= 1;
                        words <<= 1;
                        words <<= 1;
                }
                }
 
 
                if (O != 'u')
                if (O != 'u' && O != 'l')
                {
                {
                        printf("-- This file was generated with hex2rom written by Daniel Wallner\n");
                        printf("-- This file was generated with hex2rom written by Daniel Wallner\n");
                        printf("\nlibrary IEEE;");
                        printf("\nlibrary IEEE;");
                        printf("\nuse IEEE.std_logic_1164.all;");
                        printf("\nuse IEEE.std_logic_1164.all;");
                        printf("\nuse IEEE.numeric_std.all;");
                        printf("\nuse IEEE.numeric_std.all;");
Line 846... Line 849...
                                                                bits |= bitMask;
                                                                bits |= bitMask;
                                                        }
                                                        }
                                                        bitMask <<= 1;
                                                        bitMask <<= 1;
                                                }
                                                }
 
 
 
                                                if (O == 'u')
 
                                                {
                                                if (selectIter == 1)
                                                if (selectIter == 1)
                                                {
                                                {
                                                        printf("\nINST *s%s%d INIT = %04X;", outFileName.c_str(), j, bits);
                                                        printf("\nINST *s%s%d INIT = %04X;", outFileName.c_str(), j, bits);
                                                }
                                                }
                                                else
                                                else
                                                {
                                                {
                                                        printf("\nINST *s%s%d%d INIT = %04X;", outFileName.c_str(), i, j, bits);
                                                        printf("\nINST *s%s%d%d INIT = %04X;", outFileName.c_str(), i, j, bits);
                                                }
                                                }
                                        }
                                        }
 
                                                else
 
                                                {
 
                                                        if (selectIter == 1)
 
                                                        {
 
                                                                printf("\nINST *sG1_%d_S%s INIT = %04X;", j, outFileName.c_str(), bits);
 
                                                        }
 
                                                        else
 
                                                        {
 
                                                                printf("\nINST *sG1_%d_sG2_%d_S%s INIT = %04X;", i, j, outFileName.c_str(), bits);
 
                                                        }
 
                                                }
 
                                        }
                                }
                                }
                        }
                        }
 
 
                        for (i = blockTotal - blockIter; i < blockTotal; i++)
                        for (i = blockTotal - blockIter; i < blockTotal; i++)
                        {
                        {
Line 883... Line 900...
                                                        }
                                                        }
                                                }
                                                }
 
 
                                                if (init)
                                                if (init)
                                                {
                                                {
 
                                                        if (O == 'u')
 
                                                        {
                                                        if (blockIter == 1)
                                                        if (blockIter == 1)
                                                        {
                                                        {
                                                                printf("\nINST *b%s%d INIT_%02X = ", outFileName.c_str(), j, k);
                                                                printf("\nINST *b%s%d INIT_%02X = ", outFileName.c_str(), j, k);
                                                        }
                                                        }
                                                        else
                                                        else
                                                        {
                                                        {
                                                                printf("\nINST *b%s%d%d INIT_%02X = ", outFileName.c_str(), i, j, k);
                                                                printf("\nINST *b%s%d%d INIT_%02X = ", outFileName.c_str(), i, j, k);
                                                        }
                                                        }
 
                                                        }
 
                                                        else
 
                                                        {
 
                                                                if (blockIter == 1)
 
                                                                {
 
                                                                        printf("\nINST *bG1_%d_B%s INIT_%02X = ", j, outFileName.c_str(), k);
 
                                                                }
 
                                                                else
 
                                                                {
 
                                                                        printf("\nINST *bG1_%d_bG2_%d_B%s INIT_%02X = ", i, j, outFileName.c_str(), k);
 
                                                                }
 
                                                        }
                                                        for (pos = 0; pos < 32; pos++)
                                                        for (pos = 0; pos < 32; pos++)
                                                        {
                                                        {
                                                                unsigned long addr;
                                                                unsigned long addr;
 
 
                                                                if (endian = 'l')
                                                                if (endian = 'l')

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.