| JHDL Doc Home Page | User's
Manual Home Page |
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();
| 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