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

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/io/input/verilog/VerilogReader.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:
86
86
        }
87
87
    }
88
88
 
89
 
    private void createInstance(Cell parent, VerilogData verilogData,
90
 
                                VerilogData.VerilogModule module, Cell icon, CellInstance info)
91
 
    {
92
 
        NodeInst cellInst = NodeInst.newInstance(icon, getNextLocation(parent), 10, 10, parent,
93
 
                        Orientation.IDENT, info.name, 0);
94
 
 
95
 
        List<String> localPorts = new ArrayList<String>();
96
 
 
97
 
        for (CellInstance.PortInfo port : info.list)
98
 
        {
99
 
            localPorts.clear();
100
 
 
101
 
            String portLocal = port.local;
102
 
 
103
 
            // It is unknown how many pins are coming in the stream
104
 
            if (portLocal.contains("{"))
105
 
            {
106
 
                StringTokenizer parse = new StringTokenizer(portLocal, "{,}", false); // extracting pins
107
 
                while (parse.hasMoreTokens())
108
 
                {
109
 
                    String name = parse.nextToken();
110
 
                    name = name.replaceAll(" ", "");
111
 
                    localPorts.add(name);
112
 
                }
113
 
            }
114
 
            else
115
 
                localPorts.add(portLocal);
116
 
 
117
 
            for (String s : localPorts)
118
 
            {
119
 
                NodeInst pin = pinsMap.get(s);
120
 
 
121
 
                if (pin == null)
122
 
                {
123
 
                    int index = s.indexOf("[");
124
 
                    if (index != -1)
125
 
                    {
126
 
                        s = s.substring(0, index);
127
 
                        pin = pinsMap.get(s);
128
 
                    }
129
 
                }
130
 
 
131
 
                if (pin == null)
132
 
                {
133
 
                    if (s.equals("vss")) // ground
134
 
                    {
135
 
                        pin = readSupply(module, false, s);
136
 
                    }
137
 
                    else
138
 
                    {
139
 
                        if (Job.getDebug())
140
 
                            System.out.println("Unknown signal " + s + " in cell " + parent.describe(false));
141
 
                        PrimitiveNode primitive = (port.isBus) ? Schematics.tech().busPinNode : Schematics.tech().wirePinNode;
142
 
                        pin = NodeInst.newInstance(primitive, getNextLocation(parent),
143
 
                                primitiveWidth, primitiveHeight,
144
 
//                                        primitive.getDefWidth(), primitive.getDefHeight(),
145
 
                                parent, Orientation.IDENT, null/*s*/, 0);
146
 
                        pinsMap.put(s, pin);
147
 
                    }
148
 
                }
149
 
 
150
 
//                ArcProto node = (port.isBus) ? Schematics.tech.bus_arc : Schematics.tech.wire_arc;
151
 
                ArcProto node = (pin.getProto() == Schematics.tech().busPinNode) ? Schematics.tech().bus_arc : Schematics.tech().wire_arc;
152
 
                PortInst ex = cellInst.findPortInst(port.ex.getName());
153
 
                ArcInst ai = ArcInst.makeInstanceBase(node, 0.0,
154
 
//                ArcInst ai = ArcInst.makeInstanceFull(node, 0.0 /*node.getDefaultLambdaFullWidth()*/,
155
 
                        pin.getOnlyPortInst(), ex, null, null, s);
156
 
                assert(ai != null);
157
 
                ai.setFixedAngle(false);
158
 
            }
159
 
        }
160
 
    }
 
89
//    private void createInstance(Cell parent, VerilogData verilogData,
 
90
//                                VerilogData.VerilogModule module, Cell icon, CellInstance info)
 
91
//    {
 
92
//        NodeInst cellInst = NodeInst.newInstance(icon, getNextLocation(parent), 10, 10, parent,
 
93
//                        Orientation.IDENT, info.name, 0);
 
94
//
 
95
//        List<String> localPorts = new ArrayList<String>();
 
96
//
 
97
//        for (CellInstance.PortInfo port : info.list)
 
98
//        {
 
99
//            localPorts.clear();
 
100
//
 
101
//            String portLocal = port.local;
 
102
//
 
103
//            // It is unknown how many pins are coming in the stream
 
104
//            if (portLocal.contains("{"))
 
105
//            {
 
106
//                StringTokenizer parse = new StringTokenizer(portLocal, "{,}", false); // extracting pins
 
107
//                while (parse.hasMoreTokens())
 
108
//                {
 
109
//                    String name = parse.nextToken();
 
110
//                    name = name.replaceAll(" ", "");
 
111
//                    localPorts.add(name);
 
112
//                }
 
113
//            }
 
114
//            else
 
115
//                localPorts.add(portLocal);
 
116
//
 
117
//            for (String s : localPorts)
 
118
//            {
 
119
//                NodeInst pin = pinsMap.get(s);
 
120
//
 
121
//                if (pin == null)
 
122
//                {
 
123
//                    int index = s.indexOf("[");
 
124
//                    if (index != -1)
 
125
//                    {
 
126
//                        s = s.substring(0, index);
 
127
//                        pin = pinsMap.get(s);
 
128
//                    }
 
129
//                }
 
130
//
 
131
//                if (pin == null)
 
132
//                {
 
133
//                    if (s.equals("vss")) // ground
 
134
//                    {
 
135
//                        pin = readSupply(module, false, s);
 
