Giter Club home page Giter Club logo

nysa-sata's Introduction

nysa-sata-stack

Sata stack written in Verilog

Staus: TLDR Version: Demonstrated reading and writing to a hard drive on a Spartan 6 LX45T board

For a reference implementation here is a wishbone slave core used to verify the functionality of the SATA Stack:

https://github.com/CospanDesign/nysa-verilog/tree/master/verilog/wishbone/slave/wb_sata

More documentation can be found on the wiki

Most of the license is MIT but some of the licenses are GPL

Here is a link to a Spartan 6 LX45T Project

http://www.cospandesign.com/Projects/SATA/sata_build.zip

TODO: Fix Link layer... there is a small FIFO in there that is used to handle all starting and stopping of the read, it's a work around and needs to be fixed TODO: Fix Link layer so that it only instantiates one instance of the scrambler, not two

Code Organization:

rtl/
  sata_stack.v (Top File that applications interface with)
  sata_defines.v (Set defines for the stack in here)

generic/ (small modules used throughout the design)
  blk_mem.v (wraps around an infered block memory generator)
  cross_clock_enable.v (simple module that allows users to
                        send enables across a clock domain)
  debounce.v (debounce)
  ppfifo.v (ping pong FIFO, similar to a ping pong buffer
            except the user doesn't need to track the
            addresses)

command/
  sata_command_layer.v (Sata Command Layer)

transport/
  sata_transport_layer.v (Sata Transport Layer)

link/
  sata_link_layer.v (Sata Link Layer)
  sata_link_layer_read.v (Sata link layer read side)
  sata_link_layer_write.v (Sata link layer write side)
  scrambler.v (scrambles/descrambles primitives)
  crc.v (Cyclical Redundancy Check/ creator)
  cont_controller.v (controls the scrambling of primitives)

phy/
  sata_phy_layer.v (Sata phy layer)
  oob_controller.v (out of band controller)

platform/
  sata_platform.v (This is a template file you can use to interface with the gigabit transceivers)

Soapbox:

Although I believe this code should be distributed for free and people should redistribute their software I leave the ethics up to the user and have licensesed most of the code as MIT but I did use some GPL cores and if the user desires to use this in their closed source project be warned about the GPL'ed modules in this stack.

nysa-sata's People

Contributors

cospan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nysa-sata's Issues

Confusing to use

The stack is difficult to use, the interface needs to be simpler

Setup unit tests with cocotb

Cocotb is tool that allows users to write test benches for HDL in Python. It is much easier to write extensive tests with Python than with verilog.

The following tests should be written an exercise before the sata core is verified:

  • Bootup: The system starts in a default state How is this defined?
  • Single Word Write: Write a single piece of data to the SATA stack side: Expected Results: observe the correct address and data on the simulated hard drive
  • Single Word Read: Read a single piece of data from the SATA stack: Expected Results: observe the correct address on the hard drive side and pass a piece of data through the simulated hard drive and read it from the SATA stack
  • Large Write: how big? Send a stream of data from the SATA stack side to the simulated hard drive side: Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.
  • Large Read: how big? Read a stream of data from the SATA stack side: Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.
  • Large Write With Easy Back Pressure: how big? Send a stream of data from the SATA stack side to the simulated hard drive side with simulated stall commands to slow the transfer of data: Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.
  • Large Read With Easy Back Pressure: how big? Read a stream of data from the SATA stack side with simulated stall commands to emulate back preassure: Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.
  • Large Write With Hard Back Pressure: how big? Send a stream of data from the SATA stack side to the simulated hard drive side emulate the challenging back pressure (every other clock, ever two clock, etc..): Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.
  • Large Read With Hard Back Breassure: how big? Read a stream of data from the SATA stack side emulate the challenging back pressure (every other clock, ever two clock, etc..): Expected Results: observe the correct address behavior (starting at every sector) and the correct data flowing through.

Fix buffer in link layer write

After exercising this core on an FPGA we observed that the back pressure from the hard drives revealed some data loss on the link layer. A work around was implemented, it was a small buffer that would absorb the data transients. This is ugly and hacky and needs to be fixed correctly.

The area in the '/nysa-sata/rtl/link/sata_link_layer_read.v' can be found on line 228 and is related to these registers:

assign              d0_buf                    = bump_buffer[0];                                                                         |            if (data_scrambler_en) begin                                                                                                
assign              d1_buf                    = bump_buffer[1];                                                                         |              prev_data   <=  descr_dout;                                                                                               
assign              d2_buf                    = bump_buffer[2];                                                                         |            end                                                                                                                         
assign              d3_buf                    = bump_buffer[3]; 

The first milestone should be to expose the bugs in a consistent way.

Data word dropped after PRIM_HOLD

There appears to be a bug in cont_controller.v when the device sends HOLD. I have attached an ILA trace from that module that illustrates the issue.

ila_snip

This is the response to a COMMAND_DMA_READ_EX (8'h25) command for a single block. Near the end of the frame, the drive sends HOLD, HOLD, data_word, EOF. As you can see from the trace, detect_hold is asserted during the last data word. This causes link_layer_read to discard the last data word. (In sata_stack.v, user_dout_size reports 127 data words instead of 128.)

I have attached a diff against cont_controller.v that I believe fixes the issue: I have modified the assignment to hold_cont by ANDing it with cont_detect. (If HOLD had been followed by CONT, then it would be correct to keep detect_hold asserted during that cycle, but when HOLD is not followed by CONT, then detect_hold should no longer be asserted.) I have changed the other *_cont signals to match because I believe they are likely to behave the same way, although I have not observed a problem with them in practice with the devices I have available for testing.

The device that shows this behaviour is a Samsung 860 EVO SSD. We have also been testing with a Micron M500IT SSD, but we have not seen it issue this pattern of HOLDs. So far, only the Samsung drive has excited this problem.

cont_controller.v.diff.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.