1 |
95 |
fafa1971 |
// ========== Copyright Header Begin ==========================================
|
2 |
|
|
//
|
3 |
|
|
// OpenSPARC T1 Processor File: tlu_prencoder16.v
|
4 |
|
|
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
|
5 |
|
|
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
|
6 |
|
|
//
|
7 |
|
|
// The above named program is free software; you can redistribute it and/or
|
8 |
|
|
// modify it under the terms of the GNU General Public
|
9 |
|
|
// License version 2 as published by the Free Software Foundation.
|
10 |
|
|
//
|
11 |
|
|
// The above named program is distributed in the hope that it will be
|
12 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public
|
17 |
|
|
// License along with this work; if not, write to the Free Software
|
18 |
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
|
|
//
|
20 |
|
|
// ========== Copyright Header End ============================================
|
21 |
|
|
////////////////////////////////////////////////////////////////////////
|
22 |
|
|
/*
|
23 |
|
|
// Description: Datapath Priority Encoder 16b
|
24 |
|
|
// - 15b multihot vector as input
|
25 |
|
|
// - 15b 1-hit vector as output
|
26 |
|
|
// - Can use some std length such as 16b
|
27 |
|
|
// - msb is given highest priority
|
28 |
|
|
*/
|
29 |
|
|
////////////////////////////////////////////////////////////////////////
|
30 |
|
|
// Global header file includes
|
31 |
|
|
////////////////////////////////////////////////////////////////////////
|
32 |
113 |
albert.wat |
`include "sys.h" // system level definition file which contains the
|
33 |
95 |
fafa1971 |
// time scale definition
|
34 |
|
|
|
35 |
|
|
////////////////////////////////////////////////////////////////////////
|
36 |
|
|
// Local header file includes / local defines
|
37 |
|
|
////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
module tlu_prencoder16 (din, dout);
|
40 |
|
|
|
41 |
|
|
input [14:0] din ;
|
42 |
|
|
output [3:0] dout ;
|
43 |
|
|
|
44 |
|
|
wire [14:0] onehot ;
|
45 |
|
|
|
46 |
|
|
assign onehot[14] = din[14] ;
|
47 |
|
|
assign onehot[13] = din[13] & ~din[14] ;
|
48 |
|
|
assign onehot[12] = din[12] & ~(|din[14:13]) ;
|
49 |
|
|
assign onehot[11] = din[11] & ~(|din[14:12]) ;
|
50 |
|
|
assign onehot[10] = din[10] & ~(|din[14:11]) ;
|
51 |
|
|
assign onehot[9] = din[9] & ~(|din[14:10]) ;
|
52 |
|
|
assign onehot[8] = din[8] & ~(|din[14:9]) ;
|
53 |
|
|
assign onehot[7] = din[7] & ~(|din[14:8]) ;
|
54 |
|
|
assign onehot[6] = din[6] & ~(|din[14:7]) ;
|
55 |
|
|
assign onehot[5] = din[5] & ~(|din[14:6]) ;
|
56 |
|
|
assign onehot[4] = din[4] & ~(|din[14:5]) ;
|
57 |
|
|
assign onehot[3] = din[3] & ~(|din[14:4]) ;
|
58 |
|
|
assign onehot[2] = din[2] & ~(|din[14:3]) ;
|
59 |
|
|
assign onehot[1] = din[1] & ~(|din[14:2]) ;
|
60 |
|
|
assign onehot[0] = din[0] & ~(|din[14:1]) ;
|
61 |
|
|
//assign onehot[0] = din[0] & ~(|din[15:1]) ;
|
62 |
|
|
|
63 |
|
|
assign dout[3] = |onehot[14:7] ;
|
64 |
|
|
assign dout[2] = (|onehot[6:3]) | (|onehot[14:11]) ;
|
65 |
|
|
assign dout[1] = (|onehot[2:1]) | (|onehot[6:5]) |
|
66 |
|
|
(|onehot[10:9]) | (|onehot[14:13]) ;
|
67 |
|
|
assign dout[0] = onehot[0] | onehot[2] | onehot[4] | onehot[6] |
|
68 |
|
|
onehot[8] | onehot[10] | onehot[12] | onehot[14] ;
|
69 |
|
|
|
70 |
|
|
endmodule
|