Ejemplo n.º 1
0
    def queueWrite(self, name, dataU32, addrOffset = 0):
        """Create a register write (RMW-bits) transaction element and add it to the transaction queue.
        
        This works in the same way as a normal write(), except that many can be queued
        into a packet and dispatched all at once rather than individually.  Run the
        queued transactions with queueRun().
        
        Only single-register reads/writes can be queued.  Block reads/writes, etc, cannot
        be queued.
        """

        if len(self._queuedRequests) < ChipsBus.MAX_QUEUED_REQUESTS:
        
            dataU32 = dataU32 & 0xffffffff # Ignore oversize input.
            chipsLog.debug("Write queued: dataU32 = 0x" + uInt32HexStr(dataU32) + " to register '"
                           + name + "' with addrOffset = 0x" + uInt32HexStr(addrOffset))
        
            addrTableItem = self.addrTable.getItem(name) # Get the details of the relevant item from the addr table.
        
            if not addrTableItem.getWriteFlag():
                raise ChipsException("Write transaction creation error: write is not allowed on register '" +  addrTableItem.getName() + "'.")       
        
            self._queuedRequests.append(self._createRMWBitsTransactionElement(addrTableItem, dataU32, addrOffset))
            self._queuedAddrTableItems.append(addrTableItem)
            self._queuedIsARead.append(False)
            
        else:
            chipsLog.warning("Warning: transaction not added to queue as transaction queue has reached its maximum length!\n" +
                             "\tPlease either run or clear the transaction queue before continuing.\n")
Ejemplo n.º 2
0
    def queueWrite(self, name, dataU32, addrOffset = 0):
        """Create a register write (RMW-bits) transaction element and add it to the transaction queue.

        This works in the same way as a normal write(), except that many can be queued
        into a packet and dispatched all at once rather than individually.  Run the
        queued transactions with queueRun().

        Only single-register reads/writes can be queued.  Block reads/writes, etc, cannot
        be queued.
        """

        if len(self._queuedRequests) < ChipsBus.MAX_QUEUED_REQUESTS:

            dataU32 = dataU32 & 0xffffffff # Ignore oversize input.
            chipsLog.debug("Write queued: dataU32 = 0x" + uInt32HexStr(dataU32) + " to register '"
                           + name + "' with addrOffset = 0x" + uInt32HexStr(addrOffset))

            addrTableItem = self.addrTable.getItem(name) # Get the details of the relevant item from the addr table.

            if not addrTableItem.getWriteFlag():
                raise ChipsException("Write transaction creation error: write is not allowed on register '" +  addrTableItem.getName() + "'.")

            # self._queuedRequests.append(self._createRMWBitsTransactionElement(addrTableItem, dataU32, addrOffset))
            # self._queuedAddrTableItems.append(addrTableItem)
            # self._queuedIsARead.append(False)

            self._queuedRequests.append(self._createWriteTransactionElement(addrTableItem, [dataU32], addrOffset))
            self._queuedAddrTableItems.append(addrTableItem)
            self._queuedIsARead.append(False)

        else:
            chipsLog.warning("Warning: transaction not added to queue as transaction queue has reached its maximum length!\n" +
                             "\tPlease either run or clear the transaction queue before continuing.\n")
Ejemplo n.º 3
0
    def write(self, name, dataU32, addrOffset=0):
        """Write to a single register (masked, or otherwise).

        This write transaction runs straight away - i.e it's not queued at all.
        Warning: using this method clears any previously queued transactions
            that have not yet been run!

        name: the register name of the register you want to read from.
        dataU32: the 32-bit value you want writing
        addrOffset: optional - provide a 32-bit word offset if you wish.

        Notes:
            Use the addrOffset at your own risk!  No checking is done to
                see if offsets are remotely sensible!
            Under the hood, this is implemented as an RMW-bits transaction.
        """

        if len(self._queuedRequests):
            chipsLog.warning("Warning: Individual write requested, clearing previously queued transactions!\n")
            self.queueClear()

        dataU32 = dataU32 & 0xffffffff # Ignore oversize input.

        self.queueWrite(name, dataU32, addrOffset)

        self.queueRun()
