AHDL: Tri-State Buses Connected to a Bidirectional Bus
This example implements an 8-bit bus that feeds and receives
feedback from bidirectional pins. The example contains 8 D-type flipflops, or DFFs,
(named a[7..0]), which store the
values of the inputs. The DFFs named b[7..0] store the data
from the feedback line.
This example can be implemented in two ways, both of which are shown below.
In the first method, the tri-state buses are declared in the VARIABLE section; the second method uses in-line references to create the tri-state buses.
For more information on using this example in your project, go to:
Method 1: tri_bb.tdf
-- This method declares the tri-state buses
-- in the VARIABLE section.
SUBDESIGN tri_bb
(
inp[7..0], oe, clk : INPUT;
outp[7..0] : OUTPUT;
bidirp[7..0] : BIDIR;
)
VARIABLE
my_tri[7..0] : TRI;
a[7..0], b[7..0] : DFF;
BEGIN
-- Connect the a[7..0] flipflops
a[].clk = clk;
a[].d = inp[];
my_tri[].in = a[].q;
-- Connect the b[7..0] flipflops
b[].clk = clk;
b[].d = bidirp[];
outp[] = b[].q;
-- Connect the tri-state buffers
my_tri[].oe = oe;
bidirp[] = my_tri[].out;
END;
Method 2: tri_bb.tdf
-- This method uses in-line references to create
-- tri-state buses.
SUBDESIGN tri_bb
(
inp[7..0], oe, clk : INPUT;
outp[7..0] : OUTPUT;
bidirp[7..0] : BIDIR;
)
VARIABLE
a[7..0], b[7..0] : DFF;
BEGIN
a[7..0].clk = clk;
b[7..0].clk = clk;
a[7..0].d = inp[7..0];
b[7..0].d = bidirp[7..0];
bidirp[0] = TRI(a[0].q, oe);
bidirp[1] = TRI(a[1].q, oe);
bidirp[2] = TRI(a[2].q, oe);
bidirp[3] = TRI(a[3].q, oe);
bidirp[4] = TRI(a[4].q, oe);
bidirp[5] = TRI(a[5].q, oe);
bidirp[6] = TRI(a[6].q, oe);
bidirp[7] = TRI(a[7].q, oe);
outp[7..0] = b[7..0].q;
END;
Feedback
Did this information help you?
If not, please log onto mySupport to file a technical request or enhancement.
Altera does not warrant that this solution will work for the customer's intended purpose and disclaims all liability for use of or reliance on the solution.
|