Esempio n. 1
0
    def __init__(self, dw=32):
        self.sink = sink = Endpoint(eth_udp_user_description(dw))
        self.source = source = Endpoint(K2MMPacket.packet_user_description(dw))

        # # #

        self.submodules.dpkt0 = depacketizer = Depacketizer(
            sink.description, K2MMPacket.packet_description(dw),
            K2MMPacket.get_header(dw))
        self.comb += self.sink.connect(depacketizer.sink)

        self.submodules.fsm = fsm = FSM(reset_state="IDLE")
        fsm.act(
            "IDLE",
            If(
                depacketizer.source.valid, NextState("DROP"),
                If(depacketizer.source.magic == K2MMPacket.magic,
                   NextState("RECEIVE"))))
        self.comb += [
            # FIXME: flag for "user" header fields
            depacketizer.source.connect(
                source, keep={"last", "pf", "pr", "nr", "data"}),
            source.src_port.eq(sink.src_port),
            source.dst_port.eq(sink.dst_port),
            source.ip_address.eq(sink.ip_address),
            source.length.eq(sink.length - K2MMPacket.get_header(dw).length)
        ]
        fsm.act(
            "RECEIVE",
            depacketizer.source.connect(source, keep={"valid", "ready"}),
            If(source.valid & source.ready, If(source.last,
                                               NextState("IDLE"))))
        fsm.act(
            "DROP", depacketizer.source.ready.eq(1),
            If(
                depacketizer.source.valid & depacketizer.source.last
                & depacketizer.source.ready, NextState("IDLE")))
Esempio n. 2
0
 def __init__(self, dw=8):
     Depacketizer.__init__(self, eth_ipv4_user_description(dw),
                           eth_udp_description(dw), udp_header)
Esempio n. 3
0
 def __init__(self, dw=8):
     Depacketizer.__init__(self, eth_mac_description(dw),
                           eth_ipv4_description(dw), ipv4_header)
Esempio n. 4
0
 def __init__(self, dw):
     Depacketizer.__init__(self, eth_phy_description(dw),
                           eth_mac_description(dw), mac_header)
Esempio n. 5
0
 def __init__(self, dw=8):
     Depacketizer.__init__(self, eth_mac_description(dw),
                           eth_arp_description(dw), arp_header)