def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) self._enable_generator_rx = None self._enable_generator_tx = None self._enable_cr_rx = None self._enable_cr_tx = None cocotb.fork(Clock(dut.logic_clk, 8, units="ns").start()) cocotb.fork(Clock(dut.rx_clk, 8, units="ns").start()) cocotb.fork(Clock(dut.tx_clk, 8, units="ns").start()) self.gmii_source = GmiiSource(dut.gmii_rxd, dut.gmii_rx_er, dut.gmii_rx_dv, dut.rx_clk, dut.rx_rst, dut.rx_clk_enable, dut.rx_mii_select) self.gmii_sink = GmiiSink(dut.gmii_txd, dut.gmii_tx_er, dut.gmii_tx_en, dut.tx_clk, dut.tx_rst, dut.tx_clk_enable, dut.tx_mii_select) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.logic_clk, dut.logic_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.logic_clk, dut.logic_rst) dut.rx_clk_enable.setimmediatevalue(1) dut.tx_clk_enable.setimmediatevalue(1) dut.rx_mii_select.setimmediatevalue(0) dut.tx_mii_select.setimmediatevalue(0) dut.ifg_delay.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 10, units="ns").start()) # read interface self.read_desc_source = DescSource(dut, "s_axis_read_desc", dut.clk, dut.rst) self.read_desc_status_sink = DescStatusSink(dut, "m_axis_read_desc_status", dut.clk, dut.rst) self.read_data_sink = AxiStreamSink(dut, "m_axis_read_data", dut.clk, dut.rst) # write interface self.write_desc_source = DescSource(dut, "s_axis_write_desc", dut.clk, dut.rst) self.write_desc_status_sink = DescStatusSink( dut, "m_axis_write_desc_status", dut.clk, dut.rst) self.write_data_source = AxiStreamSource(dut, "s_axis_write_data", dut.clk, dut.rst) # AXI interface self.axi_ram = AxiRam(dut, "m_axi", dut.clk, dut.rst, size=2**16) dut.read_enable.setimmediatevalue(0) dut.write_enable.setimmediatevalue(0) dut.write_abort.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 10, units="ns").start()) # read interface self.read_desc_source = DescSource( DescBus.from_prefix(dut, "s_axis_read_desc"), dut.clk, dut.rst) self.read_desc_status_sink = DescStatusSink( DescStatusBus.from_prefix(dut, "m_axis_read_desc_status"), dut.clk, dut.rst) self.read_data_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "m_axis_read_data"), dut.clk, dut.rst) # AXI interface self.axi_ram = AxiRamRead(AxiReadBus.from_prefix(dut, "m_axi"), dut.clk, dut.rst, size=2**16) dut.enable.setimmediatevalue(0)
def __init__(self, dut, speed=1000e6): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.gtx_clk, 8, units="ns").start()) cocotb.fork(Clock(dut.logic_clk, 8, units="ns").start()) self.gmii_phy = GmiiPhy(dut.gmii_txd, dut.gmii_tx_er, dut.gmii_tx_en, dut.mii_tx_clk, dut.gmii_tx_clk, dut.gmii_rxd, dut.gmii_rx_er, dut.gmii_rx_dv, dut.gmii_rx_clk, speed=speed) self.axis_source = AxiStreamSource(dut, "tx_axis", dut.logic_clk, dut.logic_rst) self.axis_sink = AxiStreamSink(dut, "rx_axis", dut.logic_clk, dut.logic_rst) dut.ifg_delay.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) if len(dut.serdes_tx_data) == 64: cocotb.fork(Clock(dut.rx_clk, 6.4, units="ns").start()) cocotb.fork(Clock(dut.tx_clk, 6.4, units="ns").start()) else: cocotb.fork(Clock(dut.rx_clk, 3.2, units="ns").start()) cocotb.fork(Clock(dut.tx_clk, 3.2, units="ns").start()) self.serdes_source = BaseRSerdesSource(dut.serdes_rx_data, dut.serdes_rx_hdr, dut.rx_clk, slip=dut.serdes_rx_bitslip) self.serdes_sink = BaseRSerdesSink(dut.serdes_tx_data, dut.serdes_tx_hdr, dut.tx_clk) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.tx_clk, dut.tx_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.rx_clk, dut.rx_rst) dut.rx_ptp_ts.setimmediatevalue(0) dut.tx_ptp_ts.setimmediatevalue(0) dut.tx_prbs31_enable.setimmediatevalue(0) dut.rx_prbs31_enable.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) if len(dut.xgmii_txd) == 64: cocotb.fork(Clock(dut.logic_clk, 6.4, units="ns").start()) cocotb.fork(Clock(dut.rx_clk, 6.4, units="ns").start()) cocotb.fork(Clock(dut.tx_clk, 6.4, units="ns").start()) else: cocotb.fork(Clock(dut.logic_clk, 3.2, units="ns").start()) cocotb.fork(Clock(dut.rx_clk, 3.2, units="ns").start()) cocotb.fork(Clock(dut.tx_clk, 3.2, units="ns").start()) self.xgmii_source = XgmiiSource(dut.xgmii_rxd, dut.xgmii_rxc, dut.rx_clk, dut.rx_rst) self.xgmii_sink = XgmiiSink(dut.xgmii_txd, dut.xgmii_txc, dut.tx_clk, dut.tx_rst) self.axis_source = AxiStreamSource(dut, "tx_axis", dut.logic_clk, dut.logic_rst) self.axis_sink = AxiStreamSink(dut, "rx_axis", dut.logic_clk, dut.logic_rst) dut.ptp_sample_clk.setimmediatevalue(0) dut.ptp_ts_96.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) if len(dut.xgmii_txd) == 64: self.clk_period = 6.4 else: self.clk_period = 3.2 cocotb.start_soon( Clock(dut.rx_clk, self.clk_period, units="ns").start()) cocotb.start_soon( Clock(dut.tx_clk, self.clk_period, units="ns").start()) self.xgmii_source = XgmiiSource(dut.xgmii_rxd, dut.xgmii_rxc, dut.rx_clk, dut.rx_rst) self.xgmii_sink = XgmiiSink(dut.xgmii_txd, dut.xgmii_txc, dut.tx_clk, dut.tx_rst) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.tx_clk, dut.tx_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.rx_clk, dut.rx_rst) self.rx_ptp_clock = PtpClockSimTime(ts_64=dut.rx_ptp_ts, clock=dut.rx_clk) self.tx_ptp_clock = PtpClockSimTime(ts_64=dut.tx_ptp_ts, clock=dut.tx_clk) self.tx_ptp_ts_sink = PtpTsSink( PtpTsBus.from_prefix(dut, "tx_axis_ptp"), dut.tx_clk, dut.tx_rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) if len(dut.xgmii_txd) == 64: cocotb.start_soon(Clock(dut.rx_clk, 6.4, units="ns").start()) cocotb.start_soon(Clock(dut.tx_clk, 6.4, units="ns").start()) else: cocotb.start_soon(Clock(dut.rx_clk, 3.2, units="ns").start()) cocotb.start_soon(Clock(dut.tx_clk, 3.2, units="ns").start()) self.xgmii_source = XgmiiSource(dut.xgmii_rxd, dut.xgmii_rxc, dut.rx_clk, dut.rx_rst) self.xgmii_sink = XgmiiSink(dut.xgmii_txd, dut.xgmii_txc, dut.tx_clk, dut.tx_rst) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.tx_clk, dut.tx_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.rx_clk, dut.rx_rst) dut.rx_ptp_ts.setimmediatevalue(0) dut.tx_ptp_ts.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 8, units="ns").start()) self.header_source = EthHdrSource(EthHdrBus.from_prefix(dut, "s_eth"), dut.clk, dut.rst) self.payload_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "s_eth_payload_axis"), dut.clk, dut.rst) self.header_sink = EthHdrSink(EthHdrBus.from_prefix(dut, "m_eth"), dut.clk, dut.rst) self.payload_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "m_eth_payload_axis"), dut.clk, dut.rst) self.arp_req_source = ArpReqSource( ArpReqBus.from_prefix(dut, "arp_request"), dut.clk, dut.rst) self.arp_resp_sink = ArpRespSink( ArpRespBus.from_prefix(dut, "arp_response"), dut.clk, dut.rst) dut.local_mac.setimmediatevalue(0) dut.local_ip.setimmediatevalue(0) dut.gateway_ip.setimmediatevalue(0) dut.subnet_mask.setimmediatevalue(0) dut.clear_cache.setimmediatevalue(0)
def __init__(self, dut, speed=1000e6): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) self.rgmii_phy = RgmiiPhy(dut.rgmii_txd, dut.rgmii_tx_ctl, dut.rgmii_tx_clk, dut.rgmii_rxd, dut.rgmii_rx_ctl, dut.rgmii_rx_clk, speed=speed) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.tx_clk, dut.tx_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.rx_clk, dut.rx_rst) dut.ifg_delay.setimmediatevalue(0) dut.gtx_clk.setimmediatevalue(0) dut.gtx_clk90.setimmediatevalue(0) cocotb.start_soon(self._run_gtx_clk())
def __init__(self, dut): self.dut = dut self.log = SimLog(f"cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 2, units="ns").start()) self.source = AxiStreamSource(dut, "axis", dut.clk, dut.rst) self.sink = AxiStreamSink(dut, "axis", dut.clk, dut.rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 10, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.clk, dut.rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 4, units="ns").start()) self.source = AxiStreamSource(dut, "s_axis", dut.clk, dut.rst) self.sink = AxiStreamSink(dut, "m_axis", dut.clk, dut.rst) self.cmd_source = CsumCmdSource(dut, "s_axis_cmd", dut.clk, dut.rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 3.2, units="ns").start()) self.source = XgmiiSource(dut.xgmii_rxd, dut.xgmii_rxc, dut.clk, dut.rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) dut.ptp_ts.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 8, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.clk, dut.rst) self.header_sink = EthHdrSink(EthHdrBus.from_prefix(dut, "m_eth"), dut.clk, dut.rst) self.payload_sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_eth_payload_axis"), dut.clk, dut.rst)
def __init__(self, dut): self.dut = dut ports = int(os.getenv("PORTS")) self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 10, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.clk, dut.rst) self.sink = [AxiStreamSink(AxiStreamBus.from_prefix(dut, f"m{k:02d}_axis"), dut.clk, dut.rst) for k in range(ports)]
def __init__(self, dut): self.dut = dut s_count = len(dut.axis_ram_switch_inst.s_axis_tvalid) m_count = len(dut.axis_ram_switch_inst.m_axis_tvalid) self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 10, units="ns").start()) self.source = [AxiStreamSource(AxiStreamBus.from_prefix(dut, f"s{k:02d}_axis"), dut.clk, dut.rst) for k in range(s_count)] self.sink = [AxiStreamSink(AxiStreamBus.from_prefix(dut, f"m{k:02d}_axis"), dut.clk, dut.rst) for k in range(m_count)]
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 8, units="ns").start()) self.header_source = EthHdrSource(dut, "s_eth", dut.clk, dut.rst) self.payload_source = AxiStreamSource(dut, "s_eth_payload_axis", dut.clk, dut.rst) self.sink = AxiStreamSink(dut, "m_axis", dut.clk, dut.rst)
def __init__(self, dut, speed=100e6): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) self.mii_phy = MiiPhy(dut.mii_txd, dut.mii_tx_er, dut.mii_tx_en, dut.mii_tx_clk, dut.mii_rxd, dut.mii_rx_er, dut.mii_rx_dv, dut.mii_rx_clk, speed=speed) self.axis_source = AxiStreamSource(dut, "tx_axis", dut.tx_clk, dut.tx_rst) self.axis_sink = AxiStreamSink(dut, "rx_axis", dut.rx_clk, dut.rx_rst) dut.ifg_delay.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) s_clk = int(os.getenv("S_CLK", "10")) m_clk = int(os.getenv("M_CLK", "11")) cocotb.fork(Clock(dut.s_clk, s_clk, units="ns").start()) cocotb.fork(Clock(dut.m_clk, m_clk, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.s_clk, dut.s_rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.m_clk, dut.m_rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) self.source = XgmiiSource(dut.xgmii_rxd, dut.xgmii_rxc, dut.clk, dut.rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) self.ptp_clock = PtpClockSimTime(ts_64=dut.ptp_ts, clock=dut.clk)
def __init__(self, dut): self.dut = dut ports = int(os.getenv("PORTS")) self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 10, units="ns").start()) self.source = [AxiStreamSource(AxiStreamBus.from_prefix(dut, f"s{k:02d}_axis"), dut.clk, dut.rst) for k in range(ports)] self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) dut.enable.setimmediatevalue(0) dut.select.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut ports = len(dut.axis_arb_mux_inst.s_axis_tvalid) self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 10, units="ns").start()) self.source = [ AxiStreamSource(AxiStreamBus.from_prefix(dut, f"s{k:02d}_axis"), dut.clk, dut.rst) for k in range(ports) ] self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 6.4, units="ns").start()) self.source = BaseRSerdesSource(dut.encoded_rx_data, dut.encoded_rx_hdr, dut.clk, scramble=False) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) self.ptp_clock = PtpClockSimTime(ts_64=dut.ptp_ts, clock=dut.clk)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 10, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.clk, dut.rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) # Status self.status_sink = StatusSink(StatusBus.from_prefix(dut, "status"), dut.clk, dut.rst) self.dut.length_min.setimmediatevalue(0) self.dut.length_max.setimmediatevalue(2048)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 6.4, units="ns").start()) self.source = BaseRSerdesSource(dut.encoded_rx_data, dut.encoded_rx_hdr, dut.clk, scramble=False) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) dut.ptp_ts.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.start_soon(Clock(dut.clk, 10, units="ns").start()) self.source = AxiStreamSource(AxiStreamBus.from_prefix(dut, "s_axis"), dut.clk, dut.rst) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) dut.rate_num.setimmediatevalue(1) dut.rate_denom.setimmediatevalue(1) dut.rate_by_frame.setimmediatevalue(0)
def __init__(self, dut, baud=3e6): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) cocotb.fork(Clock(dut.clk, 8, units="ns").start()) self.source = UartSource(dut.rxd, baud=baud, bits=len(dut.m_axis_tdata), stop_bits=1) self.sink = AxiStreamSink(dut, "m_axis", dut.clk, dut.rst) dut.prescale.setimmediatevalue(int(1 / 8e-9 / baud / 8))
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) self._enable_generator = None self._enable_cr = None cocotb.fork(Clock(dut.clk, 8, units="ns").start()) self.source = GmiiSource(dut.gmii_rxd, dut.gmii_rx_er, dut.gmii_rx_dv, dut.clk, dut.rst, dut.clk_enable, dut.mii_select) self.sink = AxiStreamSink(AxiStreamBus.from_prefix(dut, "m_axis"), dut.clk, dut.rst) dut.clk_enable.setimmediatevalue(1) dut.mii_select.setimmediatevalue(0) dut.ptp_ts.setimmediatevalue(0)
def __init__(self, dut): self.dut = dut self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) if len(dut.serdes_tx_data) == 64: self.clk_period = 6.4 else: self.clk_period = 3.2 cocotb.start_soon( Clock(dut.logic_clk, self.clk_period, units="ns").start()) cocotb.start_soon( Clock(dut.rx_clk, self.clk_period, units="ns").start()) cocotb.start_soon( Clock(dut.tx_clk, self.clk_period, units="ns").start()) self.serdes_source = BaseRSerdesSource(dut.serdes_rx_data, dut.serdes_rx_hdr, dut.rx_clk, slip=dut.serdes_rx_bitslip) self.serdes_sink = BaseRSerdesSink(dut.serdes_tx_data, dut.serdes_tx_hdr, dut.tx_clk) self.axis_source = AxiStreamSource( AxiStreamBus.from_prefix(dut, "tx_axis"), dut.logic_clk, dut.logic_rst) self.axis_sink = AxiStreamSink( AxiStreamBus.from_prefix(dut, "rx_axis"), dut.logic_clk, dut.logic_rst) self.ptp_clock = PtpClockSimTime(ts_64=dut.ptp_ts_96, clock=dut.logic_clk) self.tx_ptp_ts_sink = PtpTsSink( PtpTsBus.from_prefix(dut, "tx_axis_ptp"), dut.tx_clk, dut.tx_rst) dut.ptp_sample_clk.setimmediatevalue(0) dut.ptp_ts_step.setimmediatevalue(0) dut.tx_prbs31_enable.setimmediatevalue(0) dut.rx_prbs31_enable.setimmediatevalue(0)