From f2757ef8dd07a0f8cdd80e1c7047cef12abf596d Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 2 Dec 2014 19:53:13 +0100 Subject: [PATCH] link: fix link_tb (due to others modifications) --- lib/sata/link/crc.py | 3 +-- lib/sata/link/scrambler.py | 4 ++-- lib/sata/link/test/bfm.py | 5 +++-- lib/sata/link/test/crc_tb.py | 4 ++-- lib/sata/link/test/scrambler_tb.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/sata/link/crc.py b/lib/sata/link/crc.py index e7bb3bb0..f948fdfb 100644 --- a/lib/sata/link/crc.py +++ b/lib/sata/link/crc.py @@ -33,7 +33,6 @@ class CRCEngine(Module): ### - def _optimize_eq(l): """ Replace even numbers of XORs in the equation @@ -90,7 +89,7 @@ class SATACRC(Module): 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() diff --git a/lib/sata/link/scrambler.py b/lib/sata/link/scrambler.py index 640e96f4..5f4a0faa 100644 --- a/lib/sata/link/scrambler.py +++ b/lib/sata/link/scrambler.py @@ -24,8 +24,8 @@ class Scrambler(Module): 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), diff --git a/lib/sata/link/test/bfm.py b/lib/sata/link/test/bfm.py index 577d15cc..db276c0f 100644 --- a/lib/sata/link/test/bfm.py +++ b/lib/sata/link/test/bfm.py @@ -89,8 +89,9 @@ class BFM(Module): 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): diff --git a/lib/sata/link/test/crc_tb.py b/lib/sata/link/test/crc_tb.py index 0411fd04..a4bd51bb 100644 --- a/lib/sata/link/test/crc_tb.py +++ b/lib/sata/link/test/crc_tb.py @@ -18,9 +18,9 @@ class TB(Module): 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 diff --git a/lib/sata/link/test/scrambler_tb.py b/lib/sata/link/test/scrambler_tb.py index 86a569ba..9f2ad8d6 100644 --- a/lib/sata/link/test/scrambler_tb.py +++ b/lib/sata/link/test/scrambler_tb.py @@ -14,9 +14,9 @@ class TB(Module): 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 -- 2.30.2