Esempio n. 1
0
    def _respond(self):
        valid = bool(self.bus.cyc.getvalue()) and bool(self.bus.stb.getvalue())
        if hasattr(self.bus, "stall"):
            valid = valid and not bool(self.bus.stall.getvalue())

        if valid:
            # if there is a stall signal, take it into account
            # wait before replying ?
            waitAck = self._waitAckGen.next()
            # Response: rddata/don't care
            if not bool(self.bus.we.getvalue()):
                rd = self._datGen.next()
            else:
                rd = 0

            # Response: ack/err/rty
            reply = self._ackGen.next()
            if reply not in replyTypes:
                raise TestFailure(
                    "Tried to assign unknown reply type (%u) to slave reply. Valid is 1-3 (ack, err, rty)" % reply
                )

            wr = None
            if bool(self.bus.we.getvalue()):
                wr = self.bus.datwr.getvalue()

            # get the time the master idled since the last operation
            # TODO: subtract our own stalltime or, if we're not pipelined, time since last ack
            idleTime = self._clk_cycle_count - self._lastTime - 1
            res = wbr(
                ack=reply,
                sel=self.bus.sel.getvalue(),
                adr=self.bus.adr.getvalue(),
                datrd=rd,
                datwr=wr,
                waitIdle=idleTime,
                waitStall=self._stallCount,
                waitAck=waitAck,
            )
            # print "#ADR: 0x%08x,0x%x DWR: %s DRD: %s REP: %s IDL: %3u STL: %3u RWA: %3u" % (res.adr, res.sel, res.datwr, res.datrd, replyTypes[res.ack], res.waitIdle, res.waitStall, res.waitAck)

            # add whats going to happen to the result buffer
            self._res_buf.append(res)
            # add it to the reply queue for assignment. we need to process ops every cycle, so we can't do the <waitreply> delay here
            self._reply_Q.put(res)
            self._lastTime = self._clk_cycle_count
Esempio n. 2
0
 def _read(self):
     """
         Reader for slave replies
     """
     count = 0
     clkedge = RisingEdge(self.clock)
     while self.busy:
         reply = self._get_reply()    
         # valid reply?            
         if(bool(reply)):
             datrd = int(self.bus.datrd.getvalue())
             #append reply and meta info to result buffer
             tmpRes =  wbr(ack=reply, sel=None, adr=None, datrd=datrd, datwr=None, waitIdle=None, waitStall=None, waitAck=self._clk_cycle_count)               
             self._res_buf.append(tmpRes)
             self._acked_ops += 1
         yield clkedge
         count += 1