soc/tools/remote/etherbone: speed optimization (~20/30%)

This commit is contained in:
Florent Kermarrec 2017-07-17 00:25:58 +02:00
parent bdea4152e3
commit 20c859d45c
1 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,4 @@
import math import math
from copy import deepcopy
import struct import struct
from litex.soc.interconnect.stream_packet import HeaderField, Header from litex.soc.interconnect.stream_packet import HeaderField, Header
@ -44,14 +43,11 @@ etherbone_record_header = Header(etherbone_record_header_fields,
def split_bytes(v, n, endianness="big"): def split_bytes(v, n, endianness="big"):
r = [] r = []
r_bytes = v.to_bytes(n, byteorder=endianness) return v.to_bytes(n, byteorder=endianness)
for byte in r_bytes:
r.append(int(byte))
return r
def merge_bytes(b, endianness="big"): def merge_bytes(b, endianness="big"):
return int.from_bytes(bytes(b), endianness) return int.from_bytes(b, endianness)
def get_field_data(field, datas): def get_field_data(field, datas):
@ -304,8 +300,8 @@ class EtherbonePacket(Packet):
while len(payload) != 0: while len(payload) != 0:
record = EtherboneRecord(payload) record = EtherboneRecord(payload)
record.decode() record.decode()
records.append(deepcopy(record)) records.append(record)
payload = record payload = record[:]
return records return records
def decode(self): def decode(self):