phy: use primitives dict and use only sata.std
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Nov 2014 09:19:24 +0000 (10:19 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Nov 2014 09:19:24 +0000 (10:19 +0100)
lib/sata/phy/k7sataphy/crg.py
lib/sata/phy/k7sataphy/ctrl.py
lib/sata/phy/k7sataphy/datapath.py
lib/sata/phy/k7sataphy/gtx.py
lib/sata/phy/k7sataphy/std.py [deleted file]
lib/sata/std.py

index 93ac490a0e9a95cf72a7621eb9a1771c6bdb6ea4..aae3a93814e8bc45d7e50a01405637b195f0eede 100644 (file)
@@ -4,7 +4,7 @@ from migen.fhdl.std import *
 from migen.genlib.resetsync import AsyncResetSynchronizer
 from migen.genlib.fsm import FSM, NextState
 
-from lib.sata.k7sataphy.std import *
+from lib.sata.std import *
 from lib.sata.k7sataphy.gtx import GTXE2_COMMON
 
 class K7SATAPHYCRG(Module):
@@ -58,7 +58,7 @@ class K7SATAPHYCRG(Module):
                                p_BANDWIDTH="HIGH", p_COMPENSATION="ZHOLD", i_RST=mmcm_reset, o_LOCKED=mmcm_locked,
 
                                # DRP
-                               i_DCLK=0, i_DEN=0, i_DWE=0, #o_DRDY=, 
+                               i_DCLK=0, i_DEN=0, i_DWE=0, #o_DRDY=,
                                i_DADDR=0, i_DI=0, #o_DO=,
 
                                # VCO
index c4ffb463a320e1e7aa4749c03980312e1976281c..3c840d065d5153870b49f03c1f9b5285b011b015 100644 (file)
@@ -5,7 +5,7 @@ from migen.genlib.resetsync import AsyncResetSynchronizer
 from migen.genlib.fsm import FSM, NextState
 from migen.flow.actor import Sink, Source
 
-from lib.sata.k7sataphy.std import *
+from lib.sata.std import *
 
 def us(t, clk_freq):
        clk_period_us = 1000000/clk_freq
@@ -117,7 +117,7 @@ class K7SATAPHYHostCtrl(Module):
                )
                fsm.act("SEND_ALIGN",
                        gtx.txelecidle.eq(0),
-                       self.source.data.eq(ALIGN_VAL),
+                       self.source.data.eq(primitives["ALIGN"]),
                        self.source.charisk.eq(0b0001),
                        If(non_align_cnt == 3,
                                NextState("READY")
@@ -125,7 +125,7 @@ class K7SATAPHYHostCtrl(Module):
                )
                fsm.act("READY",
                        gtx.txelecidle.eq(0),
-                       self.source.data.eq(SYNC_VAL),
+                       self.source.data.eq(primitives["SYNC"]),
                        self.source.charisk.eq(0b0001),
                        self.ready.eq(1),
                )
@@ -139,7 +139,7 @@ class K7SATAPHYHostCtrl(Module):
                        gtx.txcomwake.eq(txcomwake & ~txcomwake_d),
                ]
 
