Пример #1
0
import re

sys.path.append(os.path.join(os.path.join(sys.path[0], '..'), 'bitstream'))
from chips import ChipWithID, ChipOrPackageNamed
from utils import string_to_bits, bits_to_string

if len(sys.argv) < 3:
    print("usage: %s <input fasm file> <output asc file> [device_id]" %
          sys.argv[0])
    sys.exit(-1)

#
# Create bits for the bitstream
#
if len(sys.argv) < 4:
    chip = ChipWithID(0x00120010)
else:
    chip = ChipOrPackageNamed(sys.argv[3])

bits_by_tile = []
for col in range(0, chip.columns):
    col_bits = []
    for row in range(0, chip.rows):
        tile = chip.tile_at(col, row)
        if tile is None:
            col_bits.append([])
        else:
            col_bits.append(tile.empty_bits())
    bits_by_tile.append(col_bits)

bits_by_config = []
Пример #2
0
            break
elif spi_mark != 0xffff:
    # ffff is observed on AG1K spi flash bitstreams
    # _master.bin is identical to .bin, except
    # it comes with 0xffff at the start.
    reader.reset()

cur_pos = reader.pos
unknown_mark = reader.read32()
if unknown_mark != 0x967e3c5a:
    # This is seen on the AG16K bitstreams. 
    # It's purpose is unknown
    reader.seek(cur_pos)
    
device_id = reader.read32()
chip = ChipWithID(device_id)
if chip is None:
    print("Unexpected device id %s at pos %s" % (hex(device_id), reader.pos - 4))
    sys.exit(-1);


print(".device %s" % hex(device_id))

# ????
reader.require32(0x0000FFFF)

pos = reader.pos

lzw_marker = reader.read8()
if lzw_marker != 0x55:
    # Not lzw, roll-back the reader
Пример #3
0
        print_explain_data(data)


data = None
for line in lines:
    line = line.strip()
    if line.startswith("."):
        if data != None:
            print_data(data)

        data = None
        comps = line.split(" ")
        if len(comps) == 2:
            if comps[0] == ".device":
                chip_id = int(comps[1], 16)
                chip = ChipWithID(chip_id)
                assert (chip != None)
                print("%sdevice %s" %
                      ("# " if emit_fasm else ".", hex(chip.device_id)))
            elif comps[0] == ".config_chain":
                chain_id = int(comps[1])
                chain = chip.configChain[chain_id]
                data = {
                    'bits': [],
                    'owner': chain,
                    'header': line,
                    'args': {
                        'chain_id': chain_id
                    }
                }
        if len(comps) == 3:
Пример #4
0
#
# Parse the .asc file
#
entries = []
data = None
chip = None
for line in lines:
    line = line.strip()
    if line.startswith("."):
        data = None
        comps = line.split(" ")
        if len(comps) == 2:
            if comps[0] == ".device":
                chip_id = int(comps[1], 16)
                chip = ChipWithID(chip_id)
            elif comps[0] == ".config_chain":
                chain_id = int(comps[1])
                data = {'bits': [], 'type': 'chain', 'id': chain_id}
                entries.append(data)
        if len(comps) == 3:
            if chip != None:
                x = int(comps[1])
                y = int(comps[2])
                if x >= 0 and y >= 0:
                    data = {'x': x, 'y': y, 'type': 'tile', 'bits': []}
                    entries.append(data)
    elif len(line) > 0:
        if data != None:
            for char in line:
                if char == "0" or char == "1":
Пример #5
0
#
# Parse the .asc file
#
entries = []
data = None
chip = None
for line in lines:
    line = line.strip()
    if line.startswith("."):
        data = None
        comps = line.split(" ")
        if len(comps) == 2:
            if comps[0] == ".device":
                chip_id = int(comps[1], 16)
                chip = ChipWithID(chip_id)
            elif comps[0] == ".config_chain":
                chain_id = int(comps[1])
                data = {'bits': [], 'type': 'chain', 'id': chain_id}
                entries.append(data)
        if len(comps) == 3:
            if chip != None:
                x = int(comps[1])
                y = int(comps[2])
                if x >= 0 and y >= 0:
                    data = {'x': x, 'y': y, 'type': 'tile', 'bits': []}
                    entries.append(data)
    elif len(line) > 0:
        if data != None:
            for char in line:
                if char == "0" or char == "1":