~ubuntu-branches/ubuntu/jaunty/electric/jaunty

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/ncc/netlist/PartTypeTable.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2009-01-08 02:05:08 UTC
  • mfrom: (1.1.2 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090108020508-0h3li7zt9mu5gf0i
Tags: 8.08-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- tab-width: 4 -*-
2
 
 *
3
 
 * Electric(tm) VLSI Design System
4
 
 *
5
 
 * File: PartTypeTable.java
6
 
 *
7
 
 * Copyright (c) 2005 Sun Microsystems and Static Free Software
8
 
 *
9
 
 * Electric(tm) 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; either version 3 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * Electric(tm) is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with Electric(tm); see the file COPYING.  If not, write to
21
 
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
 
 * Boston, Mass 02111-1307, USA.
23
 
 */
24
 
package com.sun.electric.tool.ncc.netlist;
25
 
 
26
 
import java.util.ArrayList;
27
 
import java.util.HashMap;
28
 
import java.util.Iterator;
29
 
 
30
 
import com.sun.electric.tool.generator.layout.LayoutLib;
31
 
 
32
 
/**
33
 
 * Transistor and resistor types have long and short names. In Electric, 
34
 
 * schematic and layout primitive transistors have different names. NCC uses 
35
 
 * the long name to match types between the schematic and layout. Except for 
36
 
 * the basic NMOS and PMOS types, each schematic transistor contains an 
37
 
 * annotation specifying which layout transistor it matches.
38
 
 * The short names are used internally for NCC print-outs because the long
39
 
 * names are too verbose.
40
 
 * 
41
 
 * Scalable transistors, in the layout, have a different long name than
42
 
 * regular transistor but map to the same type as ordinary layout transistors.
43
 
 */
44
 
public class PartTypeTable {
45
 
        private int numTypes = 0;
46
 
        private int log2NumTypes;
47
 
        private ArrayList<PartType> types = new ArrayList<PartType>();
48
 
        private HashMap<String,PartType> nameToType = new HashMap<String,PartType>();
49
 
        /** Long type names are used only to identify transistors when NCC creates
50
 
         *  the net lists. */
51
 
        private HashMap<String,PartType> longNameToType = new HashMap<String,PartType>();
52
 
        private void add(String typeName, String longTypeName) {
53
 
                PartType t = nameToType.get(typeName);
54
 
                if (t==null) {
55
 
                        t = new PartType(numTypes++, typeName);
56
 
                        nameToType.put(typeName, t);
57
 
                }
58
 
                LayoutLib.error(longNameToType.containsKey(longTypeName), 
59
 
                                        "duplicate long type name");
60
 
                longNameToType.put(longTypeName, t);
61
 
                types.add(t);
62
 
 
63
 
                log2NumTypes = (int) Math.ceil( Math.log(numTypes)/Math.log(2) );
64
 
        }
65
 
        public PartTypeTable(String[][] typeNames) {
66
 
                for (int i=0; i<typeNames.length; i++) {
67
 
                        add(typeNames[i][0], typeNames[i][1]);
68
 
                }
69
 
        }
70
 
        public int log2NumTypes() {return log2NumTypes;}
71
 
        public Iterator<PartType> iterator() {return types.iterator();}
72
 
        public PartType get(String nm) {return nameToType.get(nm);}
73
 
        public PartType getTypeFromLongName(String nm) {
74
 
                return longNameToType.get(nm);
75
 
        }
76
 
}