Solve 8:1 Mux Simulation with C Program

  • Thread starter Thread starter TimFortin
  • Start date Start date
  • Tags Tags
    Simulation
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 replies · 17K views
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.
 
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.