In this example, four 4-bit-wide buses (a, b, c, and d) are multiplexed. The widths of the four buses are specified with the parameter LPM_WIDTH, the number of buses being multiplexed is specified with LPM_SIZE, and the number of select lines is specified with LPM_WIDTHS. You can change any of these parameters to suit the needs of your design. The ports of the LPM function are defined in a Function Prototype Statement (shown in blue text). An Instance Declaration (shown in red text) implements an instance of the function.
- How to Use AHDL Examples
- Graphic Editor: Parameterized Multiplexer (lpm_mux)
- Implementing Tri-State Buses in Altera Devices
- MAX+PLUS II Help
mux.tdf
FUNCTION lpm_mux (data[LPM_SIZE-1..0][LPM_WIDTH-1..0],
sel[LPM_WIDTHS-1..0])
WITH (LPM_WIDTH, LPM_SIZE, LPM_WIDTHS, CASCADE_CHAIN)
RETURNS (result[LPM_WIDTH-1..0]);
SUBDESIGN mux
(
a[3..0], b[3..0], c[3..0], d[3..0] : INPUT;
select[1..0] : INPUT;
result[3..0] : OUTPUT;
)
BEGIN
result[3..0] = lpm_mux (a[3..0], b[3..0], c[3..0], d[3..0],
select[1..0])
WITH (LPM_WIDTH=4, LPM_SIZE=4, LPM_WIDTHS=2);
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.

