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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_random.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_random.v                                                ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/cores/ethmac/                      ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////      - Novan Hartadi (novan@vlsi.itb.ac.id)                  ////
11
////      - Mahmud Galela (mgalela@vlsi.itb.ac.id)                ////
12
////                                                              ////
13
////  All additional information is avaliable in the Readme.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2001 Authors                                   ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46
// Revision 1.1  2001/07/30 21:23:42  mohor
47
// Directory structure changed. Files checked and joind together.
48
//
49
// Revision 1.3  2001/06/19 18:16:40  mohor
50
// TxClk changed to MTxClk (as discribed in the documentation).
51
// Crc changed so only one file can be used instead of two.
52
//
53
// Revision 1.2  2001/06/19 10:38:07  mohor
54
// Minor changes in header.
55
//
56
// Revision 1.1  2001/06/19 10:27:57  mohor
57
// TxEthMAC initial release.
58
//
59
//
60
//
61
//
62
 
63
`include "eth_timescale.v"
64
 
65
module eth_random (MTxClk, Reset, StateJam, StateJam_q, RetryCnt, NibCnt, ByteCnt,
66
                   RandomEq0, RandomEqByteCnt);
67
 
68
parameter Tp = 1;
69
 
70
input MTxClk;
71
input Reset;
72
input StateJam;
73
input StateJam_q;
74
input [3:0] RetryCnt;
75
input [15:0] NibCnt;
76
input [9:0] ByteCnt;
77
output RandomEq0;
78
output RandomEqByteCnt;
79
 
80
wire Feedback;
81
reg [9:0] x;
82
wire [9:0] Random;
83
reg  [9:0] RandomLatched;
84
 
85
 
86
always @ (posedge MTxClk or posedge Reset)
87
begin
88
  if(Reset)
89
    x[9:0] <= #Tp 0;
90
  else
91
    x[9:0] <= #Tp {x[8:0], Feedback};
92
end
93
 
94
assign Feedback = x[2] ~^ x[9];
95
 
96
assign Random [0] = x[0];
97
assign Random [1] = (RetryCnt > 1) ? x[1] : 1'b0;
98
assign Random [2] = (RetryCnt > 2) ? x[2] : 1'b0;
99
assign Random [3] = (RetryCnt > 3) ? x[3] : 1'b0;
100
assign Random [4] = (RetryCnt > 4) ? x[4] : 1'b0;
101
assign Random [5] = (RetryCnt > 5) ? x[5] : 1'b0;
102
assign Random [6] = (RetryCnt > 6) ? x[6] : 1'b0;
103
assign Random [7] = (RetryCnt > 7) ? x[7] : 1'b0;
104
assign Random [8] = (RetryCnt > 8) ? x[8] : 1'b0;
105
assign Random [9] = (RetryCnt > 9) ? x[9] : 1'b0;
106
 
107
 
108
always @ (posedge MTxClk or posedge Reset)
109
begin
110
  if(Reset)
111
    RandomLatched <= #Tp 10'h000;
112
  else
113
    begin
114
      if(StateJam & StateJam_q)
115
        RandomLatched <= #Tp Random;
116
    end
117
end
118
 
119
// Random Number == 0      IEEE 802.3 page 68. If 0 we go to defer and not to backoff.
120
assign RandomEq0 = RandomLatched == 10'h0;
121
 
122
assign RandomEqByteCnt = ByteCnt[9:0] == RandomLatched & (&NibCnt[6:0]);
123
 
124
endmodule

powered by: WebSVN 2.1.0

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