136
//                    }
 
137
//                    else
 
138
//                    {
 
139
//                        if (Job.getDebug())
 
140
//                            System.out.println("Unknown signal " + s + " in cell " + parent.describe(false));
 
141
//                        PrimitiveNode primitive = (port.isBus) ? Schematics.tech().busPinNode : Schematics.tech().wirePinNode;
 
142
//                        pin = NodeInst.newInstance(primitive, getNextLocation(parent),
 
143
//                                primitiveWidth, primitiveHeight,
 
144
////                                        primitive.getDefWidth(), primitive.getDefHeight(),
 
145
//                                parent, Orientation.IDENT, null/*s*/, 0);
 
146
//                        pinsMap.put(s, pin);
 
147
//                    }
 
148
//                }
 
149
//
 
150
////                ArcProto node = (port.isBus) ? Schematics.tech.bus_arc : Schematics.tech.wire_arc;
 
151
//                ArcProto node = (pin.getProto() == Schematics.tech().busPinNode) ? Schematics.tech().bus_arc : Schematics.tech().wire_arc;
 
152
//                PortInst ex = cellInst.findPortInst(port.ex.getName());
 
153
//                ArcInst ai = ArcInst.makeInstanceBase(node, 0.0,
 
154
////                ArcInst ai = ArcInst.makeInstanceFull(node, 0.0 /*node.getDefaultLambdaFullWidth()*/,
 
155
//                        pin.getOnlyPortInst(), ex, null, null, s);
 
156
//                assert(ai != null);
 
157
//                ai.setFixedAngle(false);
 
158
//            }
 
159
//        }
 
160
//    }
161
161
 
162
162
    private NodeInst readSupply(VerilogData.VerilogModule module, boolean power, String name)
163
163
    {
167
167
    }
168
168
 
169
169
    private CellInstance readInstance(VerilogData.VerilogModule module,
170
 
                                      VerilogData.VerilogModule element,
171
 
                                      boolean noMoreInfo) throws IOException
 
170
                                      VerilogData.VerilogModule element) throws IOException
172
171
    {
173
172
        StringBuffer signature = new StringBuffer();
174
173
        List<String> exports = new ArrayList<String>();
186
185
            {
187
186
                String line = signature.toString();
188
187
                int index = line.indexOf("("); // searching for first (
189
 
                if (index <= 0)
 
188
                String instanceName = element.getName() + "-instance";
 
189
 
 
190
                // if index==0, no name provided -> name is null
 
191
                assert(index > -1); // do we have cases with -1?
 
192
                if (index > 0)
190
193
                {
191
 
                    System.out.println("It can't parse line '" + line + "'. Data ignored.");
192
 
                    return null;
 
194
                    instanceName = line.substring(0, index);
193
195
                }
194
 
//                assert(index > 0);
195
 
                String instanceName = line.substring(0, index);
196
196
                line = line.substring(index+1, line.length());
197
197
                StringTokenizer parse = new StringTokenizer(line, ")", false);  //typicalSkipStrings can't be used
198
198
                exports.clear(); pins.clear();
503
503
            }
504
504
 
505
505
            // reading cell instances
506
 
            VerilogData.VerilogModule element = null;
507
 
            Cell schematics = null;
508
 
            boolean noMoreInfo = false;
 
506
            VerilogData.VerilogModule element = verilogData.getModule(key);
509
507
 
510
 
            element = verilogData.getModule(key);
511
508
            if (element == null) // it hasn't been created
512
509
            {
513
510
                element = verilogData.addModule(key, false); // assuming latches and other elements are treat as subcells
514
511
            }
515
512
 
516
 
            CellInstance info = readInstance(module, element, noMoreInfo);
 
513
            CellInstance info = readInstance(module, element);
517
514
        }
518
515
        // not reaching this point.
519
516
    }
628
625
        initKeywordParsing();
629
626
        boolean fullOyster = true;
630
627
        VerilogData verilogData = parseVerilogInternal(lib.getName(), fullOyster);
631
 
        buildCells(verilogData, lib, fullOyster);
632
 
        return lib;
 
628
        Cell topCell = buildCells(verilogData, lib, fullOyster);
 
629
        return (topCell != null) ? lib : null;
633
630
    }
634
631
 
635
632
    public VerilogData parseVerilog(String[] lines, String verilogName)
815
812
                        cell, Orientation.IDENT, pinName, 0);
816
813
                if (addExport)
817
814
                {
818
 
                    Export ex = Export.newInstance(cell, ni.getOnlyPortInst(), pinName);
819
 
                    ex.setCharacteristic(portType);
 
815
                    Export ex = Export.newInstance(cell, ni.getOnlyPortInst(), pinName, portType);
820
816
                }
821
817
            }
822
818
            else
907
903
//                ArcInst.makeInstanceFull(Schematics.tech.wire_arc, 0.0 /*Schematics.tech.wire_arc.getDefaultLambdaFullWidth()*/,
908
904
                    ni.getOnlyPortInst(), supply.getOnlyPortInst(), null, null, name);
909
905
 
910
 
                Export ex = Export.newInstance(cell, ni.getOnlyPortInst(), name);
911
 
                ex.setCharacteristic(portType);
 
906
                Export ex = Export.newInstance(cell, ni.getOnlyPortInst(), name, portType);
912
907
            }
913
908
            else
914
909
                System.out.println("Skipping this characteristic?");