bin2hex


Namebin2hex JSON
Version 2.1.0 PyPI version JSON
download
home_pageNone
Summarybin2hex is an utility to convert binary file to multiple types of hexadecimal text file
upload_time2025-09-15 15:21:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords bin2hex bin2vhx binary bin hexadecimal hex vhx denali verilog convert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bin2hex

## What is bin2hex

bin2hex is an utility to convert binary file to multiple types of hexadecimal text file

## How to use bin2hex

```
bin2hex [-h] [-v] [-i INPUT] [-o OUTPUT] [-f FORMAT] [-a ADDRESS] [-A ALIGNMENT]

options:
  -h, --help            show this help message and exit
  -v, --version         Show version information
  -i, --input INPUT     [Required] The raw binary input file to be converted
  -o, --output OUTPUT   [Required] The formatted hex output file to be converted to
  -f, --format FORMAT   [Optional] The format to be converted to. Default is "verilog_dw1"
  -a, --address ADDRESS
                        [Optional] The start address of the image. Not all formats require. Default is 0x0
  -A, --alignment ALIGNMENT
                        [Optional] The byte count per line. Default is various according to the format
```

## Supported text file types

### C
1. uint8:
- Convert to the c header file which can be included by C source file to init an 'uint8_t' table
- The option "alignment" is accepted as optional. Default is 16, which means 16 bytes per line
- The format will be:
```
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
0x10, 0x11 ......
```
2. uint16:
- Convert to the c header file which can be included by C source file to init an 'uint16_t' table
- The option "alignment" is accepted as optional. Default is 16, which means 16 bytes per line
- The format will be:
```
0x0100, 0x0302, 0x0504, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E
0x1110, 0x1312 ......
```
3. uint32:
- Convert to the c header file which can be included by C source file to init an 'uint32_t' table
- The option "alignment" is accepted as optional. Default is 16, which means 16 bytes per line
- The format will be:
```
0x03020100, 0x07060504, 0x0B0A0908, 0x0F0E0D0C,
0x13121110, 0x17161514 ......
```
4. uint64:
- Convert to the c header file which can be included by C source file to init an 'uint64_t' table.
- The option "alignment" is accepted as optional. Default is 16, which means 16 bytes per line
- The format will be:
```
0x0706050403020100, 0x0F0E0D0C0B0A0908,
0x1716151413121110,  ......
```
### Sim Model
1. Cadence Denali Model
- Convert to the file which can be used by Cadence denali model
- No option is accepted
- The format will be:
```
      0/00
      1/01
      ......
```

### Verilog HDL
1. Verilog Data Width 1-Byte:
- Convert to the file which can be loaded by $readmemh to a common memory with 1-byte(8-bit) width
- No option is accepted
- The format will be:
```
00
01
......
```

2. Verilog Data Width 2-Byte:
- Convert to the file which can be loaded by $readmemh to a common memory with 2-byte(16-bit) width
- No option is accepted
- The format will be:
```
0100
0302
......
```

3. Verilog Data Width 4-Byte:
- Convert to the file which can be loaded by $readmemh to a common memory with 4-byte(32-bit) width
- No option is accepted
- The format will be:
```
03020100
07060504
......
```

4. Verilog Data Width 8-Byte:
- Convert to the file which can be loaded by $readmemh to a common memory with 8-byte(64-bit) width
- No option is accepted
- The format will be:
```
0706050403020100
0F0E0D0C0B0A0908
......
```

5. Verilog Data Width 16-Byte:
- Convert to the file which can be loaded by $readmemh to a common memory with 16-byte(128-bit) width
- No option is accepted
- The format will be:
```
0F0E0D0C0B0A09080706050403020100
1F1E1D1C1B1A19181716151413121110
......
```

6. Verilog Data Width 1-Byte with Address:
- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 1-byte(8-bit) width
- The option "address" is accepted as optional. Default is 0x0
- The option "alignment" is accepted as optional. Default is 32 which means 32 bytes per line
- The format will be:
```
@0x00000000 00 01 02 03 ...... 1E 1F
@0x00000020 20 21 22 23 ...... 3E 3F
......
```