Ejemplo n.º 4
0
    def write(self, name, dataU32, addrOffset=0):
        """Write to a single register (masked, or otherwise).

        This write transaction runs straight away - i.e it's not queued at all.   
        Warning: using this method clears any previously queued transactions 
            that have not yet been run!
        
        name: the register name of the register you want to read from.
        dataU32: the 32-bit value you want writing
        addrOffset: optional - provide a 32-bit word offset if you wish.
        
        Notes:
            Use the addrOffset at your own risk!  No checking is done to
                see if offsets are remotely sensible!
            Under the hood, this is implemented as an RMW-bits transaction.
        """
        
        if len(self._queuedRequests):
            chipsLog.warning("Warning: Individual write requested, clearing previously queued transactions!\n")
            self.queueClear()
        
        dataU32 = dataU32 & 0xffffffff # Ignore oversize input.
        
        self.queueWrite(name, dataU32, addrOffset)
        
        self.queueRun()
Ejemplo n.º 5
0
    def read(self, name, addrOffset=0):
        """Read from a single masked/unmasked 32-bit register.  The result is returned from the function.

        This read transaction runs straight away - i.e it's not queued at all.
        Warning: using this method clears any previously queued transactions
            that have not yet been run!

        name: the register name of the register you want to read from.
        addrOffset: optional - provide a 32-bit word offset if you wish.

        Notes: Use the addrOffset at your own risk!  No checking is done to
            see if offsets are remotely sensible!
        """

        if len(self._queuedRequests):
            chipsLog.warning(
                "Warning: Individual read requested, clearing previously queued transactions!\n"
            )
            self.queueClear()

        self.queueRead(name, addrOffset)

        result = self.queueRun()

        return result[0][0]
Ejemplo n.º 6
0
    def serveForever(self):
        """The only function any user of this class needs to run!
        
        Receives, acts on, and responds to TCP control packets as the Mini-T (or similar hardware) would.
        Packets are received by the main thread and queued for action and response by a second thread.
        """
        chipsLog.info("Dummy Hardware TCP Server starting")
        # This starts the packet "act and respond" handler thread
        self.start()

        try:
            chipsLog.debug("Awaiting connection...")
            self._connectedSocket, addr = self._socket.accept()  # TCP
            chipsLog.debug("Client connection accepted.")
        except KeyboardInterrupt:
            chipsLog.warning(
                "\nKeyboard interrupt (ctrl-c) received whilst waiting for a TCP connection"
            )
            self._stopServingAndJoinThreads()
            return

        while not self.stopServing:
            try:
                data = self._connectedSocket.recv(
                    DummyHardware.SOCKET_BUFFER_SIZE)  # TCP
            except KeyboardInterrupt:
                chipsLog.warning(
                    "\nKeyboard interrupt (ctrl-c) received whilst waiting for incoming TCP packet"
                )
                self._stopServingAndJoinThreads()
                return
            except:
                chipsLog.warning(
                    "\nException caught whilst waiting for incoming TCP packet"
                )
                self._stopServingAndJoinThreads()
                return

            if not data:
                chipsLog.debug("TCP socket received an empty packet from " +
                               repr(addr) + ": assuming connection closed.")
                try:
                    chipsLog.debug("Awaiting new connection...")
                    self._connectedSocket, addr = self._socket.accept()  # TCP
                    chipsLog.debug("Client connection accepted.")
                    continue
                except KeyboardInterrupt:
                    chipsLog.warning(
                        "\nKeyboard interrupt (ctrl-c) received whilst waiting for a TCP connection"
                    )
                    self._stopServingAndJoinThreads()
                    return

            chipsLog.debug("\nReceived TCP packet from " + repr(addr))
            transaction = Transaction.constructHostTransaction(data, addr)
            self._transaction_queue.put(transaction)

        chipsLog.info("Dummy Hardware TCP Server stopping.")
