| JHDL Doc Home Page | User's
Manual Home Page |
(interface (port (array (rename a "a[3:0]") 4) (direction INPUT)) (port (array (rename b "b[3:0]") 4) (direction INPUT)) (port (array (rename q "q[3:0]") 4) (direction OUTPUT)) )That is, it contains a 4-bit input named "a", a 4-bit input named "b", and a 4-bit output named "q". Further, assume that the EDIF is for a Xilinx Virtex design.
Here is a JHDL design which will read in the EDIF and treat it like any other JHDL module:
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;
import byucc.jhdl.Xilinx.*;
import byucc.jhdl.Xilinx.Virtex.*;
import byucc.jhdl.parsers.edif.*;
public class add_wrapper extends Logic {
public static CellInterface[] cell_interface = {
in( "a", 4), in( "b", 4), out( "q", 4),
};
Wire a, b, q;
public add_wrapper(Node parent,
Wire a, Wire b, Wire q
) {
super(parent);
this.a = connect( "a", a);
this.b = connect( "b", b);
this.q = connect( "q", q);
PortInterface[] portWires = {
PortInterface.addPort("a", a),
PortInterface.addPort("b", b),
PortInterface.addPort("q", q),
};
Cell cel = EdifParser.parse(this, "add.edn", portWires, "Virtex");
} // end constructor
} // end class
The only things of interest to note include the following:
OK, so maybe there is more...
java byucc.jhdl.parsers.edif.BuildWrapper add.ednand it will parse "add.edn" and create the file "add_wrapper.java" shown below which you can use instead of writing your own wrapper by hand:
// Automatically generated EDIF wrapper...
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;
import byucc.jhdl.Xilinx.*;
import byucc.jhdl.Xilinx.Virtex.*;
import byucc.jhdl.parsers.edif.*;
public class add_wrapper extends Logic {
public static CellInterface[] cell_interface = {
in( "a", 4),
in( "b", 4),
out( "q", 4),
};
Wire a;
Wire b;
Wire q;
public add_wrapper(Node parent,
Wire a,
Wire b,
Wire q
) {
super(parent);
this.a = connect( "a", a);
this.b = connect( "b", b);
this.q = connect( "q", q);
// Changes to make below if there is a clock port called "clk" on the imported EDIF and you want
// to wire it to the default global clock:
// PortInterface.addPort("clk", getGlobalClock(getSystem()));
// Alternatively, if your wrapper has a port called "clk" and you want
// to hook it to a clock driver of your own making:
// Put these two lines in:
// Wire myclk = wire(1, "myclk");
// clockDriver("clk", "myclk", "01", "clockDriver");
// Now, change the PortInterface.addPort() below to be:
// PortInterface.addPort("clk", myclk);
PortInterface[] portWires = {
PortInterface.addPort("a", a),
PortInterface.addPort("b", b),
PortInterface.addPort("q", q),
};
Cell cel = EdifParser.parse(this, "add.edn", portWires, "Virtex");
} // end constructor
} // end class
In the following automatically generated wrapper, you will see that the tool saw that the EDIF had a clock port and so created a clock port on the wrapper's interface as well as created a PortInterface entry for it:
...
public class ramtest_wrapper extends Logic {
public static CellInterface[] cell_interface = {
in( "a", 4),
in( "clk", 1),
in( "d", 1),
out( "q", 1),
in( "we", 1),
};
...
// Changes to make below if there is a clock port called "clk" on the imported EDIF and you want
// to wire it to the default global clock:
// PortInterface.addPort("clk", getGlobalClock(getSystem()));
// Alternatively, if your wrapper has a port called "clk" and you want
// to hook it to a clock driver of your own making:
// Put these two lines in:
// Wire myclk = wire(1, "myclk");
// clockDriver("clk", "myclk", "01", "clockDriver");
// Now, change the PortInterface.addPort() below to be:
// PortInterface.addPort("clk", myclk);
PortInterface[] portWires = {
PortInterface.addPort("a", a),
PortInterface.addPort("clk", clk),
PortInterface.addPort("d", d),
PortInterface.addPort("q", q),
PortInterface.addPort("we", we),
};
Cell cel = EdifParser.parse(this, "ramtest.edn", portWires, "Virtex");
} // end constructor
} // end class
However, you will see that it also suggested how you might hook a clock
to that port, depending on what you wanted to do. The first suggestion
simply hooks the clock up to the global default clock. The second lets
you insert a ClockDriver and specify the clock's waveform.
As an alternative to doing this in the wrapper, you could write a testbench to directly import the EDIF. Below is a complete testbench to load the EDIF for a CLB RAM test circuit and read all 16 locations. When executed in JAB, one can see the successive values of the memory coming out on the "q" port.
import byucc.jhdl.Logic.*;
import byucc.jhdl.Xilinx.*;
import byucc.jhdl.base.*;
import byucc.jhdl.Xilinx.Virtex.*;
import byucc.jhdl.parsers.edif.*;
public class tbe_ramtest extends Logic implements TestBench {
public static void main(String argv[]) {
HWSystem hw = new HWSystem();
tbe_ramtest tb = new tbe_ramtest(hw);
hw.cycle(iterations);
}
// Here are the addresses
static final int[] a_data = {
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0,
};
Wire d;
Wire we;
Wire a;
Wire q;
public void reset() {
count = 0;
d.put(this, 0);
we.put(this, 0);
a.put(this, 0);
}
static final int iterations = 20;
int count = 0;
public void clock() {
d.put(this, 0);
we.put(this, 0);
a.put(this, a_data[count%iterations]);
count++;
}
public tbe_ramtest(Node parent) {
super(parent);
VirtexTechMapper tm = new VirtexTechMapper( true );
Logic.setDefaultTechMapper( tm );
d = Logic.wire(this, 1, "d");
we = Logic.wire(this, 1, "we");
a = Logic.wire(this, 4, "a");
q = Logic.wire(this, 1, "q");
PortInterface[] ports = {
PortInterface.addPort("d", d),
PortInterface.addPort("we", we),
PortInterface.addPort("a", a),
PortInterface.addPort("q", q),
PortInterface.addPort("clk", getGlobalClock(getSystem())),
};
Cell my_ramtest = EdifParser.parse(this, "ramtest.edn", ports, "Virtex");
}
}
java byucc.jhdl.parsers.edif.BuildWrapper ramtest_pads.ednThe file "ramtest_pads_wrapper.java" will be created. This design has a clock port on it. There will be a comment in "ramtest_pads_wrapper.java" showing how you might want to modify the design to add a clock driver to the circuit in case it was going to be your top-level design. You should read the comment to understand how to do that.
javac ramtest_pads_wrapper.java java jab ramtest_pads_wrapperThis will:
... modify the wrapper ... javac ramtest_pads_wrapper.java java jab ramtest_pads_wrapperif you used an automatically-generated wrapper you will see that it has many 1-bit ports as in: "a_0_", "a_1_", etc. (this is what happens when pads are thrown away). However, the EDIF parser on import will always merge these into a wide port by looking at the indices. Thus, when you modify the wrapper you will want to replace all these by a single port and wire named "a". Otherwise, you will get an error.
(interface (port in0 (direction INPUT)) (port in1 (direction INPUT)) (port in2 (direction INPUT)) (port in3 (direction INPUT)) (port out0 (direction OUTPUT)) (port out3 (direction OUTPUT)) )the ports in0 - in3 will be reconstructed into a 4 bit port called in. The other 2 ports will attempt to reconstruct a 2 bit port out. However, since the number of ports is less than the greatest port index, the ports will remain single bit ports with their given names. The final reconstructed port interface for this EDIF section is shown in the following JHDL code.
public static CellInterface[] cell_interface{
in( "in", 4 );
out( "out0", 1);
out( "out3", 1);
}
| 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
per