7. Verilog Data Width 2-Byte with Address:
- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 2-byte(16-bit) width
- The option "address" is accepted as optional. Default is 0x0
- The option "alignment" is accepted as optional. Default is 32 which means 32 bytes per line
- The format will be:
```
@0x00000000 0100 0302 0504 0706 ...... 1D1C 1F1E
@0x00000020 2120 2322 2524 2726 ...... 3D3C 3F3E
......
```

8. Verilog Data Width 4-Byte with Address:
- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 4-byte(32-bit) width
- The option "address" is accepted as optional. Default is 0x0
- The option "alignment" is accepted as optional. Default is 32 which means 32 bytes per line
- The format will be:
```
@0x00000000 03020100 07060504 0B0A0908 0F0E0D0C ...... 1B1A1918 1F1E1D1C
@0x00000020 23222120 27262524 2B2A2928 2F2E2D2C ...... 3B3A3938 3F3E3D3C
......
```

9. Verilog Data Width 8-Byte with Address:
- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 8-byte(64-bit) width
- The option "address" is accepted as optional. Default is 0x0
- The option "alignment" is accepted as optional. Default is 32 which means 32 bytes per line
- The format will be:
```
@0x00000000 0706050403020100 0F0E0D0C0B0A0908 1716151413121110 1F1E1D1C1B1A1918
@0x00000020 2726252423222120 2F2E2D2C2B2A2928 3736353433323130 3F3E3D3C3B3A3938
......
```

9. Verilog Data Width 16-Byte with Address:
- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 16-byte(128-bit) width
- The option "address" is accepted as optional. Default is 0x0
- The option "alignment" is accepted as optional. Default is 32 which means 32 bytes per line
- The format will be:
```
@0x00000000 0F0E0D0C0B0A09080706050403020100 1F1E1D1C1B1A19181716151413121110
@0x00000020 2F2E2D2C2B2A29282726252423222120 3F3E3D3C3B3A39383736353433323130
......
```

## Supported text file types
1. None:
- No ECC is added

2. ARM SECDED:
- Single Error Correction Double Error Detection (SECDED) code
- The ECC bits are appended to the MSB side of the data
- Only verilog_dwx (x = 4, 8, 16) formats support this ECC

