###
-
def _optimize_eq(l):
"""
Replace even numbers of XORs in the equation
polynom = 0x04C11DB7
init = 0x52325032
check = 0xC704DD7B
- def __init__(self):
+ def __init__(self, dw=32):
self.d = Signal(self.width)
self.value = Signal(self.width)
self.error = Signal()
next_value = Signal(32)
self.sync += context.eq(next_value[16:32])
- # from SATA specification, if possible replace it
- # with a generic implementation using polynoms.
+ # XXX: from SATA specification, replace it with
+ # a generic implementation using polynoms.
lfsr_coefs = (
(15, 13, 4, 0), #0
(15, 14, 13, 5, 4, 1, 0),
self.rx_packet = []
def get_scrambler_ref(self):
- p = subprocess.Popen(["./scrambler"], stdout=subprocess.PIPE)
- out, err = p.communicate()
+ with subprocess.Popen(["./scrambler"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) as process:
+ process.stdin.write("0x10000".encode("ASCII"))
+ out, err = process.communicate()
self.scrambler_ref = [int(e, 16) for e in out.decode("utf-8").split("\n")[:-1]]
def descramble(self, packet):
stdin += "0x%08x " %data
stdin += "exit"
with subprocess.Popen("./crc", stdin=subprocess.PIPE, stdout=subprocess.PIPE) as process:
- process.stdin.write(stdin.encode("UTF-8"))
+ process.stdin.write(stdin.encode("ASCII"))
out, err = process.communicate()
- return int(out.decode("UTF-8"), 16)
+ return int(out.decode("ASCII"), 16)
def gen_simulation(self, selfp):
# init CRC
def get_c_values(self, length):
stdin = "0x%08x" %length
with subprocess.Popen("./scrambler", stdin=subprocess.PIPE, stdout=subprocess.PIPE) as process:
- process.stdin.write(stdin.encode("UTF-8"))
+ process.stdin.write(stdin.encode("ASCII"))
out, err = process.communicate()
- return [int(e, 16) for e in out.decode("utf-8").split("\n")[:-1]]
+ return [int(e, 16) for e in out.decode("ASCII").split("\n")[:-1]]
def gen_simulation(self, selfp):
# init CRC