Solve 8:1 Mux Simulation with C Program

  • Thread starter Thread starter TimFortin
  • Start date Start date
  • Tags Tags
    Simulation
AI Thread Summary
The discussion centers on creating a C program to simulate an 8:1 multiplexer using only logical operators (&&, ||, !). The original poster expresses confusion about the necessity of eight source inputs when a boolean expression can yield the correct output based on three control inputs. Responses clarify that the program should define the output based on combinations of the control inputs and corresponding source inputs. Suggestions include using two 4:1 multiplexers and one 2:1 multiplexer for the implementation. Additionally, it is recommended to consider using hardware description languages like Verilog or VHDL for a more suitable approach to hardware design.
TimFortin
Messages
1
Reaction score
0

Homework Statement


Hello all, this is my first post here although I've used this site for referencing several times. My question is regarding an 8:1 multiplexer. I need to write a c program using just &&, || and ! to simulate each gate of an 8:1 mux. We have 3 control inputs and 8 source inputs and need to have just a single output. I don't understand what the need of the 8 source inputs is when you can get the correct output by using a boolean expression on the three control inputs. So to simplify my question, how do i turn the 11 (8 source + 3 control) inputs into 1 output.
Thanks for looking


Homework Equations


ans = (!a && !b) + (!a &&b &&c) + (a && !b && !c);
This produces correct answer but does not use the source inputs at all


The Attempt at a Solution


My attemp at a solution is the equation i posted above, as well as trying to use 2 4:1 muxes and a 2:1 mux but i can't seem to make any sense of it.
 
Physics news on Phys.org
TimFortin said:

Homework Statement


Hello all, this is my first post here although I've used this site for referencing several times. My question is regarding an 8:1 multiplexer. I need to write a c program using just &&, || and ! to simulate each gate of an 8:1 mux. We have 3 control inputs and 8 source inputs and need to have just a single output. I don't understand what the need of the 8 source inputs is when you can get the correct output by using a boolean expression on the three control inputs. So to simplify my question, how do i turn the 11 (8 source + 3 control) inputs into 1 output.
Thanks for looking


Homework Equations


ans = (!a && !b) + (!a &&b &&c) + (a && !b && !c);
This produces correct answer but does not use the source inputs at all


The Attempt at a Solution




My attemp at a solution is the equation i posted above, as well as trying to use 2 4:1 muxes and a 2:1 mux but i can't seem to make any sense of it.

>The first thing I want to ask is that do you know how a multiplexer works?
This is because the code that you have pasted shows that you do not fully understand how a multiplexer works.


>if you use "s0,s1,s2" as the control inputs and "a0,a1,a2,a3,a4,a5,a6,a7" as the input pins while "ans" is ur answer then the C program must assign these inputs and switches to answer in the following manner...


ans=(!s0 && !s1 && !s2 && a0 )||(s0 && !s1 && !s2 && a1 )||(!s0 && s1 && !s2 && a2 )||(s0 && s1 && !s2 && a3 )||.... till all possible values of s0,s1,s2 have been utilized.

>If you are inclined to use two 4:1 muxes and one 2:1 then you can make them the same way the 8:1 mux is made. If you still don't understand then PM me or post here.


>If you are not forced to make this program in C then i would suggest that you program it in HDL(hardware descriptive languages) like Verilog and VHDL which are meant for hardware design and verification and have nearly the same syntax like C.

I hope your problem is solved.
 
Back
Top