JHDL 0.2
| JHDL Doc Home Page | User's Manual Home Page | << | < | > | >>
ith bit of the wire
name parameter as the name of the new Wire
object.
parent as the parent of the new Wire
object.
name parameter as the
name of the Wire.
To merge wires together into a bus, you can use the concat() method of the Logic class. This method takes a list of 2 to 16 input wires, each of arbitrary width, and concatenates them into a single bus. The first parameter occupies the most significant position in the bus, and the last parameter occupies the least significant position. All of the wire slicing and dicing methods are exemplified below:
Wire a = wire(8), b = wire(8), c = wire(8), d = wire(8);
Wire t;
t = a.getWire(3); // t = a[3]
t = b.gw(5); // t = b[5]
t = c.range(6, 4); // t = c[6:4]
t = concat(a, b, c); // t = { a[7:0]; b[7:0]; c[7:0] }
// t.getWire(23) = a[7]
// t.getWire(0) = c[0]
t = concat(a.range(5,3), b.getWire(6), c.range(2, 2));
// t = { a[5:3]; b[6]; c[2] }
int i = t.getWidth(); // i = 5
While the concat method is a member of the Logic class, you can
still perform concatenation outside of the Logic class using the
static versions of the methods. These version require you to pass in
a Node as the parent of the new wire:
Wire myBus = Logic.concat(this, wire1, wire2, wire3);
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, in most cases,
could share the cell-name "FullAdder" or something. 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, anytime your JHDL circuit is parameterized a static
cell-name String will not do. Take for our 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-naming 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.
| JHDL Doc Home Page | User's Manual Home Page | << | < | > | >>
Copyright (c) 1998-1999 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.