1lytics

Designing 4-to-1 Multiplexer using Lua

What is a Multiplexer

In digital electronic a multiplexer (or MUX) is the logic device that selects one of several digital input signals and forwards the selected input into a single line. A multiplexer of 2N inputs has N select lines, which are used to select which input line to send to the output.

4-to-1 multiplexer has 4 input lines, which are forwarded to output line, and 2 select (address) lines, which are used to select which input will be forwarded.

Gorgeous Karnaugh Versions with Lua Support

Note: Not all versions of Gorgeous Karnaugh software supports Lua scripting. Check you version features here.

Writing the Lua Script to Build Truth Table

Because the truth table for 6 input variables contains 64 rows and required too much hand job, we will use the “Lua scripting” feature to define the truth table for 4-to-1 multiplexer. Launch Gorgeous Karnaugh and select “File” — “New” — “Empty set for scripting” menu item.

gkAddInputVar('a', 2)
gkAddInputVar('x', 4)
gkAddFunction('y')
MaxInput = gkGetMaxInputVector()
for InputVec = 0, MaxInput do
    addrBits = gkGetBits( InputVec, 4, 2 )
    if addrBits==0 then
       gkSetFunctionValue(InputVec,'y',gkGetInputValue(InputVec, 'x1'))
    elseif addrBits==1 then
       gkSetFunctionValue(InputVec,'y',gkGetInputValue(InputVec, 'x2'))
    elseif addrBits==2 then
       gkSetFunctionValue(InputVec,'y',gkGetInputValue(InputVec, 'x3'))
    elseif addrBits==3 then
       gkSetFunctionValue(InputVec,'y',gkGetInputValue(InputVec, 'x4'))
    end
end

After script entered, press “Alt-Enter” (or select “Edit” — “Execute Lua script” menu item).

K-Map for Minimization

Lua script, given above, produces next K-Maps for minimization:

Y - Multiplexer output

Minimizing the K-Map

Let minimize the K-Map for Product-of-Sums (by 0):

Minimized for PoS 4-to-1 Multiplexer output - Y K-Map

and get the functions minimal form:

y = (!a1|!a2|x4) (!a1|a2|x3) (a1|!a2|x2) (a1|a2|x1);

Let minimize the K-Map for Sum-of-Products (by 1):

Minimized for SoP 4-to-1 Multiplexer output - Y K-Map

and get the functions minimal form:

y = !a1 !a2 x1 | !a1 a2 x2 | a1 !a2 x3 | a1 a2 x4;

Building the Logic Gate Diagrams

In the “Coverage sets” pane select the needed coverage set. Next, select the “Coverages” — “Open Schematic”. In the appeared dialog window select appropriate diagram generation options, and press “Ok” button. After this, you got the logic gate diagram.

Logic gate diagrams for PoS and SoP:

Logic gate diagram for PoS minimized 4-to-1 Multiplexer Logic gate diagram for SoP minimized 4-to-1 Multiplexer

Checking Logic Gate Diagram in a Simulator

You can use “CEDAR Logic Simulator” program to check how your logic gate diagram works. For this, choose menu item “File” — “Save for CedarLogic” in the Gorgeous Schematic, save the “.CDL” file and open it in the “CEDAR Logic Simulator”.

Note: Not all versions of Gorgeous Karnaugh software supports export logic gate diagrams to CedarLogic. Check you version features here.

Gorgeous Karnaugh Versions

You can learn about Gorgeous Karnaugh features and compare diferences between Gorgeous Karnaugh versions on the Gorgeous Karnaugh features page.