-               self.comb +=  align_detect.eq(self.sink.stb & (self.sink.data == ALIGN_VAL));
+               self.comb +=  align_detect.eq(self.sink.stb & (self.sink.data == primitives["ALIGN"]));
                self.sync += \
                        If(fsm.ongoing("RESET"),
                                align_timeout_cnt.eq(us(873, clk_freq))
@@ -254,7 +254,7 @@ class K7SATAPHYDeviceCtrl(Module):
                fsm.act("SEND_ALIGN",
                        gtx.txelecidle.eq(0),
                        gtx.rxalign.eq(1),
-                       self.source.data.eq(ALIGN_VAL),
+                       self.source.data.eq(primitives["ALIGN"]),
                        self.source.charisk.eq(0b0001),
                        If(align_detect,
                                NextState("READY")
@@ -284,7 +284,7 @@ class K7SATAPHYDeviceCtrl(Module):
                        gtx.txcomwake.eq(txcomwake & ~txcomwake_d),
                ]
 
-               self.comb +=  align_detect.eq(self.sink.stb & (self.sink.data == ALIGN_VAL));
+               self.comb +=  align_detect.eq(self.sink.stb & (self.sink.data == primitives["ALIGN"]));
                self.sync += \
                        If(fsm.ongoing("RESET"),
                                align_timeout_cnt.eq(us(55, clk_freq))
index 83088d99000de230c7567716721ed7021f98543a..bd4b6670992540dae1dbd14fa302474d7b779340 100644 (file)
@@ -3,7 +3,7 @@ from migen.genlib.misc import chooser
 from migen.actorlib.fifo import AsyncFIFO
 from migen.flow.actor import Sink, Source
 
-from lib.sata.k7sataphy.std import *
+from lib.sata.std import *
 
 class K7SATAPHYDatapathRX(Module):
        def __init__(self):
@@ -143,7 +143,7 @@ class K7SATAPHYDatapath(Module):
                        If(ctrl.ready,
                                If(send_align,
                                        tx.sink.stb.eq(1),
-                                       tx.sink.data.eq(ALIGN_VAL),
+                                       tx.sink.data.eq(primitives["ALIGN"]),
                                        tx.sink.charisk.eq(0b0001),
                                        self.sink.ack.eq(0)
                                ).Else(
index 982cbb9ae6365d152bba498110fa74e395c4e653..101303130581f1538e8eb029497b9877500b012e 100644 (file)
@@ -1,7 +1,7 @@
 from migen.fhdl.std import *
 from migen.genlib.cdc import *
 
-from lib.sata.k7sataphy.std import *
+from lib.sata.std import *
 
 class _PulseSynchronizer(PulseSynchronizer):
        def __init__(self, i, idomain, o, odomain):
diff --git a/lib/sata/phy/k7sataphy/std.py b/lib/sata/phy/k7sataphy/std.py
deleted file mode 100644 (file)
index 5a21899..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-from migen.fhdl.std import *
-from migen.genlib.record import *
-
-ALIGN_VAL   = 0x7B4A4ABC
-SYNC_VAL    = 0xB5B5957C
-
-def ones(width):
-       return 2**width-1
index b2370c5079095eb3b7e4914d0ba957b3f8af81a7..7979b38a74e2ac76bc3a386257f8b9263f768584 100644 (file)
@@ -1,18 +1,24 @@
 from migen.fhdl.std import *
+from migen.genlib.record import *
 
-ALIGN_VAL   = 0x7B4A4ABC
-SYNC_VAL    = 0xB5B5957C
-R_RDY_VAL   = 0x4A4A957C
-R_OK_VAL    = 0x3535B57C
-R_ERR_VAL   = 0x5656B57C
-R_IP_VAL    = 0X5555B57C
-X_RDY_VAL   = 0x5757B57C
-CONT_VAL    = 0x9999AA7C
-WTRM_VAL    = 0x5858B57C
-SOF_VAL     = 0x3737B57C
-EOF_VAL     = 0xD5D5B57C
-HOLD_VAL    = 0xD5D5AA7C
-HOLD_ACK    = 0X9595AA7C
+primitives = {
+       "ALIGN" :       0x7B4A4ABC,
+       "SYNC"  :       0xB5B5957C,
+       "R_RDY" :       0x4A4A957C,
+       "R_OK"  :       0x3535B57C,
+       "R_ERR" :       0x5656B57C,
+       "R_IP"  :       0X5555B57C,
+       "X_RDY" :       0x5757B57C,
+       "CONT"  :       0x9999AA7C,
+       "WTRM"  :       0x5858B57C,
+       "SOF"   :       0x3737B57C,
+       "EOF"   :       0xD5D5B57C,
+       "HOLD"  :       0xD5D5AA7C,
+       "HOLD"  :       0X9595AA7C
+}
+
+def ones(width):
+       return 2**width-1
 
 def phy_layout(dw):
        layout = [