1 |
10 |
antiquity |
//author :gurenliang
|
2 |
|
|
//Email: gurenliang@gmail.com
|
3 |
|
|
//note: if there are some errors, you are welcome to contact me. It would be the best appreciation to me.
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
//version 0.3 correct some minor errors
|
7 |
|
|
//version 0.3 add the option of frameID mode, by include common.v and judge the macro-varible frameIDfromRx
|
8 |
|
|
//The top layer module provided full functions
|
9 |
|
|
`include "common.v"
|
10 |
|
|
|
11 |
|
|
module EthernetModule(reset, clk_10K,
|
12 |
|
|
ff_clk, ff_en_source, ff_en_sink, ff_data_source, ff_data_sink, //ff_clk should be a 270.33KHz clock
|
13 |
|
|
phy_rxd, phy_rxen, phy_rxclk, phy_rxer,
|
14 |
|
|
phy_txd, phy_txen, phy_txclk, phy_txer,
|
15 |
|
|
phy_reset, phy_col, phy_linksts, phy_crs,
|
16 |
|
|
test1, test2, test3, test4
|
17 |
|
|
);
|
18 |
|
|
input reset, clk_10K, ff_clk;
|
19 |
|
|
output phy_reset, test1, test2, test3, test4;
|
20 |
|
|
|
21 |
|
|
input ff_en_sink, ff_data_sink; //sink is used to receive data from the demodulate module
|
22 |
|
|
output ff_en_source, ff_data_source;//source is used to provide the modulation module with data get from ethernet
|
23 |
|
|
|
24 |
|
|
input[3:0] phy_rxd; //MII interface for the phy chip
|
25 |
|
|
input phy_rxclk, phy_rxer;
|
26 |
|
|
|
27 |
|
|
output[3:0] phy_txd;
|
28 |
|
|
output phy_txer, phy_txen;
|
29 |
|
|
|
30 |
|
|
//declare them as inout port because when powerup reset, they act as output pins to config DM9161
|
31 |
|
|
//after reset, phy_txclk and phy_rxen must be input ports
|
32 |
|
|
inout phy_txclk, phy_col, phy_rxen, phy_linksts, phy_crs;
|
33 |
|
|
|
34 |
|
|
wire out_en;
|
35 |
|
|
wire rxen_in, txclk_in;
|
36 |
|
|
|
37 |
|
|
`ifdef frameIDfromRx
|
38 |
|
|
wire[23:0] frameid; //share the frameid between TxModule and RxModule
|
39 |
|
|
`endif
|
40 |
|
|
|
41 |
|
|
wire empty, start;
|
42 |
|
|
|
43 |
|
|
InitModule initModule_inst(.init_clk(clk_10K), .reset(reset), .phy_reset(phy_reset), .out_en(out_en));
|
44 |
|
|
|
45 |
|
|
tri_state tri_state_inst1(.d_in(txclk_in ), .d_out(1'b0), .out_en(out_en), .ioport(phy_txclk));
|
46 |
|
|
tri_state tri_state_inst2(.d_in( ), .d_out(1'b0), .out_en(out_en), .ioport(phy_col));
|
47 |
|
|
tri_state tri_state_inst3(.d_in(rxen_in ), .d_out(1'b0), .out_en(out_en), .ioport(phy_rxen));
|
48 |
|
|
tri_state tri_state_inst4(.d_in( ), .d_out(1'b0), .out_en(out_en), .ioport(phy_linksts));
|
49 |
|
|
tri_state tri_state_inst5(.d_in( ), .d_out(1'b1), .out_en(out_en), .ioport(phy_crs));
|
50 |
|
|
|
51 |
|
|
TxModule TxModule_inst(.reset(out_en),
|
52 |
|
|
.phy_txd(phy_txd), .phy_txen(phy_txen), .phy_txclk(txclk_in), .phy_txer(phy_txer),
|
53 |
|
|
.ff_clk(ff_clk), .ff_en(ff_en_sink), .ff_data(ff_data_sink),
|
54 |
|
|
`ifdef frameIDfromRx
|
55 |
|
|
.frameid(frameid),
|
56 |
|
|
`endif
|
57 |
|
|
.start(start),
|
58 |
|
|
.test1(), .test2(), .test3(), .test4());
|
59 |
|
|
//.test1(test1), .test2(test2), .test3(test3), .test4(test4));
|
60 |
|
|
|
61 |
|
|
RxModule RxModule_inst(.phy_rxd(phy_rxd), .phy_rxen(rxen_in), .phy_rxclk(phy_rxclk), .phy_rxer(phy_rxer),
|
62 |
|
|
.ff_clk(ff_clk), .ff_data(ff_data_source), .ff_en(ff_en_source),
|
63 |
|
|
`ifdef frameIDfromRx
|
64 |
|
|
.frameid(frameid),
|
65 |
|
|
`endif
|
66 |
|
|
.start(start),
|
67 |
|
|
//.test1(), .test2(), .test3(), .test4());
|
68 |
|
|
.test1(test1), .test2(test2), .test3(test3), .test4(test4));
|
69 |
|
|
|
70 |
|
|
endmodule
|