|   JHDL Home Page   |   Configurable Computing Lab   |   User's Manual (TOC)   | Search

Level 3 - The Logic.Modules Package

A module is a pre-built, parameterizable JHDL design component, i.e a multiplier or counter. Level 3 then, build on the theory of Level 2 -- technology independent circuit elements, by adding more predefined circuit building blocks.

Pros: portable
Cons: may not take advantage of manufacturer specific features


The Logic.Modules package layers on top of Logic by providing more predefined circuit building blocks for users to incorporate into their designs. These consist of larger building blocks than are found in Logic. Examples include counters, delay lines, multipliers, and floating point units. In addition, Logic.Modules circuits are often parameterized for speed, pipelining, number format, etc.

Like Logic, Logic.Modules provides for the creation of technology-independent designs - they will work for any technology supported by JHDL. Logic.Modules does its work by simply calling appropriate combinations of Logic routines such as the add() routine in the example in the previous section. This has the advantage that designs done using only Logic and Logic.Modules are portable to any technology JHDL supports. The disadvantage of this is that Logic.Modules calls cannot take advantage of technology-specific FPGA features. Users will have to weigh the convenience of using a generic module from Logic.Modules against the speed/area penalty it may have over a technology-optmized version of the same function and the work associated with creating such a technology-optimized module.

Importing the Logic.Modules Package

The Logic.Modules package is imported like any other package:
     import byucc.jhdl.Logic.Modules.*;

Circuit Modules in the Logic.Modules Package

If you examine the API documentation for this package you will note that it contains a number of classes, divided into two groups. The first group consists of parameterized JHDL designs. An example is the up counter module with the following constructor declaration:
      public upcnt(Node parent,
	           Wire clr,
	           Wire inc,
	           Wire ld,
	           Wire ldval,
	           Wire q,
	           String instanceName) {

and can be directly instantiated using the new keyword like any other design. If you read the Logic.Modules package documentation you will see that this one constructor can create any one of 8 different counters (clearable, incrementable, loadable - there are 8 combinations of these features). To signify that you don't want the counter to have a clear function, you simply pass a null into the constructor in place of the clr wire. The constructor tests the parameters against null and thus can tell what kind of counter to generate.

The second second kind of class in Logic.Modules will have a name that is all uppercase such as COUNTERS. This is a class that contains only static methods for instancing various building blocks. Thus, instead of directly instantiating an upcnt object from above, you can call methods from COUNTERS to do that for you like this:

     // Create an upcounter that is clearable and incrementable
     COUNTERS.Clr_UpCnt(this, clrSignal, incSignal, q);

    // Create an upcounter that is clearable and loadable (always
    // incrementing if not clearing or loading)
    COUNTERS.ClrLd_UpCnt(this, clrSignal, ldSignal, ldValue, q);

    // Create an upcounter that is clearable, incrementable, and loadable
    COUNTERS.ClrIncLd_UpCnt(this, clrSignal, incSignal, ldSignal, ldValue, q);

Note that since these are static methods, they must be prefixed by the name of the class they are from (COUNTERS) and this must be passed as the parent node.

In the case of the up counter, there are at least eight such methods, each with a different name and slightly different set of parameters. Each such method simply instances an upcnt module by calling its constructor with null values for the appropriate parameters.

The Classes in Logic.Modules

To determine the set of objects such as upcnt which can be instantiated from the Logic.Modules package, consult the Logic.Modules documentation from the API docs. They will have names in all lower case letters.

In addition to the COUNTERS class introduced above, there are a number of others as well. Each contains only static methods suitable for instancing various circuit modules contained in Logic.Modules. Consult the Logic.Modules API documentation for details on how to call the methods in these classes. To date, the following classes of static methods are available:

The COMPARATORS class contains methods to call gt, lt, and eq modules. The gt and lt modules may be signed or not.
As mentioned above, COUNTERS contain methods for upcnt, as well as a downcnt. Both counters may be clearable, incrementable, or loadable, or any combination of the three.
Currently, DIVIDERS only provides methods for IntDivide.
MULTIPLIERS contains methods for arrayMult, which can be signed, pipelined, etc... and booth, a signed multiplier using Booth's algorithm.
OTHERS provide methods for the modules that don't fit in the above classes. Currently, this includes accum, delay, and rounder.

Finally, a sub-packages of Logic.Modules has been created, and it is anticipated that others may be in the future. The documentation will reflect that if it occurs. Currently, there is is a Logic.Modules.FloatingPoint package for all floating point modules. Consult the API documentation for details.

Don't reinvent the wheel! The chances are that some of the modules you need have already been designed and are in the Logic.Modules package. Be sure to consult its API documentation to see what is available in the package and take full advantage of it.

Where To Go Next?

The fact that the Logic.Modules classes are technology-independent has advantages and disadvantages. The main advantage is that they will work with any FPGA technology that JHDL supports (that is any technology for which JHDL has a TechMapper). The main disadvantage is that they won't take advantage of technology-specific features.

To alleviate this, a small set of technology-optimized module generators have been created. These include delays, array multipliers, and a few other items and are described in the next section Level 4 - Technology-Specific Module Generators.

|   JHDL Home Page   |   Configurable Computing Lab   |   Prev (Logic Package)   |   Next (Module Generators)   |

JHDL 0.3.45