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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [smii/] [smii_sync.v] - Blame information for rev 584

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

Line No. Rev Author Line
1 408 julius
/*
2
 * SMII sync generation module
3
 *
4
 * Generate sync to PHY, and for internal statemachines
5
 *
6
 * Julius Baxter, julius.baxter@orsoc.se
7
 *
8
 */
9
//////////////////////////////////////////////////////////////////////
10
////                                                              ////
11
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
12
////                                                              ////
13
//// This source file may be used and distributed without         ////
14
//// restriction provided that this copyright statement is not    ////
15
//// removed from the file and that any derivative work contains  ////
16
//// the original copyright notice and the associated disclaimer. ////
17
////                                                              ////
18
//// This source file is free software; you can redistribute it   ////
19
//// and/or modify it under the terms of the GNU Lesser General   ////
20
//// Public License as published by the Free Software Foundation; ////
21
//// either version 2.1 of the License, or (at your option) any   ////
22
//// later version.                                               ////
23
////                                                              ////
24
//// This source is distributed in the hope that it will be       ////
25
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
26
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
27
//// PURPOSE.  See the GNU Lesser General Public License for more ////
28
//// details.                                                     ////
29
////                                                              ////
30
//// You should have received a copy of the GNU Lesser General    ////
31
//// Public License along with this source; if not, download it   ////
32
//// from http://www.opencores.org/lgpl.shtml                     ////
33
////                                                              ////
34
//////////////////////////////////////////////////////////////////////
35
module smii_sync
36
  (
37
   // SMII sync
38
    output            sync,
39
   // internal
40
    output [10:1]     tx_state,
41
    output [10:1]     next_tx_state,
42
    output [10:1]     rx_state,
43
 
44
   // clock amd reset
45
    input             clk,
46
    input             rst
47
   );
48
   reg [10:1] next_tx_state_r;
49
   reg [10:1] tx_state_r;
50
 
51
   reg [10:1]         rx_state_int;
52
   reg [10:1]         rx_state_int2;
53
   reg [10:1]         rx_state_int3;
54
 
55
   // sync shall go high every 10:th cycle
56
   always @ (posedge clk)
57
     if (rst)
58
       begin
59
          next_tx_state_r <= 10'b0000000010;
60
          tx_state_r <= 0;
61
       end
62
     else
63
       begin
64
          tx_state_r <= next_tx_state_r;
65
          next_tx_state_r <= {next_tx_state_r[9:1],next_tx_state_r[10]};
66
       end
67
 
68
   assign tx_state = tx_state_r;
69
   assign next_tx_state = next_tx_state_r;
70
   assign sync = tx_state_r[1];
71
 
72
   always @(posedge clk)
73
     begin
74
        rx_state_int <= {tx_state_r[9:1],tx_state_r[10]};
75
        rx_state_int2 <= rx_state_int;
76
        rx_state_int3 <= rx_state_int2;
77
     end
78
   // rx_state counter is 2 clocks behind tx state due to flops in and out of
79
   // FPGA
80
   assign rx_state = rx_state_int3;
81
 
82
endmodule // smii_sync

powered by: WebSVN 2.1.0

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