OpenCores
URL https://opencores.org/ocsvn/sata_controller_core/sata_controller_core/trunk

Subversion Repositories sata_controller_core

[/] [sata_controller_core/] [trunk/] [sata2_fifo_v1_00_a/] [hdl/] [vhdl/] [sata_core.vhd] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ashwin_men
-- Copyright (C) 2012
2
-- Ashwin A. Mendon
3
--
4
-- This file is part of SATA2 core.
5
--
6
-- This program is free software; you can redistribute it and/or modify
7
-- it under the terms of the GNU General Public License as published by
8
-- the Free Software Foundation; either version 3 of the License, or
9
-- (at your option) any later version.
10
--
11
-- This program is distributed in the hope that it will be useful,
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
-- GNU General Public License for more details.
15
--
16
-- You should have received a copy of the GNU General Public License
17
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.  
18
 
19
----------------------------------------------------------------------------------------
20
-- ENTITY:  sata_core 
21
-- Version: 1.0
22
-- Author:  Ashwin Mendon 
23
-- Description:  The SATA core implements the Command, Transport and Link Layers of 
24
--               the SATA protocol and provides a Physical Layer Wrapper for the GTX 
25
--               transceivers. The Physical Layer Wrapper also includes an Out of Band
26
--               Signaling (OOB) controller state machine which deals with initialization
27
--               and synchronization of the SATA link. It can interface with SATA 2
28
--               Winchester style Hard Disks as well as Flash-based Solid State Drives
29
 
30
--               The core provides a simple interface to issue READ/WRITE sector commands.
31
--               The DATA interface is 32-bit FIFO like.
32
--               A 150 MHz input reference clock is needed for the GTX transceivers.
33
--               The output data is delivered 4 bytes @ 75 MHz (user output clock) 
34
--               for a theoretical peak bandwidth of 300 MB/s (SATA 2).
35
--               
36
--              
37
-- PORTS: 
38
                        -- Command, Control and Status --
39
 
40
--           ready_for_cmd          :  When asserted, SATA core is ready to execute new command.
41
--                                     This signal goes low after new_cmd is asserted.                    
42
--                                     It also serves as the command done signal    
43
--           new_cmd                :  Asserted for one clock cycle to start a request        
44
--           cmd_type               :  "01" for READ request and "10" for WRITE request           
45
--           sector_count           :  Number of sectors requested by user 
46
--           sector_addr            :  Starting address of request
47
 
48
                         -- Data and User Clock --
49
 
50
--           sata_din               :  Data from user to Write to Disk  
51
--           sata_din_we            :  Write Enable to SATA Core when FULL is low 
52
--           sata_core_full         :  SATA Core Full- de-assert WE 
53
--           sata_dout              :  Data output from SATA Core
54
--           sata_dout_re           :  Read Enable from SATA asserted when EMPTY is low 
55
--           sata_core_empty        :  SATA Core Empty- de-assert RE
56
--           SATA_USER_DATA_CLK_IN  :  SATA Core Write Clock  
57
--           SATA_USER_DATA_CLK_OUT :  SATA Core Read Clock
58
--           sata_timer             :  SATA core timer output to check performance 
59
 
60
                          --PHY Signals--
61
--           CLKIN_150              :  150 Mhz input reference clock for the GTX transceivers
62
--           reset                  :  Resets GTX and SATA core; can be tied to a software reset
63
 
64
--           LINKUP                 :  Indicates Link Initialization done (OOB) and SATA link is up 
65
 
66
             --GTX transmit/receive pins: Connected to the FMC_HPC pins on a ML605 board         
67
--           TXP0_OUT, TXN0_OUT, RXP0_IN, RXN0_IN                               
68
-----------------------------------------------------------------------------------------
69
 
70
library IEEE;
71
use IEEE.STD_LOGIC_1164.all;
72
use IEEE.STD_LOGIC_ARITH.all;
73
use IEEE.STD_LOGIC_UNSIGNED.all;
74
 
75
entity sata_core is
76
  generic(
77
    CHIPSCOPE           : boolean := false;
78
    DATA_WIDTH          : natural := 32
79
       );
