Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / verilog / mem / fbdimm / design / nb_crc_error_injector.v
CommitLineData
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 ============================================
35module nb_crc_error_injector(pn_in,pn_out,init,sclk);
36parameter DS=0;
37
38// interface signals
39input [13:0] pn_in;
40output [13:0] pn_out;
41input init;
42input sclk;
43
44reg [13:0] pn0_crc_mask;
45reg [13:0] pn1_crc_mask;
46reg [13:0] pn2_crc_mask;
47reg [13:0] pn3_crc_mask;
48reg [13:0] pn4_crc_mask;
49reg [13:0] pn5_crc_mask;
50reg [13:0] pn6_crc_mask;
51reg [13:0] pn7_crc_mask;
52reg [13:0] pn8_crc_mask;
53reg [13:0] pn9_crc_mask;
54reg [13:0] pn10_crc_mask;
55reg [13:0] pn11_crc_mask;
56reg [11:0] pn_frame_num;
57reg [3:0] tr_counter;
58reg [11:0] pn_crc_freq;
59reg [11:0] pn_crc_period;
60reg crc_en;
61reg [15:0] frame_counter;
62wire module_en = (DS == 0 );
63wire [15:0] crc_clock_period = (pn_crc_freq+pn_crc_period)*16'h6;
64
65always@(posedge sclk) if ( ~init && ( pn_frame_num !==0 ) )
66begin
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
104end
105else
106 crc_en = 0;
107
108
109assign 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
125reg dummy;
126initial
127begin
128
129tr_counter=0;
130pn0_crc_mask=14'h0;
131pn1_crc_mask=14'h0;
132pn2_crc_mask=14'h0;
133pn3_crc_mask=14'h0;
134pn4_crc_mask=14'h0;
135pn5_crc_mask=14'h0;
136pn6_crc_mask=14'h0;
137pn7_crc_mask=14'h0;
138pn8_crc_mask=14'h0;
139pn9_crc_mask=14'h0;
140pn10_crc_mask=14'h0;
141pn11_crc_mask=14'h0;
142pn_frame_num=0;
143frame_counter=0;
144pn_crc_freq=0;
145pn_crc_period=0;
146crc_en=0;
147
148`ifdef AXIS_FBDIMM_HW
149`else
150dummy=$value$plusargs("pn0_crc_mask=%h",pn0_crc_mask);
151dummy=$value$plusargs("pn1_crc_mask=%h",pn1_crc_mask);
152dummy=$value$plusargs("pn2_crc_mask=%h",pn2_crc_mask);
153dummy=$value$plusargs("pn3_crc_mask=%h",pn3_crc_mask);
154dummy=$value$plusargs("pn4_crc_mask=%h",pn4_crc_mask);
155dummy=$value$plusargs("pn5_crc_mask=%h",pn5_crc_mask);
156dummy=$value$plusargs("pn6_crc_mask=%h",pn6_crc_mask);
157dummy=$value$plusargs("pn7_crc_mask=%h",pn7_crc_mask);
158dummy=$value$plusargs("pn8_crc_mask=%h",pn8_crc_mask);
159dummy=$value$plusargs("pn9_crc_mask=%h",pn9_crc_mask);
160dummy=$value$plusargs("pn10_crc_mask=%h",pn10_crc_mask);
161dummy=$value$plusargs("pn11_crc_mask=%h",pn11_crc_mask);
162dummy=$value$plusargs("pn_frame_num=%h",pn_frame_num);
163dummy=$value$plusargs("pn_crc_freq=%h",pn_crc_freq);
164dummy=$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
182end
183
184
185endmodule
186