//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// RMON_addr_gen.v ////
|
//// RMON_addr_gen.v ////
|
//// ////
|
//// ////
|
//// This file is part of the Ethernet IP core project ////
|
//// This file is part of the Ethernet IP core project ////
|
//// http://www.opencores.org/projects.cgi/web/ethernet_tri_mode/////
|
//// http://www.opencores.org/projects.cgi/web/ethernet_tri_mode/////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Jon Gao (gaojon@yahoo.com) ////
|
//// - Jon Gao (gaojon@yahoo.com) ////
|
//// ////
|
//// ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2001 Authors ////
|
//// Copyright (C) 2001 Authors ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.1.1.1 2005/12/13 01:51:45 Administrator
|
|
// no message
|
|
//
|
module RMON_addr_gen(
|
module RMON_addr_gen(
|
Clk ,
|
Clk ,
|
Reset ,
|
Reset ,
|
//RMON
|
//RMON
|
Pkt_type_rmon ,
|
Pkt_type_rmon ,
|
Pkt_length_rmon ,
|
Pkt_length_rmon ,
|
Apply_rmon ,//pluse signal looks like eop
|
Apply_rmon ,//pluse signal looks like eop
|
Pkt_err_type_rmon ,
|
Pkt_err_type_rmon ,
|
//
|
//
|
Reg_apply ,
|
Reg_apply ,
|
Reg_addr ,
|
Reg_addr ,
|
Reg_data ,
|
Reg_data ,
|
Reg_next ,
|
Reg_next ,
|
//CPU
|
//CPU
|
Reg_drop_apply
|
Reg_drop_apply
|
);
|
);
|
input Clk ;
|
input Clk ;
|
input Reset ;
|
input Reset ;
|
//RMON
|
//RMON
|
input[2:0] Pkt_type_rmon ;
|
input[2:0] Pkt_type_rmon ;
|
input[15:0] Pkt_length_rmon ;
|
input[15:0] Pkt_length_rmon ;
|
input Apply_rmon ;//pluse signal looks like eop
|
input Apply_rmon ;//pluse signal looks like eop
|
input[2:0] Pkt_err_type_rmon ;
|
input[2:0] Pkt_err_type_rmon ;
|
//RMON_ctrl
|
//RMON_ctrl
|
output Reg_apply ;
|
output Reg_apply ;
|
output[4:0] Reg_addr ;
|
output[4:0] Reg_addr ;
|
output[15:0] Reg_data ;
|
output[15:0] Reg_data ;
|
input Reg_next ;
|
input Reg_next ;
|
//CPU
|
//CPU
|
output Reg_drop_apply ;
|
output Reg_drop_apply ;
|
|
|
//******************************************************************************
|
//******************************************************************************
|
//internal signals
|
//internal signals
|
//******************************************************************************
|
//******************************************************************************
|
parameter StateIdle =5'b00001;
|
parameter StateIdle =5'b00001;
|
parameter StatePktLength =5'b00010;
|
parameter StatePktLength =5'b00010;
|
parameter StatePktNumber =5'b00100;
|
parameter StatePktNumber =5'b00100;
|
parameter StatePktType =5'b01000;
|
parameter StatePktType =5'b01000;
|
parameter StatePktRange =5'b10000;
|
parameter StatePktRange =5'b10000;
|
|
|
reg[4:0] CurrentState;
|
reg[4:0] CurrentState;
|
reg[4:0] NextState;
|
reg[4:0] NextState;
|
|
|
reg[2:0] PktTypeReg ;
|
reg[2:0] PktTypeReg ;
|
reg[15:0] PktLengthReg ;
|
reg[15:0] PktLengthReg ;
|
reg[2:0] PktErrTypeReg ;
|
reg[2:0] PktErrTypeReg ;
|
|
|
reg Reg_apply ;
|
reg Reg_apply ;
|
reg[4:0] Reg_addr ;
|
reg[4:0] Reg_addr ;
|
reg[15:0] Reg_data ;
|
reg[15:0] Reg_data ;
|
reg Reg_drop_apply ;
|
reg Reg_drop_apply ;
|
//******************************************************************************
|
//******************************************************************************
|
//register boundery signals
|
//register boundery signals
|
|
|
//******************************************************************************
|
//******************************************************************************
|
reg Apply_rmon_dl1;
|
reg Apply_rmon_dl1;
|
reg Apply_rmon_dl2;
|
reg Apply_rmon_dl2;
|
reg Apply_rmon_pulse;
|
reg Apply_rmon_pulse;
|
reg[2:0] Pkt_type_rmon_dl1 ;
|
reg[2:0] Pkt_type_rmon_dl1 ;
|
reg[15:0] Pkt_length_rmon_dl1 ;
|
reg[15:0] Pkt_length_rmon_dl1 ;
|
reg[2:0] Pkt_err_type_rmon_dl1 ;
|
reg[2:0] Pkt_err_type_rmon_dl1 ;
|
|
|
always @(posedge Clk or posedge Reset)
|
always @(posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
begin
|
begin
|
Pkt_type_rmon_dl1 <=0;
|
Pkt_type_rmon_dl1 <=0;
|
Pkt_length_rmon_dl1 <=0;
|
Pkt_length_rmon_dl1 <=0;
|
Pkt_err_type_rmon_dl1 <=0;
|
Pkt_err_type_rmon_dl1 <=0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Pkt_type_rmon_dl1 <=Pkt_type_rmon ;
|
Pkt_type_rmon_dl1 <=Pkt_type_rmon ;
|
Pkt_length_rmon_dl1 <=Pkt_length_rmon ;
|
Pkt_length_rmon_dl1 <=Pkt_length_rmon ;
|
Pkt_err_type_rmon_dl1 <=Pkt_err_type_rmon ;
|
Pkt_err_type_rmon_dl1 <=Pkt_err_type_rmon ;
|
end
|
end
|
|
|
always @(posedge Clk or posedge Reset)
|
always @(posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
begin
|
begin
|
Apply_rmon_dl1 <=0;
|
Apply_rmon_dl1 <=0;
|
Apply_rmon_dl2 <=0;
|
Apply_rmon_dl2 <=0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
Apply_rmon_dl1 <=Apply_rmon;
|
Apply_rmon_dl1 <=Apply_rmon;
|
Apply_rmon_dl2 <=Apply_rmon_dl1;
|
Apply_rmon_dl2 <=Apply_rmon_dl1;
|
end
|
end
|
|
|
always @(Apply_rmon_dl1 or Apply_rmon_dl2)
|
always @(Apply_rmon_dl1 or Apply_rmon_dl2)
|
if (Apply_rmon_dl1&!Apply_rmon_dl2)
|
if (Apply_rmon_dl1&!Apply_rmon_dl2)
|
Apply_rmon_pulse =1;
|
Apply_rmon_pulse =1;
|
else
|
else
|
Apply_rmon_pulse =0;
|
Apply_rmon_pulse =0;
|
|
|
|
|
|
|
always @(posedge Clk or posedge Reset)
|
always @(posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
begin
|
begin
|
PktTypeReg <=0;
|
PktTypeReg <=0;
|
PktLengthReg <=0;
|
PktLengthReg <=0;
|
PktErrTypeReg <=0;
|
PktErrTypeReg <=0;
|
end
|
end
|
else if (Apply_rmon_pulse&&CurrentState==StateIdle)
|
else if (Apply_rmon_pulse&&CurrentState==StateIdle)
|
begin
|
begin
|
PktTypeReg <=Pkt_type_rmon_dl1 ;
|
PktTypeReg <=Pkt_type_rmon_dl1 ;
|
PktLengthReg <=Pkt_length_rmon_dl1 ;
|
PktLengthReg <=Pkt_length_rmon_dl1 ;
|
PktErrTypeReg <=Pkt_err_type_rmon_dl1 ;
|
PktErrTypeReg <=Pkt_err_type_rmon_dl1 ;
|
end
|
end
|
|
|
|
|
//******************************************************************************
|
//******************************************************************************
|
//State Machine
|
//State Machine
|
//******************************************************************************
|
//******************************************************************************
|
always @(posedge Clk or posedge Reset)
|
always @(posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
CurrentState <=StateIdle;
|
CurrentState <=StateIdle;
|
else
|
else
|
CurrentState <=NextState;
|
CurrentState <=NextState;
|
|
|
always @(CurrentState or Apply_rmon_pulse or Reg_next)
|
always @(CurrentState or Apply_rmon_pulse or Reg_next)
|
case (CurrentState)
|
case (CurrentState)
|
StateIdle:
|
StateIdle:
|
if (Apply_rmon_pulse)
|
if (Apply_rmon_pulse)
|
NextState =StatePktLength;
|
NextState =StatePktLength;
|
else
|
else
|
NextState =StateIdle;
|
NextState =StateIdle;
|
StatePktLength:
|
StatePktLength:
|
if (Reg_next)
|
if (Reg_next)
|
NextState =StatePktNumber;
|
NextState =StatePktNumber;
|
else
|
else
|
NextState =CurrentState;
|
NextState =CurrentState;
|
StatePktNumber:
|
StatePktNumber:
|
if (Reg_next)
|
if (Reg_next)
|
NextState =StatePktType;
|
NextState =StatePktType;
|
else
|
else
|
NextState =CurrentState;
|
NextState =CurrentState;
|
StatePktType:
|
StatePktType:
|
if (Reg_next)
|
if (Reg_next)
|
NextState =StatePktRange;
|
NextState =StatePktRange;
|
else
|
else
|
NextState =CurrentState;
|
NextState =CurrentState;
|
StatePktRange:
|
StatePktRange:
|
if (Reg_next)
|
if (Reg_next)
|
NextState =StateIdle;
|
NextState =StateIdle;
|
else
|
else
|
NextState =CurrentState;
|
NextState =CurrentState;
|
default:
|
default:
|
NextState =StateIdle;
|
NextState =StateIdle;
|
endcase
|
endcase
|
|
|
//******************************************************************************
|
//******************************************************************************
|
//gen output signals
|
//gen output signals
|
//******************************************************************************
|
//******************************************************************************
|
//Reg_apply
|
//Reg_apply
|
always @ (CurrentState)
|
always @ (CurrentState)
|
if (CurrentState==StatePktLength||CurrentState==StatePktNumber||
|
if (CurrentState==StatePktLength||CurrentState==StatePktNumber||
|
CurrentState==StatePktType||CurrentState==StatePktRange)
|
CurrentState==StatePktType||CurrentState==StatePktRange)
|
Reg_apply =1;
|
Reg_apply =1;
|
else
|
else
|
Reg_apply =0;
|
Reg_apply =0;
|
|
|
//Reg_addr
|
//Reg_addr
|
always @ (posedge Clk or posedge Reset)
|
always @ (posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
Reg_addr <=0;
|
Reg_addr <=0;
|
else case (CurrentState)
|
else case (CurrentState)
|
StatePktLength:
|
StatePktLength:
|
Reg_addr <=5'd00;
|
Reg_addr <=5'd00;
|
StatePktNumber:
|
StatePktNumber:
|
Reg_addr <=5'd01;
|
Reg_addr <=5'd01;
|
StatePktType:
|
StatePktType:
|
case(PktTypeReg)
|
case(PktTypeReg)
|
3'b011:
|
3'b011:
|
Reg_addr <=5'd02; //broadcast
|
Reg_addr <=5'd02; //broadcast
|
3'b001:
|
3'b001:
|
Reg_addr <=5'd03; //multicast
|
Reg_addr <=5'd03; //multicast
|
3'b100:
|
3'b100:
|
Reg_addr <=5'd16; //pause frame
|
Reg_addr <=5'd16; //pause frame
|
default:
|
default:
|
Reg_addr <=5'd04; //unicast
|
Reg_addr <=5'd04; //unicast
|
endcase
|
endcase
|
StatePktRange:
|
StatePktRange:
|
case(PktErrTypeReg)
|
case(PktErrTypeReg)
|
3'b001:
|
3'b001:
|
Reg_addr <=5'd05;
|
Reg_addr <=5'd05;
|
3'b010:
|
3'b010:
|
Reg_addr <=5'd06;
|
Reg_addr <=5'd06;
|
3'b011:
|
3'b011:
|
Reg_addr <=5'd07;
|
Reg_addr <=5'd07;
|
3'b100:
|
3'b100:
|
if (PktLengthReg<64)
|
if (PktLengthReg<64)
|
Reg_addr <=5'd08;
|
Reg_addr <=5'd08;
|
else if (PktLengthReg==64)
|
else if (PktLengthReg==64)
|
Reg_addr <=5'd09;
|
Reg_addr <=5'd09;
|
else if (PktLengthReg<128)
|
else if (PktLengthReg<128)
|
Reg_addr <=5'd10;
|
Reg_addr <=5'd10;
|
else if (PktLengthReg<256)
|
else if (PktLengthReg<256)
|
Reg_addr <=5'd11;
|
Reg_addr <=5'd11;
|
else if (PktLengthReg<512)
|
else if (PktLengthReg<512)
|
Reg_addr <=5'd12;
|
Reg_addr <=5'd12;
|
else if (PktLengthReg<1024)
|
else if (PktLengthReg<1024)
|
Reg_addr <=5'd13;
|
Reg_addr <=5'd13;
|
else if (PktLengthReg<1519)
|
else if (PktLengthReg<1519)
|
Reg_addr <=5'd14;
|
Reg_addr <=5'd14;
|
else
|
else
|
Reg_addr <=5'd15;
|
Reg_addr <=5'd15;
|
default:
|
default:
|
Reg_addr <=5'd05;
|
Reg_addr <=5'd05;
|
endcase
|
endcase
|
default:
|
default:
|
Reg_addr <=5'd05;
|
Reg_addr <=5'd05;
|
endcase
|
endcase
|
|
|
//Reg_data
|
//Reg_data
|
always @ (CurrentState or PktLengthReg)
|
always @ (CurrentState or PktLengthReg)
|
case (CurrentState)
|
case (CurrentState)
|
StatePktLength:
|
StatePktLength:
|
Reg_data =PktLengthReg;
|
Reg_data =PktLengthReg;
|
StatePktNumber:
|
StatePktNumber:
|
Reg_data =1;
|
Reg_data =1;
|
StatePktType:
|
StatePktType:
|
Reg_data =1;
|
Reg_data =1;
|
StatePktRange:
|
StatePktRange:
|
Reg_data =1;
|
Reg_data =1;
|
default:
|
default:
|
Reg_data =0;
|
Reg_data =0;
|
endcase
|
endcase
|
|
|
//Reg_drop_apply
|
//Reg_drop_apply
|
always @ (posedge Clk or posedge Reset)
|
always @ (posedge Clk or posedge Reset)
|
if (Reset)
|
if (Reset)
|
Reg_drop_apply <=0;
|
Reg_drop_apply <=0;
|
else if (CurrentState!=StateIdle&&Apply_rmon_pulse)
|
else if (CurrentState!=StateIdle&&Apply_rmon_pulse)
|
Reg_drop_apply <=1;
|
Reg_drop_apply <=1;
|
else
|
else
|
Reg_drop_apply <=0;
|
Reg_drop_apply <=0;
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|