link: fix link_tb (due to others modifications)
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 2 Dec 2014 18:53:13 +0000 (19:53 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 2 Dec 2014 18:53:13 +0000 (19:53 +0100)
lib/sata/link/crc.py
lib/sata/link/scrambler.py
lib/sata/link/test/bfm.py
lib/sata/link/test/crc_tb.py
lib/sata/link/test/scrambler_tb.py

index e7bb3bb0e6bb1efb1ea9c13bdb143cc19f54c8ca..f948fdfb000a6b2cf314e623fbe19479b1460533 100644 (file)
@@ -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()
index 640e96f44966ac702c04ef43cff75b3d7fa04d96..5f4a0faa98495f29310f2c3b019743fa4575e4bb 100644 (file)
@@ -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),
index 577d15cced4e2d210ce8a259b618339822bd5187..db276c0f163eba72f17537c63c895cc9fea84272 100644 (file)
@@ -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):
index 0411fd04e261ddb78e01845974bcdd6261ac63ce..a4bd51bb74d603493551973933d35a234290ff5d 100644 (file)
@@ -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
index 86a569ba2abc5300dcdd8f70beb544d01b5894d1..9f2ad8d693b1264fbf08739806d7e32347bce780 100644 (file)
@@ -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