1 /*
2  * Copyright (c) 2000 Stephen Williams (steve@icarus.com)
3  *
4  *    This source code is free software; you can redistribute it
5  *    and/or modify it in source code form under the terms of the GNU
6  *    General Public License as published by the Free Software
7  *    Foundation; either version 2 of the License, or (at your option)
8  *    any later version.
9  *
10  *    This program is distributed in the hope that it will be useful,
11  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *    GNU General Public License for more details.
14  *
15  *    You should have received a copy of the GNU General Public License
16  *    along with this program; if not, write to the Free Software
17  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 # include "config.h"
21 # include  "ivl_target.h"
22 # include  <assert.h>
23 # include  "priv.h"
24 
25 /*
26  * Given a pin index, look at the nexus for a bufif device that is
27  * driving it, if any. Save that device in the enable slot for the
28  * cell. We'll try to fit it later.
29  */
absorb_pad_enable(unsigned idx)30 static void absorb_pad_enable(unsigned idx)
31 {
32       unsigned ndx;
33       ivl_nexus_t nex = bind_pin[idx].nexus;
34 
35       for (ndx = 0 ;  ndx < ivl_nexus_ptrs(nex) ;  ndx += 1) {
36 
37 	    unsigned pin;
38 	    ivl_nexus_ptr_t ptr = ivl_nexus_ptr(nex, ndx);
39 	    ivl_net_logic_t log = ivl_nexus_ptr_log(ptr);
40 
41 	    if (log == 0)
42 		  continue;
43 
44 	    pin = ivl_nexus_ptr_pin(ptr);
45 	    assert(pin == 0);
46 
47 	    switch (ivl_logic_type(log)) {
48 
49 		case IVL_LO_BUFIF0:
50 		case IVL_LO_BUFIF1:
51 		  assert(bind_pin[idx].enable == 0);
52 		  bind_pin[idx].enable = log;
53 		  break;
54 
55 		default:
56 	    }
57       }
58 }
59 
absorb_pad_enables(void)60 void absorb_pad_enables(void)
61 {
62       unsigned idx;
63 
64       for (idx = 0 ;  idx < pins ;  idx += 1) {
65 
66 	    if (bind_pin[idx].sop == 0)
67 		  continue;
68 
69 	    if (bind_pin[idx].nexus == 0)
70 		  continue;
71 
72 	    absorb_pad_enable(idx);
73       }
74 }
75