source: XOpenSparcT1/trunk/T1-CPU/tlu/tlu_prencoder16.v @ 6

Revision 6, 2.9 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

Line 
1// ========== 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`include        "sys.h" // system level definition file which contains the
33                        // time scale definition
34
35////////////////////////////////////////////////////////////////////////
36// Local header file includes / local defines
37////////////////////////////////////////////////////////////////////////
38
39module  tlu_prencoder16 (din, dout);
40
41input   [14:0]  din  ;
42output  [3:0]   dout ;
43
44wire    [14:0]  onehot ;
45
46assign  onehot[14] = din[14] ;
47assign  onehot[13] = din[13] & ~din[14] ;
48assign  onehot[12] = din[12] & ~(|din[14:13]) ;
49assign  onehot[11] = din[11] & ~(|din[14:12]) ;
50assign  onehot[10] = din[10] & ~(|din[14:11]) ;
51assign  onehot[9]  = din[9]  & ~(|din[14:10]) ;
52assign  onehot[8]  = din[8]  & ~(|din[14:9]) ;
53assign  onehot[7]  = din[7]  & ~(|din[14:8]) ;
54assign  onehot[6]  = din[6]  & ~(|din[14:7]) ;
55assign  onehot[5]  = din[5]  & ~(|din[14:6]) ;
56assign  onehot[4]  = din[4]  & ~(|din[14:5]) ;
57assign  onehot[3]  = din[3]  & ~(|din[14:4]) ;
58assign  onehot[2]  = din[2]  & ~(|din[14:3]) ;
59assign  onehot[1]  = din[1]  & ~(|din[14:2]) ;
60assign  onehot[0]  = din[0]  & ~(|din[14:1]) ;
61//assign        onehot[0]  = din[0]  & ~(|din[15:1]) ;
62
63assign  dout[3]  =  |onehot[14:7] ;
64assign  dout[2]  = (|onehot[6:3]) | (|onehot[14:11]) ;
65assign  dout[1]  = (|onehot[2:1]) | (|onehot[6:5]) |
66                   (|onehot[10:9]) | (|onehot[14:13]) ;
67assign  dout[0]  =  onehot[0] | onehot[2] | onehot[4] | onehot[6] |
68                    onehot[8] | onehot[10] | onehot[12] | onehot[14] ;
69
70endmodule
Note: See TracBrowser for help on using the repository browser.