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 5

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

powered by: WebSVN 2.1.0

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