Skip to content

Commit

Permalink
applet.program.ecp5_sram: add method to decode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gregdavill committed Apr 25, 2020
1 parent 58b7459 commit 7184483
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
3 changes: 1 addition & 2 deletions software/glasgow/applet/program/ecp5_sram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ async def program(self, bitstream):
self.logger.info("Configuration Done")
else:
await self._check_status(status)
raise GlasgowAppletError("Configuration error. DONE not set",
bse_error_code[status.BSE_Error_Code])
raise GlasgowAppletError("Configuration error. DONE not set", status.BSEErrorCode())



Expand Down
34 changes: 32 additions & 2 deletions software/glasgow/arch/lattice/ecp5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
IR_ISC_ERASE = bits("00001110")
IR_LSC_BITSTREAM_BURST = bits("01111010")

LSC_Status = bitstruct("LSC_STATUS", 32, [
LSC_Status_bits = bitstruct("LSC_STATUS", 32, [
("Transparent_Mode", 1),
("Config_Target", 3),
("JTAG_Active", 1),
Expand Down Expand Up @@ -51,4 +51,34 @@
BSEErrorCode(0b101, "ABRT Error", "configuration aborted by the user" ),
BSEErrorCode(0b110, "OVFL Error", "data overflow error" ),
BSEErrorCode(0b111, "SDM Error", "bitstream pass the size of SRAM array"),
]
]

ConfigTargetCode = namedtuple("ConfigTargetCode", ("code","target"))

config_target_code = [
ConfigTargetCode(0b000, "SRAM"),
ConfigTargetCode(0b001, "eFuse"),
]

class LSC_Status(LSC_Status_bits):
def __init__(self):
...

def __iter__(self):
properties = {}
properties["Config Target"] = "{}".format(config_target_code[self.Config_Target])
properties["BSE Error Code"] = "{}".format(bse_error_code[self.BSE_Error_Code])

return iter(properties.items())

def BSEErrorCode(self):
return bse_error_code[self.BSE_Error_Code]

def flags_repl(self):
s = ""
for i in self:
s += " {}".format(i)
return s

def __repr__(self):
return "<{}.{} {}{}>".format(self.__module__, self.__class__.__name__, self.bits_repr(), self.flags_repl())

0 comments on commit 7184483

Please sign in to comment.