Does anybody have good idea to make the chip 'Bit' clearly?

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

Does anybody have good idea to make the chip 'Bit' clearly?

hyeonwoo
       I wrote first below code, so the error has occurred.
(The ERROR 'The chip has a circle in its parts connection' )

PARTS:
    Mux(a=thrh, b=in, sel=load, out=thrh);

    DFF(in=thrh, out=out);



I changed the code like this.

PARTS:
    Mux(a=out1, b=in, sel=load, out=thrh);

    DFF(in=thrh, out=out1);
    Or(a=out1, b=out1, out=out);


Second code works well.

But, I think second code is wasteful.(Should I do use chip like 'Or' or 'And'?)
I want to know better idea to make it clearly.
Reply | Threaded
Open this post in threaded view
|

Re: Does anybody have good idea to make the chip 'Bit' clearly?

cadet1620
Administrator
The "circle in its parts" message is because this Mux has its output hooked to one of its inputs.
    Mux(a=thrh, b=in, sel=load, out=thrh);
You don't need to use an extra gate to duplicate the DFF's output.  Just like with physical hardware, you can hook more than one wire to a pin.
    DFF(..., out=out, out=out1);
--Mark
Reply | Threaded
Open this post in threaded view
|

Do you have any idea to make false and true?

hyeonwoo
Thanks for your good advice.

Than, do you have any idea to make false and true?

I write code like below, when make false and true.

True:
Not(in=a, out=Na);
Or(a=a, b=Na, out=Res);
 //'Res' means result which has true value.

False:
Not(in=a, out=Na);
And(a=a, b=Na, out=Res);
//'Res' means result which has false value.
Reply | Threaded
Open this post in threaded view
|

Re: Do you have any idea to make false and true?

cadet1620
Administrator
true and false are built in constants. See Appendix A.5.2. Input Pins.

true and false also automatically expand to match input bus width, which is really useful. See Appendix A.5.3 Buses.

Here's a handy chip that converts a single-bit wire to a 16-bit bus (all 16 output bits will have the same value as in) that uses true and false with buses.
/**
 * Bus16: expand 1-bit 'in' to 16-bit 'out'.
 */
CHIP Bus16 {
    IN  in;
    OUT out[16];
PARTS:
    Mux16(a=false, b=true, sel=in, out=out);
}

--Mark