![]() |
|
|
import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; import byucc.jhdl.Xilinx.Virtex.*; public class mux extends Logic { public static CellInterface[] cell_interface = { in("a", 1), in("b", 1), in("sel", 1), out("q", 1), }; public mux(Node parent, Wire a, Wire b, Wire sel, Wire q) { super(parent); connect("a", a); connect("b", b); connect("sel", sel); connect("q", q); // Declare and construct local wires Wire a1 = new Xwire(this, 1, "a1"); Wire a2 = new Xwire(this, 1, "a2"); Wire selbar = new Xwire(this, 1, "selbar"); // Invert signal "sel" new inv(this, sel, selbar); // Form AND gates new and2(this, a, selbar, a1); new and2(this, b, sel, a2); // Form OR gate new or2(this, a1, a2, q); } }
import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; import byucc.jhdl.Xilinx.Virtex.*;To access a technology library you must first import it. The above lines import the Virtex-specific library of primitives in addition to the regular libraries which are always imported.
To find what libraries are available for importing, go to the JHDL API page, and search through the Packages section of the API documentation. For example, in there you will find a package called byucc.jhdl.Xilinx.Virtex. That contains the Virtex primitives. Clicking on that package reveals a collection of classes in that package. Each such class represents a primitive. The class clkdll is an example. Clicking on it gives a description of the primitive and shows how to call its constructor(s). Note that Xwire, the wire object used in the previous sections is also a class in this library.
To be technical about it, if you are going to do design using only library primitives there is no need to import the Logic package (the 2nd line in the code above). However, if you don't do that, your class will then need to extend something other than Logic (like Structural). However, there is really no advantage to doing this. Thus, in our example above, we import the Logic package and have our class extend the Logic class.
Wire a1 = new Xwire(this, 1, "a1"); Wire a2 = new Xwire(this, 1, "a2"); Wire selbar = new Xwire(this, 1, "selbar");
Every object in JHDL needs to be linked into the JHDL internal circuit data structure through its parent. Thus, the first parameter in the above calls is this. What this means is that the parent cell for the wires constructed is this, or the cell currently being constructed.
The next step is to instance each gate in the circuit, passing in as parameters the wires to connect to it.:
new inv(this, sel, selbar); new and2(this, a, selbar, a1); new and2(this, b, sel, a2); new or2(this, a1, a2, q);
As before, this is the parent cell for these gates. That is, hierarchically, they are children of the cell currently being constructed.
There are a number of ramifications of JHDL circuits just being Java classes. First, as seen above, instancing a JHDL circuit is just creating an instance of a Java object. Thus, as long as the file mux.java is on your Java CLASSPATH, when you instance it with the new keyword Java will find it. Usually "." is in your CLASSPATH and so if the file is in the current directory Java will find it. More expert users often create other locations to hold their building blocks and place that directory on their CLASSPATH. See standard Java documentation for more information on the CLASSPATH, JAR files, packages, and the like.
Read up on this next in Level 2 - The Logic Package.
| JHDL Home Page | Configurable Computing Lab | Prev (Logic Descriptions) | Next (Logic Package) | |
JHDL 0.3.45
Copyright (c) 1998-2003 Brigham Young University. All rights reserved.
Last updated on 11 May 2006