80
  port(
81
    -- ChipScope ILA / Trigger Signals
82
    sata_rx_frame_ila_control  : in  std_logic_vector(35 downto 0);
83
    sata_tx_frame_ila_control  : in  std_logic_vector(35 downto 0);
84
    sata_phy_ila_control       : in  std_logic_vector(35 downto 0);
85
    oob_control_ila_control    : in  std_logic_vector(35 downto 0);
86
    cmd_layer_ila_control      : in  std_logic_vector(35 downto 0);
87
    scrambler_ila_control      : in  std_logic_vector(35 downto 0);
88
    descrambler_ila_control    : in  std_logic_vector(35 downto 0);
89
    ---------------------------------------
90
    -- SATA Interface -----
91
      -- Command, Control and Status --
92
    ready_for_cmd         : out std_logic;
93
    new_cmd               : in  std_logic;
94
    cmd_type              : in  std_logic_vector(1 downto 0);
95
    sector_count          : in  std_logic_vector(31 downto 0);
96
    sector_addr           : in  std_logic_vector(31 downto 0);
97
      -- Data and User Clock --
98
    sata_din               : in  std_logic_vector(31 downto 0);
99
    sata_din_we            : in  std_logic;
100
    sata_core_full         : out std_logic;
101
    sata_dout              : out std_logic_vector(31 downto 0);
102
    sata_dout_re           : in  std_logic;
103
    sata_core_empty        : out std_logic;
104
    SATA_USER_DATA_CLK_IN  : in std_logic;
105
    SATA_USER_DATA_CLK_OUT : out std_logic;
106
 
107
    -- Timer --
108
    sata_timer            : out std_logic_vector(31 downto 0);
109
 
110
         -- PHY Signals
111
    -- Clock and Reset Signals
112
    CLKIN_150             : in  std_logic;
113
    reset                 : in  std_logic;
114
 
115
    LINKUP                : out std_logic;
116
    TXP0_OUT              : out std_logic;
117
    TXN0_OUT              : out std_logic;
118
    RXP0_IN               : in std_logic;
119
    RXN0_IN               : in std_logic;
120
    PLLLKDET_OUT_N        : out std_logic;
121
    DCMLOCKED_OUT         : out std_logic
122
);
123
end sata_core;
124
 
125
-------------------------------------------------------------------------------
126
-- ARCHITECTURE
127
-------------------------------------------------------------------------------
128
architecture BEHAV of sata_core is
129
 
130
  -- Sata Phy
131
  signal sata_user_clk        : std_logic;
132
  --signal GTXRESET            : std_logic;
133
  signal LINKUP_i             : std_logic;
134
  -- Sata Phy
135
 
136
  signal REFCLK_PAD_P_IN_i   : std_logic;
137
  signal REFCLK_PAD_N_IN_i   : std_logic;
138
 
139
  -- COMMAND LAYER / LINK LAYER SIGNALS  
140
  signal ll_ready_for_cmd_i         : std_logic;
141
  signal sata_ready_for_cmd_i       : std_logic;
142
  signal ll_cmd_start               : std_logic;
143
  signal ll_cmd_type                : std_logic_vector(1 downto 0);
144
  signal ll_dout                    : std_logic_vector(31 downto 0);
145
  signal ll_dout_we                 : std_logic;
146
  signal ll_din                     : std_logic_vector(31 downto 0);
147
  signal ll_din_re                  : std_logic;
148
  signal sector_count_int           : integer;
149
 
150
 -- User FIFO signals
151
  signal user_din_re          : std_logic;
152
  signal user_fifo_dout       : std_logic_vector(31 downto 0);
153
  signal user_fifo_full       : std_logic;
154
  signal user_fifo_prog_full  : std_logic;
155
  signal user_fifo_empty      : std_logic;
156
 
157
  signal write_fifo_full_i    : std_logic;
158
  signal read_fifo_empty      : std_logic;
159
 
160
 
161
-- USER FIFO DECLARATION
162
  component user_fifo
163
        port (
164
        clk: IN std_logic;
165
        rst: IN std_logic;
166
        din: IN std_logic_VECTOR(31 downto 0);
167
        wr_en: IN std_logic;
168
        rd_en: IN std_logic;
169
        dout: OUT std_logic_VECTOR(31 downto 0);
170
        full: OUT std_logic;
171
        prog_full: OUT std_logic;
172
        empty: OUT std_logic);
173
  end component;
174
 
175
-------------------------------------------------------------------------------
176
-- BEGIN
177
-------------------------------------------------------------------------------
178
begin
179
 
180
  --- User Logic Fifo for writing data ---
181
  USER_FIFO_i : user_fifo
182
                port map (
183
                        rst => reset,
184
                        clk => sata_user_clk,
185
                        din => sata_din,
186
                        wr_en => sata_din_we,
187
                        dout => user_fifo_dout,
188
                        rd_en => user_din_re,
189
                        full => user_fifo_full,
190
                        prog_full => user_fifo_prog_full,
191
                        empty => user_fifo_empty);
192
 
193
   -- SATA Core Output Signals
