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

Subversion Repositories ethernet_tri_mode

[/] [ethernet_tri_mode/] [trunk/] [rtl/] [verilog/] [MAC_tx/] [Ramdon_gen.v] - Blame information for rev 6

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

Line No. Rev Author Line
1 5 maverickis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Ramdon_gen.v                                                ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects.cgi/web/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 6 maverickis
// $Log: not supported by cvs2svn $
42
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
43
// no message
44
//                                           
45 5 maverickis
 
46
module Ramdon_gen(
47
Reset           ,
48
Clk                 ,
49
Init            ,
50
RetryCnt            ,
51
Random_time_meet
52
);
53
input                   Reset           ;
54
input                   Clk                 ;
55
input                   Init            ;
56
input[3:0]               RetryCnt            ;
57
output                  Random_time_meet;
58
 
59
//******************************************************************************
60
//internal signals                                                              
61
//******************************************************************************
62
reg[9:0]         Random_sequence ;
63
reg[9:0]         Ramdom                  ;
64
reg[9:0]         Ramdom_counter  ;
65
reg[7:0]         Slot_time_counter; //256*2=512bit=1 slot time
66
reg                             Random_time_meet;
67
 
68
//******************************************************************************
69
always @ (posedge Clk or posedge Reset)
70
        if (Reset)
71
                Random_sequence         <=0;
72
        else
73
                Random_sequence         <={Random_sequence[8:0],~(Random_sequence[2]^Random_sequence[9])};
74
 
75
always @ (RetryCnt or Random_sequence)
76
        case (RetryCnt)
77
                4'h0    :       Ramdom={9'b0,Random_sequence[0]};
78
                4'h1    :       Ramdom={8'b0,Random_sequence[1:0]};
79
                4'h2    :       Ramdom={7'b0,Random_sequence[2:0]};
80
                4'h3    :       Ramdom={6'b0,Random_sequence[3:0]};
81
                4'h4    :       Ramdom={5'b0,Random_sequence[4:0]};
82
                4'h5    :       Ramdom={4'b0,Random_sequence[5:0]};
83
                4'h6    :       Ramdom={3'b0,Random_sequence[6:0]};
84
                4'h7    :       Ramdom={2'b0,Random_sequence[7:0]};
85
                4'h8    :       Ramdom={1'b0,Random_sequence[8:0]};
86
                4'h9    :       Ramdom={         Random_sequence[9:0]};
87
                default :       Ramdom={         Random_sequence[9:0]};
88
        endcase
89
 
90
always @ (posedge Clk or posedge Reset)
91
        if (Reset)
92
                Slot_time_counter               <=0;
93
        else if(Init)
94
                Slot_time_counter               <=0;
95
        else if(!Random_time_meet)
96
                Slot_time_counter               <=Slot_time_counter+1;
97
 
98
always @ (posedge Clk or posedge Reset)
99
        if (Reset)
100
                Ramdom_counter          <=0;
101
        else if (Init)
102
                Ramdom_counter          <=Ramdom;
103
        else if (Ramdom_counter!=0&&Slot_time_counter==255)
104
                Ramdom_counter          <=Ramdom_counter -1 ;
105
 
106
always @ (posedge Clk or posedge Reset)
107
        if (Reset)
108
                Random_time_meet        <=1;
109
        else if (Init)
110
                Random_time_meet        <=0;
111
        else if (Ramdom_counter==0)
112
                Random_time_meet        <=1;
113
 
114
endmodule
115
 
116
 

powered by: WebSVN 2.1.0

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