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

Subversion Repositories sgmii

[/] [sgmii/] [trunk/] [src/] [mRateAdapter.v] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 jefflieu
/*
2
Developed By Subtleware Corporation Pte Ltd 2011
3
File            :
4
Description     :
5
Remarks         :
6
Revision        :
7
        Date    Author          Description
8
02/09/12        Jefflieu
9
*/
10
module mRateAdapter(
11
        //MAC Side signal
12
        input   i_TxClk,
13
        input   i_TxEN,
14
        input   i_TxER,
15
        input   [07:00] i8_TxD,
16
 
17
        input   i_RxClk,
18
        output  o_RxEN,
19
        output  o_RxER,
20
        output  [07:00] o8_RxD,
21
 
22
        input   [1:0] i2_Speed,
23
 
24
        //SGMII PHY side
25
        input   i_SamplingClk,
26
        input   i_GClk,
27
        output  o_TxEN,
28
        output  o_TxER,
29
        output  [07:00] o8_TxD,
30
 
31
        input   i_RxEN,
32
        input   i_RxER,
33
        input   [07:00] i8_RxD
34
);
35
 
36
        wire w_TxActive;
37
        reg r_TxActive;
38
        reg r_GTxEN;
39
        reg r_GTxER;
40
        reg [07:00] r8_GByte;
41
        reg [07:00] r8_Byte;
42
        reg [03:00] r4_LowNib;
43
        reg r_HighNib;
44
        reg r_TxEN_D;
45
        reg r_TxER_D;
46
        reg r_Active;
47
        wire w_TxSop;
48
        wire w_TxEop;
49
 
50
        assign w_TxActive = i_TxEN & i_TxER;
51
        assign w_TxSop = (~r_TxActive && w_TxActive);
52
        assign w_TxEop = (r_TxActive && ~w_TxActive);
53
 
54
        always@(posedge i_TxClk)
55
        begin
56
                r_TxActive <= w_TxActive;
57
 
58
                r_HighNib <= (w_TxSop)?1'b1:(~r_HighNib);
59
 
60
                if(w_TxActive) begin
61
                        if(r_HighNib) r8_Byte <= {i8_TxD[3:0],r4_LowNib};
62
                        if(r_HighNib && (~w_TxSop)) r_TxEN_D <= i_TxEN;
63
                        if(r_HighNib && (~w_TxSop)) r_TxER_D <= i_TxER;
64
                        end else
65
                         begin
66
                         r_TxEN_D <= 1'b0;
67
                         r_TxER_D <= 1'b0;
68
                         end
69
                if((~r_HighNib)|| (w_TxSop))
70
                        r4_LowNib <= i8_TxD[3:0];
71
 
72
        end
73
 
74
        always@(posedge i_GClk)
75
        begin
76
                if(i_SamplingClk==1'b1) begin
77
                        r8_GByte <= r8_Byte;
78
                        r_GTxEN <= r_TxEN_D;
79
                        r_GTxER <= r_TxER_D;
80
                end
81
        end
82
 
83
        assign o8_TxD = (i2_Speed==2'b10)?i8_TxD:r8_GByte;
84
        assign o_TxEN = (i2_Speed==2'b10)?i_TxEN:r_GTxEN;
85
        assign o_TxER = (i2_Speed==2'b10)?i_TxER:r_GTxER;
86
 
87
 
88
        //Receive
89
        //Receive Counter
90
        wire w_RxActive;
91
        reg r_RxActive;
92
        reg [03:00] r4_Cntr;
93
        wire w_RxSop;
94
        wire w_RxEop;
95
        reg [05:00] r6_GByte;
96
        reg [05:00] r6_MByte;
97
 
98
        assign w_RxSop = (~r_RxActive & w_RxActive);
99
 
100
        assign w_RxActive = i_RxEN | i_RxER;
101
 
102
        always@(posedge i_GClk)
103
        begin
104
                r_RxActive <= w_RxActive;
105
                if(w_RxSop) r4_Cntr<=4'h0;
106
                else if(w_RxActive) r4_Cntr <= ((r4_Cntr==4'h9)?4'h0:(r4_Cntr+4'h1));
107
                if(r4_Cntr==4'h0) r6_GByte <= {i_RxEN,i_RxER,i8_RxD[3:0]};
108
                else if(r4_Cntr==4'h5) r6_GByte <= {i_RxEN,i_RxER,i8_RxD[7:4]};
109
        end
110
 
111
        always@(posedge i_RxClk)
112
        begin
113
                r6_MByte <= r6_GByte;
114
        end
115
 
116
 
117
        assign o8_RxD = (i2_Speed==2'b10)?i8_RxD:{r6_MByte[3:0],r6_MByte[3:0]};
118
        assign o_RxEN = (i2_Speed==2'b10)?i_RxEN:r6_MByte[5];
119
        assign o_RxER = (i2_Speed==2'b10)?i_RxER:r6_MByte[4];
120
 
121
 
122
 
123
endmodule

powered by: WebSVN 2.1.0

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