194
   ready_for_cmd    <= sata_ready_for_cmd_i;
195 7 ashwin_men
   --sata_core_full   <= write_fifo_full_i;
196
   sata_core_full   <= user_fifo_prog_full;
197 2 ashwin_men
   sata_core_empty  <= read_fifo_empty;
198
   SATA_USER_DATA_CLK_OUT  <= sata_user_clk;
199
   LINKUP           <= LINKUP_i;
200
-----------------------------------------------------------------------------
201
  -- Command Layer Instance
202
-----------------------------------------------------------------------------
203
 
204
  COMMAND_LAYER_i : entity work.command_layer
205
    generic map
206
    (
207
      CHIPSCOPE        => CHIPSCOPE
208
    )
209
    port map
210
    (
211
      -- ChipScope Signal
212
      cmd_layer_ila_control  => cmd_layer_ila_control,
213
      -- Clock and Reset Signals
214
      sw_reset             => reset,
215
      clk                  => sata_user_clk,
216
 
217
      new_cmd              => new_cmd,
218
      cmd_done             => sata_ready_for_cmd_i,
219
      cmd_type             => cmd_type,
220
      sector_count         => sector_count,
221
      sector_addr          => sector_addr,
222
      user_din             => user_fifo_dout,
223
      user_din_re_out      => user_din_re,
224
      user_dout            => sata_dout,
225
      user_dout_re         => sata_dout_re,
226
      write_fifo_full      => write_fifo_full_i,
227
      user_fifo_empty      => user_fifo_empty,
228
      user_fifo_full       => user_fifo_prog_full,
229
      sector_timer_out       => sata_timer,
230
 
231
    -- Signals from/to Link Layer
232
      ll_ready_for_cmd     => ll_ready_for_cmd_i,
233
      ll_cmd_start         => ll_cmd_start,
234
      ll_cmd_type          => ll_cmd_type,
235
      ll_dout              => ll_dout,
236
      ll_dout_we           => ll_dout_we,
237
      ll_din               => ll_din,
238
      ll_din_re            => ll_din_re
239
    );
240
 
241
 ------------------------------------------
242
  -- Sata Link Layer Module Instance
243
  ------------------------------------------
244
  sector_count_int  <=  conv_integer(sector_count);
245
 
246
  SATA_LINK_LAYER_i: entity work.sata_link_layer
247
  generic map(
248
    CHIPSCOPE           => CHIPSCOPE,
249
    DATA_WIDTH          => DATA_WIDTH
250
       )
251
  port map(
252
    -- Clock and Reset Signals
253
    CLKIN_150             => CLKIN_150,
254
    sw_reset             => reset,
255
    -- ChipScope ILA / Trigger Signals
256
    sata_rx_frame_ila_control  => sata_rx_frame_ila_control  ,
257
    sata_tx_frame_ila_control  => sata_tx_frame_ila_control  ,
258
    oob_control_ila_control    => oob_control_ila_control,
259
    sata_phy_ila_control       => sata_phy_ila_control,
260
    scrambler_ila_control => scrambler_ila_control,
261
    descrambler_ila_control => descrambler_ila_control,
262
    ---------------------------------------
263
    -- Ports from/to User Logic
264
    read_fifo_empty      => read_fifo_empty,
265
    write_fifo_full      => write_fifo_full_i,
266
    GTX_RESET_IN         => reset,
267
    sector_count         => sector_count_int,
268
    sata_user_clk_out     => sata_user_clk,
269
    -- Ports from/to Command Layer 
270
    ready_for_cmd_out    => ll_ready_for_cmd_i,
271
    new_cmd_in           => ll_cmd_start,
272
    cmd_type             => ll_cmd_type,
273
    sata_din             => ll_dout,
274
    sata_din_we          => ll_dout_we,
275
    sata_dout            => ll_din,
276
    sata_dout_re         => ll_din_re,
277
    ---------------------------------------
278
    --  Ports to SATA PHY
279
    REFCLK_PAD_P_IN       => REFCLK_PAD_P_IN_i,
280
    REFCLK_PAD_N_IN       => REFCLK_PAD_N_IN_i,
281
    TXP0_OUT              => TXP0_OUT,
282
    TXN0_OUT              => TXN0_OUT,
283
    RXP0_IN               => RXP0_IN,
284
    RXN0_IN               => RXN0_IN,
285
    PLLLKDET_OUT_N        => PLLLKDET_OUT_N,
286
    DCMLOCKED_OUT         => DCMLOCKED_OUT,
287
    LINKUP_led            => LINKUP_i
288
      );
289
 
290
end BEHAV;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.