CPLD: Add output for PortaPack C++ CPLD data.
This commit is contained in:
@ -149,9 +149,10 @@ def make_sram_program(program_blocks):
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
action_group = parser.add_mutually_exclusive_group(required=True)
|
action_group = parser.add_argument_group(title='outputs')
|
||||||
action_group.add_argument('--checksum', action='store_true', help='Calculate bitstream read-back CRC32 value')
|
action_group.add_argument('--checksum', action='store_true', help='Print bitstream verification CRC32 value')
|
||||||
action_group.add_argument('--hackrf-data', type=str, help='C data file for HackRF bitstream loading/programming/verification')
|
action_group.add_argument('--hackrf-data', type=str, help='C data file for HackRF bitstream loading/programming/verification')
|
||||||
|
action_group.add_argument('--portapack-data', type=str, help='C++ data file for PortaPack bitstream loading/programming/verification')
|
||||||
parser.add_argument('--crcmod', action='store_true', help='Use Python crcmod library instead of built-in CRC32 code')
|
parser.add_argument('--crcmod', action='store_true', help='Use Python crcmod library instead of built-in CRC32 code')
|
||||||
parser.add_argument('--debug', action='store_true', help='Enable debug output')
|
parser.add_argument('--debug', action='store_true', help='Enable debug output')
|
||||||
parser.add_argument('--xsvf', required=True, type=str, help='HackRF Xilinx XC2C64A CPLD XSVF file containing erase/program/verify phases')
|
parser.add_argument('--xsvf', required=True, type=str, help='HackRF Xilinx XC2C64A CPLD XSVF file containing erase/program/verify phases')
|
||||||
@ -245,3 +246,33 @@ if args.hackrf_data:
|
|||||||
))
|
))
|
||||||
with open(args.hackrf_data, 'w') as f:
|
with open(args.hackrf_data, 'w') as f:
|
||||||
f.write('\n'.join(result))
|
f.write('\n'.join(result))
|
||||||
|
|
||||||
|
if args.portapack_data:
|
||||||
|
program_sram = make_sram_program(program_blocks)
|
||||||
|
verify_block = verify_blocks[1]
|
||||||
|
verify_masks = extract_mask(verify_block)
|
||||||
|
|
||||||
|
result = []
|
||||||
|
result.extend((
|
||||||
|
'/*',
|
||||||
|
' * WARNING: Auto-generated file. Do not edit.',
|
||||||
|
'*/',
|
||||||
|
'#include "hackrf_cpld_data.hpp"',
|
||||||
|
'namespace hackrf {',
|
||||||
|
'namespace one {',
|
||||||
|
'namespace cpld {',
|
||||||
|
'const ::cpld::xilinx::XC2C64A::verify_blocks_t verify_blocks { {',
|
||||||
|
))
|
||||||
|
data_lines = [', '.join(['0x%02x' % n for n in row['data'].to_bytes(bytes_of_data, byteorder='big')]) for row in program_sram]
|
||||||
|
mask_lines = [', '.join(['0x%02x' % n for n in mask.to_bytes(bytes_of_data, byteorder='big')]) for mask in verify_masks]
|
||||||
|
lines = ['{ 0x%02x, { { %s } }, { { %s } } }' % data for data in zip(address_sequence, data_lines, mask_lines)]
|
||||||
|
result.extend('\t%s,' % line for line in lines)
|
||||||
|
result.extend((
|
||||||
|
'} };',
|
||||||
|
'} /* namespace hackrf */',
|
||||||
|
'} /* namespace one */',
|
||||||
|
'} /* namespace cpld */',
|
||||||
|
'',
|
||||||
|
))
|
||||||
|
with open(args.portapack_data, 'w') as f:
|
||||||
|
f.write('\n'.join(result))
|
||||||
|
Reference in New Issue
Block a user