Ejemplo n.º 7
0
    def serveForever(self):
        """The only function any user of this class needs to run!
        
        Receives, acts on, and responds to UDP control packets as the Mini-T (or similar hardware) would.
        Packets are received by the main thread and queued for action and response by a second thread.
        """
        chipsLog.info("Dummy Hardware UDP Server starting")
        # This starts the packet "act and respond" handler thread
        self.start()

        while not self.stopServing:
            try:
                data, addr = self._socket.recvfrom(DummyHardware.SOCKET_BUFFER_SIZE)
            except KeyboardInterrupt:
                chipsLog.warning("\nKeyboard interrupt (ctrl-c) received whilst waiting for incoming UDP packet")
                self._stopServingAndJoinThreads()
                return
            except:
                chipsLog.warning("\nException caught whilst waiting for incoming UDP packet")
                self._stopServingAndJoinThreads()
                return

            if not data:
                chipsLog.warning("Socket received an empty packet from " + repr(addr) + \
                                 ".  Assuming socket now closed.\nTerminating dummy hardware server...")
                self._stopServingAndJoinThreads()
                return
            else:
                chipsLog.debug("\nReceived packet from " + repr(addr))
                transaction = Transaction.constructHostTransaction(data, addr)
                self._transaction_queue.put(transaction)
Ejemplo n.º 8
0
    def serveForever(self):
        """The only function any user of this class needs to run!
        
        Receives, acts on, and responds to TCP control packets as the Mini-T (or similar hardware) would.
        Packets are received by the main thread and queued for action and response by a second thread.
        """
        chipsLog.info("Dummy Hardware TCP Server starting")
        # This starts the packet "act and respond" handler thread
        self.start()

        try:
            chipsLog.debug("Awaiting connection...")
            self._connectedSocket, addr = self._socket.accept()  # TCP
            chipsLog.debug("Client connection accepted.")            
        except KeyboardInterrupt:
            chipsLog.warning("\nKeyboard interrupt (ctrl-c) received whilst waiting for a TCP connection")
            self._stopServingAndJoinThreads()
            return            

        while not self.stopServing:
            try:
                data = self._connectedSocket.recv(DummyHardware.SOCKET_BUFFER_SIZE)  # TCP
            except KeyboardInterrupt:
                chipsLog.warning("\nKeyboard interrupt (ctrl-c) received whilst waiting for incoming TCP packet")
                self._stopServingAndJoinThreads()
                return
            except:
                chipsLog.warning("\nException caught whilst waiting for incoming TCP packet")
                self._stopServingAndJoinThreads()
                return

            if not data:
                chipsLog.debug("TCP socket received an empty packet from " + repr(addr) + ": assuming connection closed.")
                try:
                    chipsLog.debug("Awaiting new connection...")
                    self._connectedSocket, addr = self._socket.accept()  # TCP
                    chipsLog.debug("Client connection accepted.")            
                    continue
                except KeyboardInterrupt:
                    chipsLog.warning("\nKeyboard interrupt (ctrl-c) received whilst waiting for a TCP connection")
                    self._stopServingAndJoinThreads()
                    return            

            chipsLog.debug("\nReceived TCP packet from " + repr(addr))
            transaction = Transaction.constructHostTransaction(data, addr)
            self._transaction_queue.put(transaction)

        chipsLog.info("Dummy Hardware TCP Server stopping.")
Ejemplo n.º 9
0
 def read(self, name, addrOffset=0):
     """Read from a single masked/unmasked 32-bit register.  The result is returned from the function.
     
     This read transaction runs straight away - i.e it's not queued at all.   
     Warning: using this method clears any previously queued transactions
         that have not yet been run!
     
     name: the register name of the register you want to read from.
     addrOffset: optional - provide a 32-bit word offset if you wish.
     
     Notes: Use the addrOffset at your own risk!  No checking is done to
         see if offsets are remotely sensible!
     """
     
     if len(self._queuedRequests):
         chipsLog.warning("Warning: Individual read requested, clearing previously queued transactions!\n")
         self.queueClear()
     
     self.queueRead(name, addrOffset)
     
     result = self.queueRun()
     
     return result[0][0]
