"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 = []
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):
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
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 = []
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)