diff --git a/firmware/src/mmc3_m26_eth.v b/firmware/src/mmc3_m26_eth.v index f29e3ad..e74d91b 100644 --- a/firmware/src/mmc3_m26_eth.v +++ b/firmware/src/mmc3_m26_eth.v @@ -1,4 +1,4 @@ - +localparam VERSION = 8'd01; module mmc3_m26_eth( input wire RESET_N, @@ -341,6 +341,31 @@ localparam M26_RX_HIGHADDR = 32'ha00f-1; localparam GPIO_BASEADDR = 32'hb000; localparam GPIO_HIGHADDR = 32'hb01f; + +// VERSION READBACk +reg [7:0] BUS_DATA_OUT_REG; +always @ (posedge BUS_CLK) begin + if(BUS_RD) begin + if(BUS_ADD == 0) + BUS_DATA_OUT_REG <= VERSION[7:0]; + //else if(BUS_ADD == 1) + // BUS_DATA_OUT_REG <= VERSION[15:8]; + //else if(BUS_ADD == 2) + //BUS_DATA_OUT_REG <= BOARD[7:0]; + //else if(BUS_ADD == 3) + //BUS_DATA_OUT_REG <= BOARD[15:8]; + end +end + +reg READ_VER; +always @ (posedge BUS_CLK) + if(BUS_RD & BUS_ADD < 2) + READ_VER <= 1; + else + READ_VER <= 0; + +assign BUS_DATA[7:0] = READ_VER ? BUS_DATA_OUT_REG : 8'hzz; + // ------- USER MODULES ------- // ///////////////////// M26 JTAG diff --git a/pymosa/m26.py b/pymosa/m26.py index 6ebdee0..9cbc365 100644 --- a/pymosa/m26.py +++ b/pymosa/m26.py @@ -65,6 +65,9 @@ class m26(Dut): Note: Setup run and trigger in configuration file (e.g. configuration.yaml) ''' + + VERSION = 1 # required version for mmc3_m26_eth.v + def __init__(self, conf=None, context=None, socket_address=None): self.meta_data_dtype = np.dtype([('index_start', 'u4'), ('index_stop', 'u4'), ('data_length', 'u4'), ('timestamp_start', 'f8'), ('timestamp_stop', 'f8'), ('error', 'u4')]) @@ -91,11 +94,11 @@ def __init__(self, conf=None, context=None, socket_address=None): def init(self, **kwargs): super(m26, self).init() - # TODO: version control -# fw_version = self['intf'].read(0x2000, 1)[0] -# logging.info("MMC3 firmware version: %s" % (fw_version)) -# if fw_version != self.VERSION: -# raise Exception("MMC3 firmware version does not satisfy version requirements (read: %s, require: %s)" % (fw_version, self.VERSION)) + # check firmware version + fw_version = self['ETH'].read(0x0000, 1)[0] + logging.info("MMC3 firmware version: %s" % (fw_version)) + if fw_version != self.VERSION: + raise Exception("MMC3 firmware version does not satisfy version requirements (read: %s, require: %s)" % (fw_version, self.VERSION)) logging.info('Initializing %s', self.__class__.__name__)