JHDL 0.3.39

| JHDL Doc Home Page | User's Manual Home Page |


Advanced Topics

Cell naming

Generally there are two names associated with any cell: its instance-name, which is an identifier to uniquely identify the cell; and its cell-name which identifies the type of cell. Say that we instance two FullAdder objects; each instance must have a unique instance-name (which is arbitrary -- "Fred" or "adder_5" or "Barney"), but all instances will have the same cell-name that tells "what kind of cell it is", maybe "FullAdder". This cell-name is used in the netlist to set the component name of hierarchical cells.

The user can set the instance-name and the cell-name in his JHDL class as follows. The instance name is set by passing the name string to the super-constructor of the core JHDL Cell classes. The cell-name is usually set by the static final String field cellname. Since this is a static variable, this field will make the cell-name the same for all instances of a class. In most cases, this is exactly what we want -- all instances of the class FullAdder, for instance, could share the cell-name "FullAdder". Valid JHDL cell-names can only include alpha-numeric characters and single underscores (double underscores are reserved for the netlister). Below is shown how the FullAdder class could set both the instance-name and the cell-name:

   // The existence of this field sets the cellname for all FullAdder
   // objects.
   public static final String cellname = "FullAdder";
   public FullAdder(Node parent, Wire a, Wire b, Wire ci, Wire sum,
                    Wire co, String instance_name) {
     // Passing a String to the super-constructor sets the instance-
     // name of the cell.
     super(parent, instance_name);
     ...
   }
However, any time your JHDL circuit is parameterized, a static cell-name String will not do. Take, for example, our NBitAdder class. In this case it would be inappropriate to give all instances a static cell-name -- an 8-bit adder is structurally different than a 4-bit adder. Having the same cell-name will cause errors in the netlist since the netlister will say that the one is an identical instance of the other. In this case we need to override the static cellname field based on the parameters used to create the circuit. We do this with the getCellName() method. So we might set the cell-name of our NBitAdder as follows:
   public String getCellName() { return "Adder" + width; }
   int width;
   public NBitAdder(Node parent, Wire a, Wire b, Wire sum) {
     super(parent);
     width = a.getWidth();

Thus as a general rule, the cell-name can be a static String for classes which always generate the same structure. If your circuit is parameterized, you need to incorporate those parameters into the generation of a unique cell-name. Note that those who use the XC4000TechMapper get some built-in checking of cell-naming errors at netlist-time. Creating Wires


| JHDL Doc Home Page | User's Manual Home Page |

Copyright (c) 1998-2003 Brigham Young University. All rights reserved.
Reproduction in whole or in part in any form or medium without express permission of Brigham Young University is prohibited.

Documentation Revision: 19 Mar, 2001