3. User specific algorithm
- Custom ECC function defined in the specified Python file
- The Python file should define a function named ecc_encode
```
def ecc_encode(data: bytes, data_width: int) -> bytes
    # Add user specific algorithm here
    return data + ecc_bytes
```
- data is the input data in bytes
- data_width is the data width in bytes
- The function should return the data with ECC bits appended to the MSB side in bytes
- Only verilog_dwx (x = 1, 2, 4, 8, 16) formats support this ECC

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bin2hex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "bin2hex, bin2vhx, binary, bin, hexadecimal, hex, vhx, denali, verilog, convert",
    "author": null,
    "author_email": "Yitao Zhang <xtayyt@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/3c/5a/4749c58215cd5f053da5229dcf6c176986350cbd954af3297887263a2342/bin2hex-2.1.0.tar.gz",
    "platform": null,
    "description": "# bin2hex\n\n## What is bin2hex\n\nbin2hex is an utility to convert binary file to multiple types of hexadecimal text file\n\n## How to use bin2hex\n\n```\nbin2hex [-h] [-v] [-i INPUT] [-o OUTPUT] [-f FORMAT] [-a ADDRESS] [-A ALIGNMENT]\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --version         Show version information\n  -i, --input INPUT     [Required] The raw binary input file to be converted\n  -o, --output OUTPUT   [Required] The formatted hex output file to be converted to\n  -f, --format FORMAT   [Optional] The format to be converted to. Default is \"verilog_dw1\"\n  -a, --address ADDRESS\n                        [Optional] The start address of the image. Not all formats require. Default is 0x0\n  -A, --alignment ALIGNMENT\n                        [Optional] The byte count per line. Default is various according to the format\n```\n\n## Supported text file types\n\n### C\n1. uint8:\n- Convert to the c header file which can be included by C source file to init an 'uint8_t' table\n- The option \"alignment\" is accepted as optional. Default is 16, which means 16 bytes per line\n- The format will be:\n```\n0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F\n0x10, 0x11 ......\n```\n2. uint16:\n- Convert to the c header file which can be included by C source file to init an 'uint16_t' table\n- The option \"alignment\" is accepted as optional. Default is 16, which means 16 bytes per line\n- The format will be:\n```\n0x0100, 0x0302, 0x0504, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E\n0x1110, 0x1312 ......\n```\n3. uint32:\n- Convert to the c header file which can be included by C source file to init an 'uint32_t' table\n- The option \"alignment\" is accepted as optional. Default is 16, which means 16 bytes per line\n- The format will be:\n```\n0x03020100, 0x07060504, 0x0B0A0908, 0x0F0E0D0C,\n0x13121110, 0x17161514 ......\n```\n4. uint64:\n- Convert to the c header file which can be included by C source file to init an 'uint64_t' table.\n- The option \"alignment\" is accepted as optional. Default is 16, which means 16 bytes per line\n- The format will be:\n```\n0x0706050403020100, 0x0F0E0D0C0B0A0908,\n0x1716151413121110,  ......\n```\n### Sim Model\n1. Cadence Denali Model\n- Convert to the file which can be used by Cadence denali model\n- No option is accepted\n- The format will be:\n```\n      0/00\n      1/01\n      ......\n```\n\n### Verilog HDL\n1. Verilog Data Width 1-Byte:\n- Convert to the file which can be loaded by $readmemh to a common memory with 1-byte(8-bit) width\n- No option is accepted\n- The format will be:\n```\n00\n01\n......\n```\n\n2. Verilog Data Width 2-Byte:\n- Convert to the file which can be loaded by $readmemh to a common memory with 2-byte(16-bit) width\n- No option is accepted\n- The format will be:\n```\n0100\n0302\n......\n```\n\n3. Verilog Data Width 4-Byte:\n- Convert to the file which can be loaded by $readmemh to a common memory with 4-byte(32-bit) width\n- No option is accepted\n- The format will be:\n```\n03020100\n07060504\n......\n```\n\n4. Verilog Data Width 8-Byte:\n- Convert to the file which can be loaded by $readmemh to a common memory with 8-byte(64-bit) width\n- No option is accepted\n- The format will be:\n```\n0706050403020100\n0F0E0D0C0B0A0908\n......\n```\n\n5. Verilog Data Width 16-Byte:\n- Convert to the file which can be loaded by $readmemh to a common memory with 16-byte(128-bit) width\n- No option is accepted\n- The format will be:\n```\n0F0E0D0C0B0A09080706050403020100\n1F1E1D1C1B1A19181716151413121110\n......\n```\n\n6. Verilog Data Width 1-Byte with Address:\n- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 1-byte(8-bit) width\n- The option \"address\" is accepted as optional. Default is 0x0\n- The option \"alignment\" is accepted as optional. Default is 32 which means 32 bytes per line\n- The format will be:\n```\n@0x00000000 00 01 02 03 ...... 1E 1F\n@0x00000020 20 21 22 23 ...... 3E 3F\n......\n```\n\n7. Verilog Data Width 2-Byte with Address:\n- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 2-byte(16-bit) width\n- The option \"address\" is accepted as optional. Default is 0x0\n- The option \"alignment\" is accepted as optional. Default is 32 which means 32 bytes per line\n- The format will be:\n```\n@0x00000000 0100 0302 0504 0706 ...... 1D1C 1F1E\n@0x00000020 2120 2322 2524 2726 ...... 3D3C 3F3E\n......\n```\n\n8. Verilog Data Width 4-Byte with Address:\n- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 4-byte(32-bit) width\n- The option \"address\" is accepted as optional. Default is 0x0\n- The option \"alignment\" is accepted as optional. Default is 32 which means 32 bytes per line\n- The format will be:\n```\n@0x00000000 03020100 07060504 0B0A0908 0F0E0D0C ...... 1B1A1918 1F1E1D1C\n@0x00000020 23222120 27262524 2B2A2928 2F2E2D2C ...... 3B3A3938 3F3E3D3C\n......\n```\n\n9. Verilog Data Width 8-Byte with Address:\n- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 8-byte(64-bit) width\n- The option \"address\" is accepted as optional. Default is 0x0\n- The option \"alignment\" is accepted as optional. Default is 32 which means 32 bytes per line\n- The format will be:\n```\n@0x00000000 0706050403020100 0F0E0D0C0B0A0908 1716151413121110 1F1E1D1C1B1A1918\n@0x00000020 2726252423222120 2F2E2D2C2B2A2928 3736353433323130 3F3E3D3C3B3A3938\n......\n```\n\n9. Verilog Data Width 16-Byte with Address:\n- Convert to the file which can be loaded by $readmemh to a specific offset of a common memory with 16-byte(128-bit) width\n- The option \"address\" is accepted as optional. Default is 0x0\n- The option \"alignment\" is accepted as optional. Default is 32 which means 32 bytes per line\n- The format will be:\n```\n@0x00000000 0F0E0D0C0B0A09080706050403020100 1F1E1D1C1B1A19181716151413121110\n@0x00000020 2F2E2D2C2B2A29282726252423222120 3F3E3D3C3B3A39383736353433323130\n......\n```\n\n## Supported text file types\n1. None:\n- No ECC is added\n\n2. ARM SECDED:\n- Single Error Correction Double Error Detection (SECDED) code\n- The ECC bits are appended to the MSB side of the data\n- Only verilog_dwx (x = 4, 8, 16) formats support this ECC\n\n3. User specific algorithm\n- Custom ECC function defined in the specified Python file\n- The Python file should define a function named ecc_encode\n```\ndef ecc_encode(data: bytes, data_width: int) -> bytes\n    # Add user specific algorithm here\n    return data + ecc_bytes\n```\n- data is the input data in bytes\n- data_width is the data width in bytes\n- The function should return the data with ECC bits appended to the MSB side in bytes\n- Only verilog_dwx (x = 1, 2, 4, 8, 16) formats support this ECC\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "bin2hex is an utility to convert binary file to multiple types of hexadecimal text file",
    "version": "2.1.0",
    "project_urls": {
        "Changelog": "https://github.com/xtayyt/bin2hex/blob/master/CHANGELOG.md",
        "Homepage": "https://github.com/xtayyt/bin2hex",
        "Issues": "https://github.com/xtayyt/bin2hex/issues",
        "Repository": "https://github.com/xtayyt/bin2hex.git"
    },
    "split_keywords": [
        "bin2hex",
        " bin2vhx",
        " binary",
        " bin",
        " hexadecimal",
        " hex",
        " vhx",
        " denali",
        " verilog",
        " convert"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c27797519f919ee18658405c662ef68c72804c9ba907171dba724c7ad293a550",
                "md5": "9daad353945202bec427e2fd31f34d42",
                "sha256": "8b3c2db54b57c503aaa799e70bbbf7bf3f35ff17c41978776472281e10775f72"
            },
            "downloads": -1,
            "filename": "bin2hex-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9daad353945202bec427e2fd31f34d42",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12346,
            "upload_time": "2025-09-15T15:21:48",
            "upload_time_iso_8601": "2025-09-15T15:21:48.411023Z",
            "url": "https://files.pythonhosted.org/packages/c2/77/97519f919ee18658405c662ef68c72804c9ba907171dba724c7ad293a550/bin2hex-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3c5a4749c58215cd5f053da5229dcf6c176986350cbd954af3297887263a2342",
                "md5": "b237c5370d10fa0672b4422d8a6a79fe",
                "sha256": "4ebc2871608258e2e2c212297ff6bf97076215354696dc86072c98591e0019ef"
            },
            "downloads": -1,
            "filename": "bin2hex-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b237c5370d10fa0672b4422d8a6a79fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15324,
            "upload_time": "2025-09-15T15:21:49",
            "upload_time_iso_8601": "2025-09-15T15:21:49.737760Z",
            "url": "https://files.pythonhosted.org/packages/3c/5a/4749c58215cd5f053da5229dcf6c176986350cbd954af3297887263a2342/bin2hex-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-15 15:21:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xtayyt",
    "github_project": "bin2hex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bin2hex"
}
        
Elapsed time: 1.04597s