Ejemplo n.º 10
0
    def serveForever(self):
        """The only function any user of this class needs to run!
        
        Receives, acts on, and responds to UDP control packets as the Mini-T (or similar hardware) would.
        Packets are received by the main thread and queued for action and response by a second thread.
        """
        chipsLog.info("Dummy Hardware UDP Server starting")
        # This starts the packet "act and respond" handler thread
        self.start()

        while not self.stopServing:
            try:
                data, addr = self._socket.recvfrom(
                    DummyHardware.SOCKET_BUFFER_SIZE)
            except KeyboardInterrupt:
                chipsLog.warning(
                    "\nKeyboard interrupt (ctrl-c) received whilst waiting for incoming UDP packet"
                )
                self._stopServingAndJoinThreads()
                return
            except:
                chipsLog.warning(
                    "\nException caught whilst waiting for incoming UDP packet"
                )
                self._stopServingAndJoinThreads()
                return

            if not data:
                chipsLog.warning("Socket received an empty packet from " + repr(addr) + \
                                 ".  Assuming socket now closed.\nTerminating dummy hardware server...")
                self._stopServingAndJoinThreads()
                return
            else:
                chipsLog.debug("\nReceived packet from " + repr(addr))
                transaction = Transaction.constructHostTransaction(data, addr)
                self._transaction_queue.put(transaction)
Ejemplo n.º 11
0
 def __init__(self, port = 50001):
     DummyHardwareUdp.__init__(self, port)
     chipsLog.warning("Please note: this class has been deprecated - use DummyHardwareUdp in the future.")
Ejemplo n.º 12
0
 def __init__(self, addrTable, hostIp, hostPort, localPort = None):
     ChipsBusUdp.__init__(self, addrTable, hostIp, hostPort, localPort)
     chipsLog.warning("Please note: this class has been deprecated - use ChipsBusUdp"\
                      " in the future if you want the same functionality.")
Ejemplo n.º 13
0
 def __init__(self, addrTable, hostIp, hostPort, localPort = None):
     ChipsBusUdp.__init__(self, addrTable, hostIp, hostPort, localPort)
     chipsLog.warning("Please note: this class has been deprecated - use ChipsBusUdp"\
                      " in the future if you want the same functionality.")
Ejemplo n.º 14
0
        
            chipsLog.debug("Read queued: register '" + name + "' with addrOffset = 0x" + uInt32HexStr(addrOffset))
        
            item = self.addrTable.getItem(name) # Get the details of the relevant item from the addr table.
        
            try:
                self._checkRWFlag(item)
            except ChipsException, err:
                raise ChipsException("Read error on register '" + name + "':\n\t" + str(err))
        
            self._transactionQueue.append(self._createReadTransactionElement(item, 1, addrOffset))
            self._transactionItemQueue.append(item)
            self._transactionRWFlagQueue.append(1)
            
        else:
            chipsLog.warning("Warning: transaction not added to queue as transaction queue has reached its maximum length!\n" +
                             "\tPlease either run or clear the transaction queue before continuing.\n")
                
        
    def queueWrite(self, name, dataU32, addrOffset = 0):
        """Create a register write (RMW-bits) transaction element and add it to the transaction queue.
        
        This works in the same way as a normal write(), except that many can be queued
        into a packet and dispatched all at once rather than individually.  Run the
        queued transactions with queueRun().
        
        Only single-register reads/writes can be queued.  Block reads/writes, etc, cannot
        be queued.
        """

        if len(self._transactionQueue) <= 50:
        
Ejemplo n.º 15
0
 def __init__(self, port=50001):
     DummyHardwareUdp.__init__(self, port)
     chipsLog.warning(
         "Please note: this class has been deprecated - use DummyHardwareUdp in the future."
     )