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

Subversion Repositories sgmii

[/] [sgmii/] [trunk/] [src/] [mRegisters.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
`timescale 1ns/100ps
11
`include "SGMIIDefs.v"
12
module mRegisters(
13
        input w_ARstLogic_L,
14
        input i_Clk,
15
        input i_Cyc,
16
        input i_Stb,
17
        input i_WEn,
18
        input [07:00] i8_Addr,
19
        input [31:00] i32_WrData,
20
        output reg [31:00] o32_RdData,
21
        output reg o_Ack,
22
        output o_Stall,
23
 
24
        inout io_Mdio,
25
        input i_Mdc,
26
 
27
        //This is used in Phy-Side SGMII 
28
        input   i_PhyLink,
29
        input   i_PhyDuplex,
30
        input   [1:0] i2_PhySpeed,
31
 
32
        //MAC-Side Speed,
33
        output  [01:00] o2_SGMIISpeed,
34
        //MAC-Side Duplex,
35
        output  o_SGMIIDuplex,
36
 
37
 
38
        //Register in and out,
39
        output  [20:00] o21_LinkTimer,
40
 
41
        input   [02:00] i3_XmitState,
42
        input   [15:00] i16_TxConfigReg,
43
        output o_MIIRst_L,
44
        output o_ANEnable,
45
        output o_ANRestart,
46
        output o_Loopback,
47
        output o_GXBPowerDown,
48
        output [15:00] o16_LcAdvAbility,
49
        input   i_ANComplete,
50
        input   i_SyncStatus,
51
        input [15:00] i16_LpAdvAbility);
52
 
53
        //TODO: Local BUs interface to setup registers
54
        //Register Write        
55
        wire    w_Write;
56
        reg     r_Write;
57
        wire    w_WritePulse;
58
        wire    [04:00] w5_Addr;
59
        wire    [15:00] w16_WrData;
60
        reg     [15:00] r16_CtrlReg0;
61
        reg     [15:00] r16_CtrlReg4;
62
        wire    [15:00] w16_StatusReg1;
63
        reg             [15:00] r16_ModeReg;
64
        wire    [15:00] w16_LcAdvAbility;
65
        wire    w_UseAsSGMII;
66
        reg     r_Read;
67
        wire    w_Read;
68
        wire    w_ReadPulse;
69
        wire    w_SGMII_PHY;
70
        reg [20:00] r21_LinkTimer;
71
        reg [15:00] r16_ScratchRev;
72
        wire w_UseLcConfig;
73
 
74
        assign o21_LinkTimer = r21_LinkTimer;
75
        assign w5_Addr = i8_Addr[6:2];
76
        assign w16_WrData = i32_WrData[15:00];
77
        assign w_Write = (i_Cyc & i_Stb & i_WEn);
78
        assign w_WritePulse = w_Write & (~r_Write);
79
        assign w_Read = (i_Cyc & i_Stb & (~i_WEn));
80
        assign w_ReadPulse = w_Read & (~r_Read);
81
        assign o_Stall = (w_Write|w_Read)&(~o_Ack);
82
        always@(posedge i_Clk or negedge w_ARstLogic_L)
83
        if(w_ARstLogic_L==1'b0)
84
                begin
85
                        r16_CtrlReg4 <= `cReg4Default;
86
                        r16_CtrlReg0 <= `cReg0Default;
87
                        r16_ModeReg  <= `cRegXDefault;
88
                        r21_LinkTimer <= `cRegLinkTimerDefault;
89
                        r16_ScratchRev <= 16'h1_0_00;
90
                end
91
        else
92
        begin
93
                //Write Controller
94
                r_Write <= w_Write;
95
                o_Ack  <= w_WritePulse|w_ReadPulse;
96
                //Control Register 0
97
                if(w_WritePulse && w5_Addr==5'b00000) r16_CtrlReg0 <= w16_WrData;
98
                else begin
99
                        if(i3_XmitState==`cXmitCONFIG) r16_CtrlReg0[9] <= 1'b0;
100
                        r16_CtrlReg0[15] <= 1'b0;
101
                end
102
 
103
 
104
                if(w_WritePulse && w5_Addr==5'b00100) r16_CtrlReg4 <= w16_WrData;
105
 
106
                if(w_WritePulse && w5_Addr==5'b01000) r21_LinkTimer[15:00] <= w16_WrData;
107
                if(w_WritePulse && w5_Addr==5'b01001) r21_LinkTimer[20:16] <= w16_WrData[4:0];
108
                if(w_WritePulse && w5_Addr==5'b01010) r16_ScratchRev    <= w16_WrData;
109
                if(w_WritePulse && w5_Addr==5'b11111) r16_ModeReg               <= w16_WrData;
110
 
111
                //Read Controller
112
                r_Read <= w_Read;
113
 
114
                if(w_ReadPulse)
115
                        case(w5_Addr)
116
                        5'h00:          o32_RdData <= {16'h0,r16_CtrlReg0};
117
                        5'h01:          o32_RdData <= {16'h0,w16_StatusReg1};
118
                        5'h02:          o32_RdData <= 32'h0;
119
                        5'h03:          o32_RdData <= 32'h0;
120
                        5'h04:          o32_RdData <= {16'h0,w16_LcAdvAbility};
121
                        5'h05:          o32_RdData <= {16'h0,i16_LpAdvAbility};
122
                        5'h08:          o32_RdData <= {16'h0,r21_LinkTimer[15:00]};
123
                        5'h09:          o32_RdData <= {16'h0,11'h0,r21_LinkTimer[20:16]};
124
                        5'h0A:          o32_RdData <= r16_ScratchRev;
125
                        5'h1F:          o32_RdData <= r16_ModeReg;
126
                        default:        o32_RdData <= 32'h0;
127
                        endcase
128
        end
129
        assign o_ANRestart              = r16_CtrlReg0[9];
130
        assign o_MIIRst_L               = ~r16_CtrlReg0[15];
131
        assign o_ANEnable               = r16_CtrlReg0[12];
132
        assign o_Loopback               = r16_CtrlReg0[14];
133
        assign o_GxBPowerDown   = r16_CtrlReg0[11];
134
        assign o16_LcAdvAbility = w16_LcAdvAbility;
135
 
136
        assign w16_LcAdvAbility = (w_UseAsSGMII==1'b0)?({1'b0,i16_TxConfigReg[15],r16_CtrlReg4[13:12],3'b000,r16_CtrlReg4[8:7],2'b01,5'b00000})://1000-X mode
137 3 jefflieu
                                                                ((w_SGMII_PHY==1'b1)?({i_PhyLink,i16_TxConfigReg[15],1'b0,(i_PhyDuplex|r16_CtrlReg4[12]),(i2_PhySpeed|r16_CtrlReg4[11:10]),10'h1})://SGMII mode - PHY Side
138 2 jefflieu
                                                                ({1'b0,i16_TxConfigReg[15],1'b0,3'b000,10'h1}));//SGMII mode - MAC Side
139
 
140
        assign w16_StatusReg1 = {9'h0,i_ANComplete,2'b01,i_SyncStatus,2'b0};
141
        assign w_UseAsSGMII     = r16_ModeReg[0];
142
        assign w_SGMII_PHY              = r16_ModeReg[1];
143
        assign w_UseLcConfig    = r16_ModeReg[2];
144
        assign o2_SGMIISpeed    = (w_UseAsSGMII==1'b0)?2'b10:((w_UseLcConfig==1'b0)?i16_LpAdvAbility[11:10]:{r16_CtrlReg0[6],r16_CtrlReg0[13]});
145
        assign o_SGMIIDuplex    = (w_UseAsSGMII==1'b0)?1'b1:((w_UseLcConfig==1'b0)?i16_LpAdvAbility[12]:{r16_CtrlReg0[8]});
146
 
147
endmodule

powered by: WebSVN 2.1.0

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