Chip has a circle in it's parts? Xor.hdl issues

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

Chip has a circle in it's parts? Xor.hdl issues

Zhme
I am getting an error "This chip has a circle in it's parts connections: load Xor.hdl".

My code:

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    Nand(a=a, b=a, out=outa);
    Nand(a=b, b=b, out=outb);
    Nand(a=a, b=notb, out=outanda);
    Nand(a=nota, b=b, out=outandb);
    Nand(a=outanda, b=outanda, out=nota);
    Nand(a=outandb, b=outandb, out=notb);
    Nand(a=nota, b=notb, out=out);
}

I assumed that, noting the title of the course, we should attempt to write each basic gate from a flow built with nand gates alone.

After seeing this error message I wonder if maybe I just needed to see how the most basic of gates could be built with nand alone, and to use the gates that I've built to slowly build more advanced gates?

I wonder if the reason for my error is that I assigned the initial inputs in more than one location? If so, how would I remedy this error and still use this convoluted approach? Thank you in advance for any support given!
Reply | Threaded
Open this post in threaded view
|

Re: Chip has a circle in it's parts? Xor.hdl issues

ivant
Zhme wrote
I assumed that, noting the title of the course, we should attempt to write each basic gate from a flow built with nand gates alone.

After seeing this error message I wonder if maybe I just needed to see how the most basic of gates could be built with nand alone, and to use the gates that I've built to slowly build more advanced gates?
Yes, you should use the gates you've already build. You can build an XOR gate directly from NANDs, but later gates become too complex for our brains to handle.

Zhme wrote
I wonder if the reason for my error is that I assigned the initial inputs in more than one location? If so, how would I remedy this error and still use this convoluted approach? Thank you in advance for any support given!
You can use the inputs in multiple locations, that is not an issue.

Look at the outputs outa and outb. They are not used anywhere. Are they needed?
Reply | Threaded
Open this post in threaded view
|

Re: Chip has a circle in it's parts? Xor.hdl issues

WBahn
Administrator
In reply to this post by Zhme
Zhme wrote
I am getting an error "This chip has a circle in it's parts connections: load Xor.hdl".

My code:

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    Nand(a=a, b=a, out=outa);
    Nand(a=b, b=b, out=outb);
    Nand(a=a, b=notb, out=outanda);
    Nand(a=nota, b=b, out=outandb);
    Nand(a=outanda, b=outanda, out=nota);
    Nand(a=outandb, b=outandb, out=notb);
    Nand(a=nota, b=notb, out=out);
}

I assumed that, noting the title of the course, we should attempt to write each basic gate from a flow built with nand gates alone.

After seeing this error message I wonder if maybe I just needed to see how the most basic of gates could be built with nand alone, and to use the gates that I've built to slowly build more advanced gates?

I wonder if the reason for my error is that I assigned the initial inputs in more than one location? If so, how would I remedy this error and still use this convoluted approach? Thank you in advance for any support given!
A "circle" means that two signals are dependent on each other. The simulator can't handle that situation.

In other words, Fred depends on Sue and Sue depends on Joe, but if Joe depends on Fred, then there is a circle and Fred depends on Fred.

One way to see this is to draw the schematic of the circuit described by your HDL code.

Another way is to list the dependencies for each signal.

out: {nota, notb}

nota: {outanda}
notb: {outandb}

outanda: {a, notb}
outandb: {nota, b}

nota: {outanda}
notb: {outandb}

So nota depends on outanda, outanda depends on notb, notb depends on outandb, and outandb depends on nota. The result is that nota depends on nota.

The circle is (nota -> outandb -> notb -> outanda -> nota)

Reply | Threaded
Open this post in threaded view
|

Re: Chip has a circle in it's parts? Xor.hdl issues

Zhme
This clears things up pretty well for me. I am at work right now, but when I get home I plan to clarify a more direct naming construct to make it work without my circle issue. On a side note, I managed to get it working with my previously-made gates very easily, but I will work on my convoluted attempt as a challenge for myself. Thank you both for your guidance!