add identify device to command_tb and revert endianness (seems conform with Lecroy...
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 20 Dec 2014 12:26:07 +0000 (13:26 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 20 Dec 2014 12:26:07 +0000 (13:26 +0100)
it seems endianness is correct by is only printed in LSB first in Lecroy software

lib/sata/test/command_tb.py
lib/sata/test/hdd.py
lib/sata/transport/__init__.py

index fd6c3a1eed8437b3cca201d68d7851e498d64fad..50397c3ad51d7110fe979f1d1346aa24ba0cbade 100644 (file)
@@ -100,5 +100,8 @@ class TB(Module):
                s, l, e = check(write_data, read_data)
                print("shift "+ str(s) + " / length " + str(l) + " / errors " + str(e))
 
+               identify_packet = CommandTXPacket(identify=1)
+               yield from self.streamer.send(identify_packet)
+
 if __name__ == "__main__":
        run_simulation(TB(), ncycles=2048, vcd_name="my.vcd", keep_files=True)
index 6a58518f4d40b6b912c24408d89a9cfafa94db4e..ec62bbcbebb99442b47adabb78e6ae4378a7fb3b 100644 (file)
@@ -282,7 +282,7 @@ def _little2big(v):
        return r
 
 def get_field_data(field, packet):
-       return (_little2big(packet[field.dword]) >> field.offset) & (2**field.width-1)
+       return (packet[field.dword] >> field.offset) & (2**field.width-1)
 
 class FIS:
        def __init__(self, packet, description, direction="H2D"):
@@ -297,7 +297,7 @@ class FIS:
 
        def encode(self):
                for k, v in self.description.items():
-                       self.packet[v.dword] |= _big2little((getattr(self, k) << v.offset))
+                       self.packet[v.dword] |= (getattr(self, k) << v.offset)
 
        def __repr__(self):
                if self.direction == "H2D":
@@ -385,7 +385,7 @@ class TransportLayer(Module):
                        print_transport(fis)
 
        def callback(self, packet):
-               fis_type = _little2big(packet[0]) & 0xff
+               fis_type = packet[0] & 0xff
                if fis_type == fis_types["REG_H2D"]:
                        fis = FIS_REG_H2D(packet)
                elif fis_type == fis_types["REG_D2H"]:
@@ -508,7 +508,8 @@ class HDD(Module):
                packet.insert(0, 0)
                return [FIS_DATA(packet, direction="D2H"), FIS_REG_D2H()]
 
-       def identify_dma_callback(self, fis):
+       def identify_device_dma_callback(self, fis):
+               print_hdd("Identify device request")
                packet = [i for i in range(256)]
                packet.insert(0, 0)
                return [FIS_DATA(packet, direction="D2H"), FIS_REG_D2H()]
index 6abbfd5c103bc38f4f7429061b2bc7bb1684b761..f83aa672ed61029d6a151c105d10d1b974a24f57 100644 (file)
@@ -96,7 +96,7 @@ class SATATransportTX(Module):
 
                cmd_cases = {}
                for i in range(cmd_ndwords):
-                       cmd_cases[i] = [link.sink.d.eq(_big2little(encoded_cmd[32*i:32*(i+1)]))]
+                       cmd_cases[i] = [link.sink.d.eq(encoded_cmd[32*i:32*(i+1)])]
 
                self.comb += \
                        If(cmd_send,
@@ -141,7 +141,7 @@ class SATATransportRX(Module):
                data_done = Signal()
 
                def test_type(name):
-                       return link.source.d[24:] == fis_types[name]
+                       return link.source.d[:8] == fis_types[name]
 
                self.fsm = fsm = FSM(reset_state="IDLE")
 
@@ -230,7 +230,7 @@ class SATATransportRX(Module):
 
                cmd_cases = {}
                for i in range(cmd_ndwords):
-                       cmd_cases[i] = [encoded_cmd[32*i:32*(i+1)].eq(_little2big(link.source.d))]
+                       cmd_cases[i] = [encoded_cmd[32*i:32*(i+1)].eq(link.source.d)]
 
                self.comb += \
                        If(cmd_receive & link.source.stb,