1 |
26 |
jefflieu |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// MAC_tx_addr_add.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the Ethernet IP core project ////
|
6 |
|
|
//// http://www.opencores.org/projects.cgi/wr_en/ethernet_tri_mode/////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Author(s): ////
|
9 |
|
|
//// - Jon Gao (gaojon@yahoo.com) ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// ////
|
12 |
|
|
//////////////////////////////////////////////////////////////////////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Copyright (C) 2001 Authors ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source file may be used and distributed without ////
|
17 |
|
|
//// restriction provided that this copyright statement is not ////
|
18 |
|
|
//// removed from the file and that any derivative work contains ////
|
19 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
20 |
|
|
//// ////
|
21 |
|
|
//// This source file is free software; you can redistribute it ////
|
22 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
23 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
24 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
25 |
|
|
//// later version. ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source is distributed in the hope that it will be ////
|
28 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
29 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
30 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
31 |
|
|
//// details. ////
|
32 |
|
|
//// ////
|
33 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
34 |
|
|
//// Public License along with this source; if not, download it ////
|
35 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
36 |
|
|
//// ////
|
37 |
|
|
//////////////////////////////////////////////////////////////////////
|
38 |
|
|
//
|
39 |
|
|
// CVS Revision History
|
40 |
|
|
//
|
41 |
|
|
// $Log: not supported by cvs2svn $
|
42 |
|
|
// Revision 1.2 2005/12/16 06:44:18 Administrator
|
43 |
|
|
// replaced tab with space.
|
44 |
|
|
// passed 9.6k length frame test.
|
45 |
|
|
//
|
46 |
|
|
// Revision 1.1.1.1 2005/12/13 01:51:45 Administrator
|
47 |
|
|
// no message
|
48 |
|
|
//
|
49 |
|
|
|
50 |
|
|
module MAC_tx_addr_add (
|
51 |
|
|
Reset ,
|
52 |
|
|
Clk ,
|
53 |
|
|
MAC_tx_addr_init ,
|
54 |
|
|
MAC_tx_addr_rd ,
|
55 |
|
|
MAC_tx_addr_data ,
|
56 |
|
|
//CPU ,
|
57 |
|
|
MAC_add_prom_data ,
|
58 |
|
|
MAC_add_prom_add ,
|
59 |
|
|
MAC_add_prom_wr
|
60 |
|
|
);
|
61 |
|
|
|
62 |
|
|
input Reset ;
|
63 |
|
|
input Clk ;
|
64 |
|
|
input MAC_tx_addr_rd ;
|
65 |
|
|
input MAC_tx_addr_init ;
|
66 |
|
|
output [7:0] MAC_tx_addr_data ;
|
67 |
|
|
//CPU ;
|
68 |
|
|
input [7:0] MAC_add_prom_data ;
|
69 |
|
|
input [2:0] MAC_add_prom_add ;
|
70 |
|
|
input MAC_add_prom_wr ;
|
71 |
|
|
|
72 |
|
|
//******************************************************************************
|
73 |
|
|
//internal signals
|
74 |
|
|
//******************************************************************************
|
75 |
|
|
reg [2:0] add_rd;
|
76 |
|
|
wire[2:0] add_wr;
|
77 |
|
|
wire[7:0] din;
|
78 |
|
|
wire[7:0] dout;
|
79 |
|
|
wire wr_en;
|
80 |
|
|
reg MAC_add_prom_wr_dl1;
|
81 |
|
|
reg MAC_add_prom_wr_dl2;
|
82 |
|
|
//******************************************************************************
|
83 |
|
|
//write data from cpu to prom
|
84 |
|
|
//******************************************************************************
|
85 |
|
|
always @ (posedge Clk or posedge Reset)
|
86 |
|
|
if (Reset)
|
87 |
|
|
begin
|
88 |
|
|
MAC_add_prom_wr_dl1 <=0;
|
89 |
|
|
MAC_add_prom_wr_dl2 <=0;
|
90 |
|
|
end
|
91 |
|
|
else
|
92 |
|
|
begin
|
93 |
|
|
MAC_add_prom_wr_dl1 <=MAC_add_prom_wr;
|
94 |
|
|
MAC_add_prom_wr_dl2 <=MAC_add_prom_wr_dl1;
|
95 |
|
|
end
|
96 |
|
|
assign # 2 wr_en =MAC_add_prom_wr_dl1&!MAC_add_prom_wr_dl2;
|
97 |
|
|
assign # 2 add_wr =MAC_add_prom_add;
|
98 |
|
|
assign # 2 din =MAC_add_prom_data;
|
99 |
|
|
|
100 |
|
|
//******************************************************************************
|
101 |
|
|
//read data from cpu to prom
|
102 |
|
|
//******************************************************************************
|
103 |
|
|
always @ (posedge Clk or posedge Reset)
|
104 |
|
|
if (Reset)
|
105 |
|
|
add_rd <=0;
|
106 |
|
|
else if (MAC_tx_addr_init)
|
107 |
|
|
add_rd <=0;
|
108 |
|
|
else if (MAC_tx_addr_rd)
|
109 |
|
|
add_rd <=add_rd + 1;
|
110 |
|
|
assign MAC_tx_addr_data=dout;
|
111 |
|
|
//******************************************************************************
|
112 |
|
|
//b port for read ,a port for write .
|
113 |
|
|
//******************************************************************************
|
114 |
|
|
duram #(8,3,"M512","DUAL_PORT") U_duram(
|
115 |
|
|
.data_a (din ),
|
116 |
|
|
.wren_a (wr_en ),
|
117 |
|
|
.address_a (add_wr ),
|
118 |
|
|
.address_b (add_rd ),
|
119 |
|
|
.clock_a (Clk ),
|
120 |
|
|
.clock_b (Clk ),
|
121 |
|
|
.q_b (dout ));
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
endmodule
|
125 |
|
|
|