Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / crc_gen_xmii.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: crc_gen_xmii.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/*%W% %G%*/
36
37/*************************************************************************
38 *
39 * File Name : crc_gen_xmii.v
40 * Author Name : John Lo
41 * Description : crc generation logic
42 * Parent Module: rx_fcs_xmii
43 * Child Module:
44 * Interface Mod: many.
45 * Date Created : 5/9/00
46 *
47 * Copyright (c) 2002, Sun Microsystems, Inc.
48 * Sun Proprietary and Confidential
49 *
50 * Modification :
51 *
52 * Synthesis Notes:
53 * This module is very timing critical. It has
54 * a long xor chain to calculate crc. Special care
55 * must be taker to insure timing integrity.
56 * It should be synthesized and layout independently
57 * that the optimal timing goal can be achieved.
58 * Written on Feb. 10th, 2000 - John Lo
59 *
60 *************************************************************************/
61
62module crc_gen_xmii (clk,initialize_crc,compute_en,
63 data_valid,dv_8bit,
64 input_byte0,input_byte1,input_byte2,
65 input_byte3,input_byte4,input_byte5,
66 input_byte6,input_byte7,
67 new_crc5_result,
68 crc_result);
69 input clk,initialize_crc,compute_en;
70 // vlint flag_input_port_not_connected off
71 input data_valid;
72 // vlint flag_input_port_not_connected on
73 input [7:0] dv_8bit;
74 input [7:0] input_byte0;
75 input [7:0] input_byte1;
76 input [7:0] input_byte2;
77 input [7:0] input_byte3;
78 input [7:0] input_byte4;
79 input [7:0] input_byte5;
80 input [7:0] input_byte6;
81 input [7:0] input_byte7;
82 output [31:0] new_crc5_result;
83 output [31:0] crc_result;
84
85 wire [31:0] new_crc0;
86 wire [31:0] new_crc1;
87 wire [31:0] new_crc2;
88 wire [31:0] new_crc3;
89 wire [31:0] new_crc4;
90 wire [31:0] new_crc5;
91 wire [31:0] new_crc6;
92 wire [31:0] new_crc7;
93 wire [31:0] new_crc_final;
94 wire [31:0] current_crc_final;
95 reg [31:0] new_crc_result;
96 wire [31:0] new_crc5_result = ~new_crc5;
97 // vlint flag_dangling_net_within_module off
98 // vlint flag_net_has_no_load off
99 // vlint flag_input_port_not_connected off
100 wire data_valid;
101 // vlint flag_input_port_not_connected on
102 // vlint flag_net_has_no_load on
103 // vlint flag_dangling_net_within_module on
104
105crc_com_part stage0(.input_byte(input_byte0),.current_crc(current_crc_final),.new_crc(new_crc0));
106crc_com_part stage1(.input_byte(input_byte1),.current_crc(new_crc0),.new_crc(new_crc1));
107crc_com_part stage2(.input_byte(input_byte2),.current_crc(new_crc1),.new_crc(new_crc2));
108crc_com_part stage3(.input_byte(input_byte3),.current_crc(new_crc2),.new_crc(new_crc3));
109crc_com_part stage4(.input_byte(input_byte4),.current_crc(new_crc3),.new_crc(new_crc4));
110crc_com_part stage5(.input_byte(input_byte5),.current_crc(new_crc4),.new_crc(new_crc5));
111crc_com_part stage6(.input_byte(input_byte6),.current_crc(new_crc5),.new_crc(new_crc6));
112crc_com_part stage7(.input_byte(input_byte7),.current_crc(new_crc6),.new_crc(new_crc7));
113
114assign new_crc_final = initialize_crc ? 32'hff_ff_ff_ff :
115 compute_en ? new_crc_result : current_crc_final;
116
117// vlint flag_variable_in_sensitivity_list_not_used_in_block off
118always @ (/*AUTOSENSE*/data_valid or dv_8bit or new_crc0 or new_crc1
119 or new_crc2 or new_crc3 or new_crc4 or new_crc5 or new_crc6
120 or new_crc7)
121 begin
122 casex (dv_8bit) // synopsys parallel_case full_case
123 8'b1xxxxxxx: new_crc_result = new_crc7;
124 8'b01xxxxxx: new_crc_result = new_crc6;
125 8'b001xxxxx: new_crc_result = new_crc5;
126 8'b0001xxxx: new_crc_result = new_crc4;
127 8'b00001xxx: new_crc_result = new_crc3;
128 8'b000001xx: new_crc_result = new_crc2;
129 8'b0000001x: new_crc_result = new_crc1;
130 8'b00000001: new_crc_result = new_crc0;
131 default: begin
132 new_crc_result = new_crc7;
133 // synopsys translate_off
134 if (data_valid)
135 $display("\n (* ERROR: at sim time = %d, crc_gen contains invalid combination of dv_8bit = %b *) \n", $time, dv_8bit);
136 else ;
137 // synopsys translate_on
138 end // case: default
139 endcase // casex(dv_8bit)
140 end // always @ (...
141// vlint flag_variable_in_sensitivity_list_not_used_in_block on
142
143register_X32 rx_crc_result_register_X32(.clk(clk),.din(new_crc_final),.dout(current_crc_final),.dout_n(crc_result));
144
145endmodule // crc_gen_xmii
146
147
148
149module crc_com_part (input_byte,current_crc,new_crc);
150 input [7:0] input_byte;
151 input [31:0] current_crc;
152 output [31:0] new_crc;
153
154 wire [7:0] crc_in;
155 wire [31:0] current_crc,new_crc;
156//\f
157 assign crc_in[0] = current_crc[31] ^ input_byte[7];
158 assign crc_in[1] = current_crc[30] ^ input_byte[6];
159 assign crc_in[2] = current_crc[29] ^ input_byte[5];
160 assign crc_in[3] = current_crc[28] ^ input_byte[4];
161 assign crc_in[4] = current_crc[27] ^ input_byte[3];
162 assign crc_in[5] = current_crc[26] ^ input_byte[2];
163 assign crc_in[6] = current_crc[25] ^ input_byte[1] ^ crc_in[0];
164 assign crc_in[7] = current_crc[24] ^ input_byte[0] ^ crc_in[1];
165
166 assign new_crc[31] = (current_crc[23] ^ crc_in[2]) ;
167 assign new_crc[30] = (current_crc[22] ^ crc_in[0] ^ crc_in[3]);
168 assign new_crc[29] = (current_crc[21] ^ crc_in[0] ^ crc_in[1] ^ crc_in[4]);
169 assign new_crc[28] = (current_crc[20] ^ crc_in[1] ^ crc_in[2] ^ crc_in[5]);
170 assign new_crc[27] = (current_crc[19] ^ crc_in[2] ^ crc_in[3] ^ crc_in[6]);
171 assign new_crc[26] = (current_crc[18] ^ crc_in[3] ^ crc_in[4] ^ crc_in[7]);
172 assign new_crc[25] = (current_crc[17] ^ crc_in[4] ^ crc_in[5]);
173 assign new_crc[24] = (current_crc[16] ^ crc_in[5] ^ crc_in[6]);
174 assign new_crc[23] = (current_crc[15] ^ crc_in[0] ^ crc_in[6] ^ crc_in[7]);
175 assign new_crc[22] = (current_crc[14] ^ crc_in[1] ^ crc_in[7]);
176 assign new_crc[21] = (current_crc[13] ^ crc_in[2]);
177 assign new_crc[20] = (current_crc[12] ^ crc_in[3]);
178 assign new_crc[19] = (current_crc[11] ^ crc_in[0] ^ crc_in[4]);
179 assign new_crc[18] = (current_crc[10] ^ crc_in[0] ^ crc_in[1] ^ crc_in[5]);
180 assign new_crc[17] = (current_crc[9] ^ crc_in[0] ^ crc_in[1] ^ crc_in[2] ^ crc_in[6]);
181 assign new_crc[16] = (current_crc[8] ^ crc_in[1] ^ crc_in[2] ^ crc_in[3] ^ crc_in[7]);
182 assign new_crc[15] = (current_crc[7] ^ crc_in[0] ^ crc_in[2] ^ crc_in[3] ^ crc_in[4]);
183 assign new_crc[14] = (current_crc[6] ^ crc_in[0] ^ crc_in[1] ^ crc_in[3] ^ crc_in[4] ^ crc_in[5]);
184 assign new_crc[13] = (current_crc[5] ^ crc_in[1] ^ crc_in[2] ^ crc_in[4] ^ crc_in[5] ^ crc_in[6]);
185 assign new_crc[12] = (current_crc[4] ^ crc_in[0] ^ crc_in[2] ^ crc_in[3] ^ crc_in[5] ^ crc_in[6] ^ crc_in[7]);
186 assign new_crc[11] = (current_crc[3] ^ crc_in[0] ^ crc_in[1] ^ crc_in[3] ^ crc_in[4] ^ crc_in[6] ^ crc_in[7]);
187 assign new_crc[10] = (current_crc[2] ^ crc_in[1] ^ crc_in[2] ^ crc_in[4] ^ crc_in[5] ^ crc_in[7]);
188 assign new_crc[9] = (current_crc[1] ^ crc_in[0] ^ crc_in[2] ^ crc_in[3] ^ crc_in[5] ^ crc_in[6]);
189 assign new_crc[8] = (current_crc[0] ^ crc_in[0] ^ crc_in[1] ^ crc_in[3] ^ crc_in[4] ^ crc_in[6] ^ crc_in[7]);
190 assign new_crc[7] = (crc_in[0] ^ crc_in[1] ^ crc_in[2] ^ crc_in[4] ^ crc_in[5] ^ crc_in[7]);
191 assign new_crc[6] = (crc_in[1] ^ crc_in[2] ^ crc_in[3] ^ crc_in[5] ^ crc_in[6]);
192 assign new_crc[5] = (crc_in[2] ^ crc_in[3] ^ crc_in[4] ^ crc_in[6] ^ crc_in[7]);
193 assign new_crc[4] = (crc_in[3] ^ crc_in[4] ^ crc_in[5] ^ crc_in[7]);
194 assign new_crc[3] = (crc_in[4] ^ crc_in[5] ^ crc_in[6]);
195 assign new_crc[2] = (crc_in[5] ^ crc_in[6] ^ crc_in[7]);
196 assign new_crc[1] = (crc_in[6] ^ crc_in[7]);
197 assign new_crc[0] = crc_in[7];
198
199endmodule // crc_com_part
200
201