Spent almost 40 minutes implementing NOT

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

Spent almost 40 minutes implementing NOT

Sazi
This post was updated on .
(Spoiler alert) It took me less than a minute to know NOT (A) is Nand(A, A). But to implement this I've tried a hundred ways but still no success. I need some help please!!

Edit: I'm using VI as my editor on Mac 10.6.8 and not sure if there's some spacing or formatting issues with Vi.. Although with my AND gate implementation I had no issues using Vi.
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

cadet1620
Administrator
Look at the skeleton for Not.hdl:
CHIP Not {
    IN in;
    OUT out;

    PARTS:
    // Put your code here.
}
and the leftmost column figure 1.6 for an example of HDL syntax.

For each connection in a part, the left side of the "=" is an I/O pin in the part you are using. The right side of the "=" is a pin or wire in the chip you are writing.

Since Nand has inputs "a" and "b" output "out", every Nand part used in a chip will be
    Nand (a=something, b=something, out=something);

For the Not, the only choice for the somethings are either in or out since these are the only declared input and output pins.

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

Re: Spent almost 40 minutes implementing NOT

Sazi
Thanks. Yes I read Appendix A, Ch1, and the useful hints. but your explanation has helped a great deal. The line For each connection in a part, the left side of the "=" is an I/O pin in the part you are using. The right side of the "=" is a pin or wire in the chip you are writing.  should be added to future versions of this book!
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

Sazi
In reply to this post by cadet1620
Logically it was simple to find the answer. But HDL. I forgot that just like a real NOT gate the output must have a value. The output pin of the NOT gate must have a value. In my HDL I hadn't assigned the "out" variable (If I can call it that) a value. So i routed my NAND's output to be the value for my NOT's "out"put and it worked perfectly.
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

ybakos
Don't think of variables. HDL is a representation of hardware -- your "variables" are really wires aka pins.
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

stephan
In reply to this post by cadet1620
Thanks, Mark. So, now I know that when there is a syntax error somewhere, the hdl file does not load.
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

ammarr
In reply to this post by cadet1620
hi

i got the same problem, but after reading posts here and there i got it right

by drawing the truth table and trying to get the results of Not by using a nand gate it worked for me.

but i have one question

if NOT is more primitive , why are we using nand to get the results of NOT, why dont we use NOT as the primitive gate

thanks
Reply | Threaded
Open this post in threaded view
|

Re: Spent almost 40 minutes implementing NOT

cadet1620
Administrator
ammarr wrote
if NOT is more primitive , why are we using nand to get the results of NOT, why dont we use NOT as the primitive gate
The trick is to have a single gate as the primitive gate from which all other logic can be derived. If Not were chosen as that gate, how would you build a multi-input gate?

The Not gate can be thought of as a 1-input Nand or Nor, and in IC internal schematics you often see it drawn using the Nand or Nor symbol with a single input.

Here are Not, Nand and Nand3Way as implemented in CMOS (using Logisim).

CMOS Nand gates

--Mark