Implementing a Comparison Function Using EABs
This example uses two FLEX 10K EABs to implement a comparison function.
The top-level file is named eab_comp.gdf. Two lower-level files named eabcomp.tdf, which were created in the Altera Hardware Description Language (AHDL), perform a comparison on two 5-bit buses. A third lower-level file named final_comp.tdf performs the final comparison. The outputs are 00 if a equals b, 01 if a is greater than b, and 10 is a is less than b.
You must assign a logic option to the two eabcomp.tdf files in order to implement them in the EAB. To implement the assignment:
- Select both
eabcomp symbols in the Graphic Editor and choose Logic Options (Assign menu). The Logic Options dialog box will appear.
- Choose the Individual Logic Options button.
- In the Individual Logic Options dialog box, turn on Implement in EAB.
- Choose OK twice.
Download the Graphic Editor file used in this example:
eab_comp.gdf
eabcomp.tdf
constant AeqB = b"00";
constant AgreB = b"01";
constant BgreA = b"10";
SUBDESIGN eabcomp
(
a[4..0], b[4..0], clock : INPUT;
comp[1..0] : OUTPUT;
)
VARIABLE
a_ff[4..0], b_ff[4..0] : dff; -- Flipflops used for registering
-- inputs and outputs
BEGIN
a_ff[].clk = clock;
b_ff[].clk = clock;
a_ff[].d = a[];
b_ff[].d = b[];
If a_ff[].q == b_ff[].q then
comp[] = AeqB;
elsif a_ff[].q > b_ff[].q then
comp[] = AgreB;
elsif a_ff[].q < b_ff[].q then
comp[] = BgreA;
END IF;
END;
final_comp.tdf
constant AeqB = b"00";
SUBDESIGN final_comp
(
msbits[1..0], lsbits[1..0], clock : INPUT;
comp[1..0] : OUTPUT;
)
VARIABLE
comp[1..0] : dff;
BEGIN
comp[].clk = clock;
If msbits[] == AeqB then
comp[].d = lsbits[];
else
comp[].d = msbits[];
END IF;
END;
For more information on using this example in your project, go to:
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.
|