arp: rx and decoding OK
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 30 Jan 2015 09:48:56 +0000 (10:48 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 30 Jan 2015 09:48:56 +0000 (10:48 +0100)
liteeth/common.py
liteeth/generic/depacketizer.py
liteeth/generic/packetizer.py
liteeth/test/arp_tb.py

index e68e4c49826b332d82ba30bcc7ecaebcc898e1c0..ddb14e2df3ae819a8d342131db31ca6a00faab50 100644 (file)
@@ -77,6 +77,13 @@ udp_header = {
        "checksum":                                     HField( 6,  0, 16)
 }
 
+def reverse_bytes(v):
+       n = math.ceil(flen(v)//8)
+       r = []
+       for i in reversed(range(n)):
+               r.append(v[i*8:min((i+1)*8, flen(v))])
+       return Cat(iter(r))
+
 # layouts
 def _layout_from_header(header):
        _layout = []
index e4525a0c5bfeeba8cb007f8475a8d9bc996c833b..39d11136265f00b2d3ce4f5233de811d8b3e6edf 100644 (file)
@@ -5,7 +5,7 @@ def _decode_header(h_dict, h_signal, obj):
        for k, v in sorted(h_dict.items()):
                start = v.byte*8+v.offset
                end = start+v.width
-               r.append(getattr(obj, k).eq(h_signal[start:end]))
+               r.append(getattr(obj, k).eq(reverse_bytes(h_signal[start:end])))
        return r
 
 class LiteEthDepacketizer(Module):
@@ -18,6 +18,12 @@ class LiteEthDepacketizer(Module):
                counter = Counter(max=header_length)
                self.submodules += counter
 
+               self.sync += [
+                       If(shift,
+                               header.eq(Cat(header[8:], sink.data))
+                       )
+               ]
+
                fsm = FSM(reset_state="IDLE")
                self.submodules += fsm
 
index 2aa161ef4426850922cfc8bcdf36c44cf4f4808a..4fb788f169c5d65e6dac9a0e660e1d9abaa3f584 100644 (file)
@@ -1,12 +1,4 @@
 from liteeth.common import *
-import math
-
-def reverse_bytes(v):
-       n = math.ceil(flen(v)//8)
-       r = []
-       for i in reversed(range(n)):
-               r.append(v[i*8:min((i+1)*8, flen(v))])
-       return Cat(iter(r))
 
 def _encode_header(h_dict, h_signal, obj):
        r = []
index b4629c8937dffe72457c9243a34ae2161558c421..e11a1101101000991cbe11c4311851493a018b53 100644 (file)
@@ -51,4 +51,4 @@ class TB(Module):
                selfp.arp.table.request.stb = 1
 
 if __name__ == "__main__":
-       run_simulation(TB(), ncycles=256, vcd_name="my.vcd", keep_files=True)
+       run_simulation(TB(), ncycles=1024, vcd_name="my.vcd", keep_files=True)