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

Subversion Repositories sata_controller_core

[/] [sata_controller_core/] [trunk/] [sata2_bus_v1_00_a/] [base_system/] [pcores/] [sata_core_v1_00_a/] [hdl/] [vhdl/] [sata_core_top.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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