Unknown variable: in

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

Unknown variable: in

petridish
Hello,

I have built a Not gate, but I'm getting error "unknown variable: in" when I run the test.

CHIP NOT {
IN input1;
OUT out;

PARTS:
Nand(a=input1, b=input1, out=out);}

What could be causing this?
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variable: in

WBahn
Administrator
Would you expect things to work if you called the Nand gate using

Nand(the_input_I_want_to_call_fred=input1, the_other_input=input1, an_output_named_sue=out);

Of course not. There's a contract between you and the person that wrote the Nand gate that says that the two inputs are named 'a' and 'b' and the output is named 'out'. If either you or the person that wrote the Nand gate part decide to break the contract by using a different name for one of the ports, it's not going to be surprising that things don't work.

So, what is the contract between the user of the Not gate part (i.e., the test script) and the writer of the Not gate part (i.e., you)?

This is why the authors gave you templates for every part they are asking you to create that satisfy the contract for that part.
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variable: in

petridish
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variable: in

WBahn
Administrator
A Nand gate has two inputs. You've connected one of them. What about the other one? The simulator isn't a mind reader, so it doesn't know what your intentions are. Whoever wrote the simulator has to decide what to do in this case and there are a number of options. Throw an error? Assume that the input is tied to a specific level, such as LO? Assume that the input is tied to a default level that makes sense for that part?

Don't give the person that wrote the simulator that kind of power over your design. YOU decide what you want each input to be and then make it so.
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variable: in

petridish
It worked!

Previously when I added 2 inputs I was getting an error, but now I changed the input name and the comparison was successful.

Thank you so much for your help :) I was stuck on this for a while now.