Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: nb_crc_error_injector.v | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | module nb_crc_error_injector(pn_in,pn_out,init,sclk); | |
36 | parameter DS=0; | |
37 | ||
38 | // interface signals | |
39 | input [13:0] pn_in; | |
40 | output [13:0] pn_out; | |
41 | input init; | |
42 | input sclk; | |
43 | ||
44 | reg [13:0] pn0_crc_mask; | |
45 | reg [13:0] pn1_crc_mask; | |
46 | reg [13:0] pn2_crc_mask; | |
47 | reg [13:0] pn3_crc_mask; | |
48 | reg [13:0] pn4_crc_mask; | |
49 | reg [13:0] pn5_crc_mask; | |
50 | reg [13:0] pn6_crc_mask; | |
51 | reg [13:0] pn7_crc_mask; | |
52 | reg [13:0] pn8_crc_mask; | |
53 | reg [13:0] pn9_crc_mask; | |
54 | reg [13:0] pn10_crc_mask; | |
55 | reg [13:0] pn11_crc_mask; | |
56 | reg [11:0] pn_frame_num; | |
57 | reg [3:0] tr_counter; | |
58 | reg [11:0] pn_crc_freq; | |
59 | reg [11:0] pn_crc_period; | |
60 | reg crc_en; | |
61 | reg [15:0] frame_counter; | |
62 | wire module_en = (DS == 0 ); | |
63 | wire [15:0] crc_clock_period = (pn_crc_freq+pn_crc_period)*16'h6; | |
64 | ||
65 | always@(posedge sclk) if ( ~init && ( pn_frame_num !==0 ) ) | |
66 | begin | |
67 | ||
68 | ||
69 | if ( frame_counter !== crc_clock_period ) | |
70 | begin | |
71 | ||
72 | if ( frame_counter < (pn_crc_freq*12) ) | |
73 | crc_en = 1; | |
74 | else | |
75 | crc_en =0; | |
76 | ||
77 | frame_counter=frame_counter+1; | |
78 | ||
79 | end if ( frame_counter == crc_clock_period ) | |
80 | frame_counter = 0; | |
81 | ||
82 | ||
83 | ||
84 | if ( tr_counter == 4'hb ) begin | |
85 | tr_counter=0; | |
86 | ||
87 | // If pn_frame_num is FFF, then all frames will have the same crc | |
88 | if ( pn_frame_num == 12'hfff ) begin | |
89 | crc_en = 1; | |
90 | end | |
91 | // If pn_frame_num is non-zero, N number of frames will have crc errors | |
92 | // then crc will be turned off | |
93 | else if ( pn_frame_num !== 0 ) begin | |
94 | crc_en = 1; | |
95 | pn_frame_num = pn_frame_num - 1; | |
96 | end | |
97 | else | |
98 | crc_en = 0; | |
99 | ||
100 | end | |
101 | else | |
102 | tr_counter=tr_counter+1; | |
103 | ||
104 | end | |
105 | else | |
106 | crc_en = 0; | |
107 | ||
108 | ||
109 | assign pn_out = ( ~module_en || init || ~crc_en) ? pn_in: | |
110 | ((tr_counter == 4'h0 ) && crc_en) ? pn_in ^ pn0_crc_mask : | |
111 | ((tr_counter == 4'h1 ) && crc_en) ? pn_in ^ pn1_crc_mask : | |
112 | ((tr_counter == 4'h2 ) && crc_en) ? pn_in ^ pn2_crc_mask : | |
113 | ((tr_counter == 4'h3 ) && crc_en) ? pn_in ^ pn3_crc_mask : | |
114 | ((tr_counter == 4'h4 ) && crc_en) ? pn_in ^ pn4_crc_mask : | |
115 | ((tr_counter == 4'h5 ) && crc_en) ? pn_in ^ pn5_crc_mask : | |
116 | ((tr_counter == 4'h6 ) && crc_en) ? pn_in ^ pn6_crc_mask : | |
117 | ((tr_counter == 4'h7 ) && crc_en) ? pn_in ^ pn7_crc_mask : | |
118 | ((tr_counter == 4'h8 ) && crc_en) ? pn_in ^ pn8_crc_mask : | |
119 | ((tr_counter == 4'h9 ) && crc_en) ? pn_in ^ pn9_crc_mask : | |
120 | ((tr_counter == 4'ha ) && crc_en) ? pn_in ^ pn10_crc_mask : | |
121 | ((tr_counter == 4'hb ) && crc_en) ? pn_in ^ pn11_crc_mask : | |
122 | pn_in ; | |
123 | ||
124 | ||
125 | reg dummy; | |
126 | initial | |
127 | begin | |
128 | ||
129 | tr_counter=0; | |
130 | pn0_crc_mask=14'h0; | |
131 | pn1_crc_mask=14'h0; | |
132 | pn2_crc_mask=14'h0; | |
133 | pn3_crc_mask=14'h0; | |
134 | pn4_crc_mask=14'h0; | |
135 | pn5_crc_mask=14'h0; | |
136 | pn6_crc_mask=14'h0; | |
137 | pn7_crc_mask=14'h0; | |
138 | pn8_crc_mask=14'h0; | |
139 | pn9_crc_mask=14'h0; | |
140 | pn10_crc_mask=14'h0; | |
141 | pn11_crc_mask=14'h0; | |
142 | pn_frame_num=0; | |
143 | frame_counter=0; | |
144 | pn_crc_freq=0; | |
145 | pn_crc_period=0; | |
146 | crc_en=0; | |
147 | ||
148 | `ifdef AXIS_FBDIMM_HW | |
149 | `else | |
150 | dummy=$value$plusargs("pn0_crc_mask=%h",pn0_crc_mask); | |
151 | dummy=$value$plusargs("pn1_crc_mask=%h",pn1_crc_mask); | |
152 | dummy=$value$plusargs("pn2_crc_mask=%h",pn2_crc_mask); | |
153 | dummy=$value$plusargs("pn3_crc_mask=%h",pn3_crc_mask); | |
154 | dummy=$value$plusargs("pn4_crc_mask=%h",pn4_crc_mask); | |
155 | dummy=$value$plusargs("pn5_crc_mask=%h",pn5_crc_mask); | |
156 | dummy=$value$plusargs("pn6_crc_mask=%h",pn6_crc_mask); | |
157 | dummy=$value$plusargs("pn7_crc_mask=%h",pn7_crc_mask); | |
158 | dummy=$value$plusargs("pn8_crc_mask=%h",pn8_crc_mask); | |
159 | dummy=$value$plusargs("pn9_crc_mask=%h",pn9_crc_mask); | |
160 | dummy=$value$plusargs("pn10_crc_mask=%h",pn10_crc_mask); | |
161 | dummy=$value$plusargs("pn11_crc_mask=%h",pn11_crc_mask); | |
162 | dummy=$value$plusargs("pn_frame_num=%h",pn_frame_num); | |
163 | dummy=$value$plusargs("pn_crc_freq=%h",pn_crc_freq); | |
164 | dummy=$value$plusargs("pn_crc_period=%h",pn_crc_period); | |
165 | `endif | |
166 | ||
167 | /* | |
168 | $display("CRC: pn0_crc_mask = %h\n",pn0_crc_mask); | |
169 | $display("CRC: pn1_crc_mask = %h\n",pn1_crc_mask); | |
170 | $display("CRC: pn2_crc_mask = %h\n",pn2_crc_mask); | |
171 | $display("CRC: pn3_crc_mask = %h\n",pn3_crc_mask); | |
172 | $display("CRC: pn4_crc_mask = %h\n",pn4_crc_mask); | |
173 | $display("CRC: pn5_crc_mask = %h\n",pn5_crc_mask); | |
174 | $display("CRC: pn6_crc_mask = %h\n",pn6_crc_mask); | |
175 | $display("CRC: pn7_crc_mask = %h\n",pn7_crc_mask); | |
176 | $display("CRC: pn8_crc_mask = %h\n",pn8_crc_mask); | |
177 | $display("CRC: pn9_crc_mask = %h\n",pn9_crc_mask); | |
178 | $display("CRC: pn10_crc_mask = %h\n",pn10_crc_mask); | |
179 | $display("CRC: pn11_crc_mask = %h\n",pn11_crc_mask); | |
180 | */ | |
181 | ||
182 | end | |
183 | ||
184 | ||
185 | endmodule | |
186 |