soc/interconnect/stream_packet: add check of field's width vs signal's width in Header.get_field

This commit is contained in:
Florent Kermarrec 2015-11-27 19:36:23 +01:00
parent c0539fff3e
commit d85d2b7b9b

View file

@ -118,6 +118,8 @@ class Header:
field = getattr(obj, name.replace("_msb", ""))[width:2*width] field = getattr(obj, name.replace("_msb", ""))[width:2*width]
else: else:
field = getattr(obj, name) field = getattr(obj, name)
if len(field) != width:
raise ValueError("Width mismatch on " + name + " field")
return field return field
def encode(self, obj, signal): def encode(self, obj, signal):