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

Subversion Repositories nysa_sata

[/] [nysa_sata/] [trunk/] [rtl/] [phy/] [sata_phy_layer.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 cospan
//sata_phy_layer.v
2
/*
3
Distributed under the MIT license.
4
Copyright (c) 2011 Dave McCoy (dave.mccoy@cospandesign.com)
5
 
6
Permission is hereby granted, free of charge, to any person obtaining a copy of
7
this software and associated documentation files (the "Software"), to deal in
8
the Software without restriction, including without limitation the rights to
9
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
of the Software, and to permit persons to whom the Software is furnished to do
11
so, subject to the following conditions:
12
 
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
*/
24
 
25
 
26
`include "sata_defines.v"
27
 
28
module sata_phy_layer (
29
 
30
input               rst,            //reset
31
input               clk,
32
 
33
input               platform_ready,   //the underlying physical platform is
34
output              linkup,           //link is finished
35
 
36
output  [31:0]      tx_dout,
37
output              tx_isk,
38
output              tx_comm_reset,
39
output              tx_comm_wake,
40
output              tx_elec_idle,
41
 
42
input   [31:0]      rx_din,
43
input   [3:0]       rx_isk,
44
input               rx_elec_idle,
45
input               rx_byte_is_aligned,
46
input               comm_init_detect,
47
input               comm_wake_detect,
48
 
49
output              phy_ready,
50
output      [3:0]   lax_state
51
 
52
);
53
 
54
 
55
//Parameters
56
parameter           NOT_READY         = 4'h0;
57
parameter           SEND_FIRST_ALIGN  = 4'h1;
58
parameter           SEND_SECOND_ALIGN = 4'h2;
59
parameter           READY             = 4'h3;
60
 
61
//Registers/Wires
62
reg         [3:0]   state;
63
reg         [7:0]   align_count;
64
 
65
//OOB Control
66
wire        [31:0]  oob_tx_dout;
67
wire                oob_tx_isk;
68
 
69
//Phy Control
70
wire        [31:0]  phy_tx_dout;
71
wire                phy_tx_isk;
72
wire                align_detected;
73
 
74
 
75
 
76
//Submodules
77
oob_controller oob (
78
  .rst                (rst),
79
  .clk                (clk),
80
 
81
  //OOB controller
82
  .platform_ready     (platform_ready),
83
  .linkup             (linkup),
84
 
85
  //Platform Control
86
  .tx_dout            (oob_tx_dout),
87
  .tx_isk             (oob_tx_isk),
88
  .tx_comm_reset      (tx_comm_reset),
89
  .tx_comm_wake       (tx_comm_wake),
90
  .tx_set_elec_idle   (tx_elec_idle),
91
 
92
  .rx_din             (rx_din),
93
  .rx_isk             (rx_isk),
94
  .comm_init_detect   (comm_init_detect),
95
  .comm_wake_detect   (comm_wake_detect),
96
  .rx_byte_is_aligned (rx_byte_is_aligned),
97
  .rx_is_elec_idle    (rx_elec_idle),
98
  .lax_state          (lax_state)
99
 
100
);
101
 
102
//Asynchronous Logic
103
assign              tx_dout         = !linkup ? oob_tx_dout : phy_tx_dout;
104
assign              tx_isk          = !linkup ? oob_tx_isk  : phy_tx_isk;
105
 
106
assign              phy_tx_dout     =  `PRIM_ALIGN;
107
assign              phy_tx_isk      =  1;
108
 
109
assign              align_detected  = ((rx_isk > 0) && (rx_din == `PRIM_ALIGN) && rx_byte_is_aligned);
110
//assign              phy_ready       = ((state == READY) && (!align_detected));
111
assign              phy_ready       = (state == READY);
112
 
113
 
114
 
115
//Synchronous Logic
116
always @ (posedge clk) begin
117
  if (rst) begin
118
    state             <=  NOT_READY;
119
    align_count       <=  0;
120
  end
121
  else begin
122
    if (state == READY) begin
123
      align_count       <=  align_count + 1;
124
    end
125
    case (state)
126
      NOT_READY:  begin
127
        align_count   <=  0;
128
        if (linkup) begin
129
`ifdef VERBOSE
130
          $display ("sata_phy_layer: linkup! send aligns");
131
`endif
132
          state       <=  SEND_FIRST_ALIGN;
133
        end
134
      end
135
      SEND_FIRST_ALIGN: begin
136
        state         <=  SEND_SECOND_ALIGN;
137
      end
138
      SEND_SECOND_ALIGN: begin
139
        state         <=  READY;
140
      end
141
      READY:      begin
142
        if (align_count ==  255) begin
143
          state       <=  SEND_FIRST_ALIGN;
144
`ifdef VERBOSE
145
          $display ("sata_phy_layer: linkup! send alignment dwords");
146
`else
147
          $display ("sata_phy_layer: .");
148
`endif
149
//Send an align primitive
150
        end
151
      end
152
      default:    begin
153
      end
154
    endcase
155
  end
156
end
157
 
158
 
159
 
160
endmodule

powered by: WebSVN 2.1.0

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