Mux from nand

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Mux from nand

Bruno
Hi all,

In project 1 I tried to make a mux from nand chips. I made all the previous chips by making a diagram of the chip layout and then coding it into HDL. However, with the mux chip this did'nt work out for me as my mind couldn't make up a right way to implement the selector. This is why i re-read the part about canonical representations, and I made a canonical representation of the mux using a truth table, and then I used that to code the chip.

My question to you guys is: Is it ok to use a conanical representation for making a chip, or is there an easier and faster way?

My code is as follows:

----------------------------

CHIP Mux {

    IN  a, b, sel;
    OUT out;

    PARTS:
    Not(in = a, out = nota);
    Not(in = b, out = notb);
    Not(in = sel, out = notsel);

    //!a, b, sel
    And(a = nota, b = b, out = a1);
    And(a = nota, b = sel, out = a2);
    And(a = a1, b = a2, out = w1);

    //a, !b, !sel
    And(a = a, b = notb, out = b1);
    And(a = a, b = notsel, out = b2);
    And(a = b1, b = b2, out = w2);

    //a, b, !sel
    And(a = a, b = b, out = c1);
    And(a = a, b = notsel, out = c2);
    And(a = c1, b = c2, out = w3);

    //a, b, sel
    And(a = a, b = b, out = d1);
    And(a = a, b = sel, out = d2);
    And(a = d1, b = d2, out = w4);

    Or(a = w1, b = w2, out = f1);
    Or(a = w3, b = w4, out = f2);
    Or(a = f1, b = f2, out = out);

}

-------------------------------------

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

ybakos
Your thought process and path to a solution is great. Another approach is to use a Karnaugh Map, but that takes a little more study and investigation.

Remember, we don't really care about the implementation details as long as the implementation meets the specification. However, you should also know that the circuit can be simplified, and that the methodical approach to this would be to refactor / reduce the initial canonical expression.




Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Bruno
Thanks for your quick respond, it's good to know that my mux gate is right. I'll look into Karnaugh maps now, because from what I've seen of it it looks to be useful. I don't think refactoring or reducing the cannonical expression was ever mentioned in the book? I'd be thankful if you could maybe give an example.

It seems like the subject is not being talked about much on the internet, because googling 'nand to mux' and search terms like that don't give any useful results.

I'd also like to ask one more thing: Is it possible to make every chip from project 1, using just the cannonical expression method?

Again, thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Bruno
BTW: It's not possible to use an if statement inside hdl, right? If statements would of course make it very easy to build a mux. In that case you are not really using only nand gates anymore, so I'm not sure whether this is possible.
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

ybakos
In reply to this post by Bruno
The idea to grasp is that a chip's logic can be represented as a boolean expression, and that many non-trivial boolean expressions can be simplified (just like in traditional algebra). Hence, to simplify a logic circuit, reduce its representative boolean expression.
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Bruno
I studies Karnaugh maps now, using the excersises on this website. I think this will really help me, so thanks for the tip.
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Bruno
This post was updated on .
I registered to the forums, so I can edit my posts now which will be pretty convenient. Also, thanks to your tip i simplified my cannonical representation to !s.a + s.b, which results in the following code:

------------------------
CHIP Mux {

    IN  a, b, sel;
    OUT out;

    PARTS:
    [Working HDL code removed by admin.]
}
------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Rineez
I got a Mux by combining a Not and three Nand chips. But not sure that's best way to go.
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Sapientia
In reply to this post by ybakos
I just want to reiterate to any beginners how useful the Karnaugh Map can be for simplifying more complex chip functions. I spent about two hours trying and failing to come up with a design by working backward from the inputs or forward from the outputs. After I comprehended the Karnaugh Map process, it took me about 90 seconds to come up with an efficient chip design.

The Wikipedia page is coated with jargon (as Wikipedia pages tend to be with specialized subjects) and somewhat unhelpful visualizations, but if you read through it closely and try to understand it step-by-step, you'll gain a valuable tool for simplifying Boolean functions.
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Jane W
This post was updated on .
In reply to this post by Bruno
i have a easier way to build Mux. i have tested it,and result is right, code is followed
CHIP WJMutiplexor
{
  IN a,b,sel;
  OUT out;
  PARTS:
  [Working HDL code removed by admin.] 
}
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

cadet1620
Administrator
Jane W wrote
i have a easier way to build Mux. i have tested it,and result is right, code is followed
...
Your code is the simplified canonical representation talked about in this thread.

Please note that it is against board policy to post working code; we want students to develop their own solutions.
Please edit your post to remove the working code.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Mux from nand

Jane W
sorry,i will not  do that.