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.
- How to Use AHDL Examples
- Graphic Editor: Tri-State Buses Connected to a Bidirectional Bus
- Implementing Tri-State Buses in Altera Devices
- MAX+PLUS II Help
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;
Design Examples Disclaimer
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.
