| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: niu_pio_macros.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 : niu_pio_macros.v |
| 40 | * Author Name : John Lo |
| 41 | * Description : It contains macros. |
| 42 | * |
| 43 | * Parent Module: |
| 44 | * Child Module: |
| 45 | * Interface Mod: many. |
| 46 | * Date Created : 3/15/04 |
| 47 | * |
| 48 | * Copyright (c) 2020, Sun Microsystems, Inc. |
| 49 | * Sun Proprietary and Confidential |
| 50 | * |
| 51 | * Modification : |
| 52 | * |
| 53 | ****************************************************************/ |
| 54 | |
| 55 | |
| 56 | //***************************** |
| 57 | // Register xREG2 |
| 58 | //***************************** |
| 59 | module pio_xREG2 (clk,reset,reset_value,load,din,qout); |
| 60 | |
| 61 | parameter dwidth = 10; |
| 62 | input clk; |
| 63 | input reset; |
| 64 | input [dwidth-1:0] reset_value; |
| 65 | input load; |
| 66 | input [dwidth-1:0] din; |
| 67 | output [dwidth-1:0] qout; |
| 68 | |
| 69 | reg [dwidth-1:0] qout; |
| 70 | |
| 71 | |
| 72 | always @ (posedge clk) |
| 73 | if (reset) |
| 74 | qout <= reset_value; |
| 75 | else if (load) |
| 76 | qout <= din; |
| 77 | else |
| 78 | qout <= qout; |
| 79 | |
| 80 | endmodule |
| 81 | |
| 82 | |
| 83 | /*********************************** |
| 84 | * 1 bit rst reset dff |
| 85 | ***********************************/ |
| 86 | module rffre (clk,reset,rst,en,d,q); |
| 87 | |
| 88 | input clk; |
| 89 | input reset; |
| 90 | input rst; |
| 91 | input en; |
| 92 | input d; |
| 93 | output q; |
| 94 | |
| 95 | reg nx_q; |
| 96 | wire q; |
| 97 | |
| 98 | always @ (rst or en or d or q) |
| 99 | if (rst) |
| 100 | nx_q = 0; |
| 101 | else if (en) |
| 102 | nx_q = d; |
| 103 | else |
| 104 | nx_q = q; |
| 105 | |
| 106 | dffr #(1) dffr (.clk(clk),.reset(reset),.d(nx_q),.q(q)); |
| 107 | |
| 108 | endmodule |
| 109 | |
| 110 | /*********************************** |
| 111 | * 6 bit count down counter |
| 112 | ***********************************/ |
| 113 | module timer_6bit (clk,reset,rst,dec,en,d,q); |
| 114 | |
| 115 | input clk; |
| 116 | input reset; |
| 117 | input rst; |
| 118 | input dec; |
| 119 | input en; |
| 120 | input [5:0] d; |
| 121 | output [5:0] q; |
| 122 | |
| 123 | reg [5:0] nx_q; |
| 124 | wire [5:0] q; |
| 125 | |
| 126 | always @ (rst or en or d or q or dec) |
| 127 | if (rst) |
| 128 | nx_q = 0; |
| 129 | else if (en) |
| 130 | nx_q = d; |
| 131 | else if (~(|q)) // q == 0 |
| 132 | nx_q = q; |
| 133 | else if (dec) |
| 134 | nx_q = q -1; |
| 135 | else |
| 136 | nx_q = q; |
| 137 | |
| 138 | dffr #(6) dffr (.clk(clk),.reset(reset),.d(nx_q),.q(q)); |
| 139 | |
| 140 | endmodule // timer_6bit |
| 141 | |
| 142 | /*********************************** |
| 143 | * 20 bit resolution counter |
| 144 | ***********************************/ |
| 145 | module rtimer_20bit (clk,reset,dec_timer,en,d,q); |
| 146 | |
| 147 | input clk; |
| 148 | input reset; |
| 149 | input en; |
| 150 | input [19:0] d; |
| 151 | output dec_timer; |
| 152 | output [19:0] q; |
| 153 | |
| 154 | |
| 155 | reg [19:0] nx_cnt; |
| 156 | wire [19:0] cnt; |
| 157 | wire timer_pls; |
| 158 | |
| 159 | dffre #(20) resolution_dffre (.clk(clk),.reset(reset),.en(en),.d(d),.q(q)); |
| 160 | |
| 161 | // assign nx_cnt = cnt +1; |
| 162 | always @ (q or cnt or timer_pls) |
| 163 | if ((~(|q)) | timer_pls) // q == 0 |
| 164 | nx_cnt = 0; |
| 165 | else |
| 166 | nx_cnt = cnt+1; |
| 167 | |
| 168 | dffr #(20) cnt_dffr (.clk(clk),.reset(reset),.d(nx_cnt),.q(cnt)); |
| 169 | |
| 170 | assign timer_pls = (cnt == q) ; |
| 171 | |
| 172 | df1 #(1) dec_timer_df1 (.clk(clk),.d(timer_pls),.q(dec_timer)); |
| 173 | |
| 174 | endmodule // timer_6bit |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | module niu_pls_gen2 (clk,sig_in,lead,trail); |
| 180 | input sig_in, clk; |
| 181 | output lead,trail; |
| 182 | |
| 183 | wire sig_in, sig_out,lead,trail; |
| 184 | df1 sig_out_df1 (.clk(clk),.d(sig_in),.q(sig_out)); |
| 185 | assign lead = sig_in & ~sig_out; |
| 186 | assign trail= ~sig_in & sig_out; |
| 187 | |
| 188 | endmodule |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | module mux_r64to1(din,sel,dout); |
| 194 | input [63:0] din; |
| 195 | input [5:0] sel; |
| 196 | output dout; |
| 197 | |
| 198 | wire [5:0] sel; |
| 199 | reg dout; |
| 200 | |
| 201 | always @ (sel or din) |
| 202 | casex(sel) // synopsys parallel_case full_case |
| 203 | 6'd0 : dout = din[63] ; |
| 204 | 6'd1 : dout = din[62] ; |
| 205 | 6'd2 : dout = din[61] ; |
| 206 | 6'd3 : dout = din[60] ; |
| 207 | 6'd4 : dout = din[59] ; |
| 208 | 6'd5 : dout = din[58] ; |
| 209 | 6'd6 : dout = din[57] ; |
| 210 | 6'd7 : dout = din[56] ; |
| 211 | 6'd8 : dout = din[55] ; |
| 212 | 6'd9 : dout = din[54] ; |
| 213 | 6'd10 : dout = din[53] ; |
| 214 | 6'd11 : dout = din[52] ; |
| 215 | 6'd12 : dout = din[51] ; |
| 216 | 6'd13 : dout = din[50] ; |
| 217 | 6'd14 : dout = din[49] ; |
| 218 | 6'd15 : dout = din[48] ; |
| 219 | 6'd16 : dout = din[47] ; |
| 220 | 6'd17 : dout = din[46] ; |
| 221 | 6'd18 : dout = din[45] ; |
| 222 | 6'd19 : dout = din[44] ; |
| 223 | 6'd20 : dout = din[43] ; |
| 224 | 6'd21 : dout = din[42] ; |
| 225 | 6'd22 : dout = din[41] ; |
| 226 | 6'd23 : dout = din[40] ; |
| 227 | 6'd24 : dout = din[39] ; |
| 228 | 6'd25 : dout = din[38] ; |
| 229 | 6'd26 : dout = din[37] ; |
| 230 | 6'd27 : dout = din[36] ; |
| 231 | 6'd28 : dout = din[35] ; |
| 232 | 6'd29 : dout = din[34] ; |
| 233 | 6'd30 : dout = din[33] ; |
| 234 | 6'd31 : dout = din[32] ; |
| 235 | 6'd32 : dout = din[31] ; |
| 236 | 6'd33 : dout = din[30] ; |
| 237 | 6'd34 : dout = din[29] ; |
| 238 | 6'd35 : dout = din[28] ; |
| 239 | 6'd36 : dout = din[27] ; |
| 240 | 6'd37 : dout = din[26] ; |
| 241 | 6'd38 : dout = din[25] ; |
| 242 | 6'd39 : dout = din[24] ; |
| 243 | 6'd40 : dout = din[23] ; |
| 244 | 6'd41 : dout = din[22] ; |
| 245 | 6'd42 : dout = din[21] ; |
| 246 | 6'd43 : dout = din[20] ; |
| 247 | 6'd44 : dout = din[19] ; |
| 248 | 6'd45 : dout = din[18] ; |
| 249 | 6'd46 : dout = din[17] ; |
| 250 | 6'd47 : dout = din[16] ; |
| 251 | 6'd48 : dout = din[15] ; |
| 252 | 6'd49 : dout = din[14] ; |
| 253 | 6'd50 : dout = din[13] ; |
| 254 | 6'd51 : dout = din[12] ; |
| 255 | 6'd52 : dout = din[11] ; |
| 256 | 6'd53 : dout = din[10] ; |
| 257 | 6'd54 : dout = din[9] ; |
| 258 | 6'd55 : dout = din[8] ; |
| 259 | 6'd56 : dout = din[7] ; |
| 260 | 6'd57 : dout = din[6] ; |
| 261 | 6'd58 : dout = din[5] ; |
| 262 | 6'd59 : dout = din[4] ; |
| 263 | 6'd60 : dout = din[3] ; |
| 264 | 6'd61 : dout = din[2] ; |
| 265 | 6'd62 : dout = din[1] ; |
| 266 | 6'd63 : dout = din[0] ; |
| 267 | endcase |
| 268 | |
| 269 | endmodule // mux_r64to1 |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | module niu_pio_mux_2to1_x144(dout, select, din1, din0); |
| 275 | input select; |
| 276 | input [143:0] din1, din0; |
| 277 | output [143:0] dout; |
| 278 | |
| 279 | wire [143:0] din1, din0, dout; |
| 280 | |
| 281 | // Use the following code when IBM is NOT used as founder |
| 282 | assign dout = select ? din1 : din0; |
| 283 | |
| 284 | |
| 285 | endmodule // niu_pio_mux_2to1_x144 |
| 286 | |
| 287 | |
| 288 | |