| JHDL Doc Home Page | User's
Manual Home Page |
First, we discuss how to declare your own clocks for multi-clock design. Next, we tell you how to do your own pad insertion using Logic calls or direct instantiation. Finally, we outline what automated facilities JHDL has to help you in the insertion of pads.
Consider the following multi-clock design:
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;
import byucc.jhdl.Xilinx.Virtex.*;
public class flipflops extends Logic {
public static CellInterface[] cell_interface = {
in ("clkIn", 1), in ("clk2In", 1),
in ("a", 1),
out ("q", 1), out ("q2", 1),
};
public flipflops(Node parent, Wire clkIn, Wire clk2In,
wire a, Wire q, Wire q2) {
super(parent);
connect("clkIn", clkIn); connect("clk2In", clk2In);
connect("a", a);
connect("q", q); connect("q2", q2);
Wire clk = clockDriver(clkIn, "0001", "clk");
// Build this clockDriver with a DLL!
String[] mods = {"DLL"};
Wire clk2 = clockDriver(clk2In, "0101", "clk2", mods);
// Build a flip flop clocked by "clk"
setDefaultClock(clk);
reg_o(a, q);
// Build a flip flop clocked by "clk2" - explicitly specify clock
reg_o(clk2, a, q2);
}
}
The red text shows two clocks being defined and two registers being created
- one is clocked by each clock. The 2nd parameter to the clockDriver()
calls tell how the two clocks are related - "clk2" runs twice as fast as
"clk". It is an error to declare two clocks whose schedules are different
lengths - 4 phases in this case. Also, the first clock driver is instantiated
with a DLL - a Virtex-specific feature.
The setDefaultClock() method deserves further discussion. Consider the following code fragment:
Wire clk = clockDriver(clkIn, "0001", "clk"); Wire clk2 = clockDriver(clk2In, "0101", "clk2"); setDefaultClock(clk); new myreg(this, a, q); setDefaultClock(clk2); new myreg(this, a, q2);Although neither clock wire is passed into either of the myreg() constructors, the first myreg will receive "clk" as in implicit port and the second will receive "clk2". However, if each myreg() call needed to build some of its circuitry using "clk" and some using "clk2" then both would have had to be passed in as parameters to those calls. It should be obvious that the use of setDefaultClock() can eliminate much typing for you.
NOTE: in the design above "clkIn" is shown as the input to the clockDriver() call. It should be noted that in simulation "clkIn" will never change - the clockDriver() call sets up the simulator to use the phase pattern specified to drive the "clk" signal with alternating 1's and 0's (in this case). Thus, watching "clkIn" in the waveform viewer will not show any signal transitions. However, in real life, the clock will enter this module on "clkIn".
The rest of the JHDL tool suite handles multiple clocks correctly. Jab has options for both Step and Cycle and all viewers are updated every phase. If you do determine to use multiple clocks and you have written testbench code which counts clock cycles, you will need to modify that code since it will now get called every phase.
The first step is to tell JHDL you are going to do your own pads insertion:
VirtexTechMapper tm = new VirtexTechMapper( true ); Logic.setDefaultTechMapper( tm ); ...The line in red is what you add to a normal testbench to prevent pad insertion from automatically being done.... tm.setInsertPads(false); tm.netlist( my_cell, "my_cell.edn" );
It should be clear that since pads and buffers are primitive cells in every FPGA library that they could be instanced as primitive objects in a design like this:
new ibuf(this, padWire, cktWire, "myibuf");However, the Logic class in JHDL provides convenience functions to aid in the insertion of pads and drivers. In particular, Logic calls are technology independent and hide much of the detail from the user. Logic includes the following calls:
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;
public class cntWithPads extends Logic {
public static CellInterface[] cell_interface = {
in ( "clkPad", 1 ),
in ( "clrPad", 1 ),
out ( "qPad", 4 ),
};
Wire clkPad, clrPad, qPad;
public cntWithPads(Node parent,
Wire clkPad,
Wire clrPad,
Wire qPad,
String instanceName) {
super(parent, instanceName);
connect("clkPad", clkPad);
connect("clrPad", clrPad);
connect("qPad", qPad);
// Insert clock pad and buffer, return clock to use on "clk" signal.
Wire clk = padClock(clkPad, null, "clk");
// Input pad and wire for clr signal - unregistered
Wire clr = padIn(clrPad, false, null, "clr");
// Output pad for q signal - unregistered but FAST
String[] mods = {"FAST"};
Wire q = padOut(qPad, false, mods, "q");
// Instance actual counter
new cnt(this, clk, clr, q);
}
}
This design is simply a wrapper to insert pads and then instance a basic
4-bit counter. This is a recommended approach: use a separate layer of
hierarchy to wrap your design and put all pads in that layer of hierarchy.
Some more items to note:
The netlisting behavior described above is limited --- if your design contains tri-state outputs or bidirectional pins the above default JHDL mechanisms will be insufficient.
One strategy would then be to do all of your pad insertion manually by instructing JHDL to not insert pads using:
tm.setInsertPads(false);in your testbench code.
Another strategy would be to let JHDL do what it can and then do the rest manually. For example, by marking all ports you do not wish JHDL to netlist as inout ports you can force JHDL to leave them alone and you can handle them as you desire (using the methods described previously).
Wire CLK = getGlobalClock(getSystem()); Wire CLKPAD = wire(1, "CLK_IPAD_IN"); padClock_o(CLKPAD, CLK, null);
tm.netlist( my_chip, "chip.edn" );However, there are a collection of options that can be set to get the behavior your want. Here they are:
tm.setInsertPads(boolean flg); -- default is trueThis allows you to control whether JHDL will automatically insert pads on your top level ports. There are 2 cases where you would set this to false. First, you may want to insert the pads yourself. Second, you may want to generate a black box netlist of your design. That is, you don't want any pads on the design since you are going to take the netlist that JHDL generates and use it in another CAD tool as a black box.
The second flag is:
tm.setInsertTopLevelPorts(boolean flg); -- default is falseThis allows you to control whether a port interface is emitted for your top level design. Usually (when generating EDIF for a whole chip) you want the default of false. However, you would want to set this to true for generating a black box netlist.
To summarize, here is a discussion of the four possible uses of these two flags:
| 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