Forum Discussion
Altera_Forum
Honored Contributor
10 years ago --- Quote Start --- Are you absolutely sure about that? Because from what you describe it seems that both your inputs and outputs are active low. In your example code, if you assume that in_1 and in_2 are normally '1' and they become '0' when you press the key, then your out_1 will be normally '1' and become '0' if one or both of the two keys is pressed. Therefore if the LED is also active low, it will light when one or both of the keys is pressed, implementing what looks like an 'or' function, even if you used the '&' operator. Remember that an AND gate with all its inputs and outputs inverted is an OR gate (and vice versa) --- Quote End --- I think you have found the cause. I looked back at the schematic for my circuit and realised that I had totally overlooked my LED. I thought it was using an NPN transistor to drive it but it was in fact a PNP transistor. This means that my circuit has two naturally high inputs and one naturally high output. Thus making an OR gate operation, I rewrote part of the code to this
out_1 <= ~in_1 & ~in_2; Now my circuit acts like an NAND gate (better but not quite). Do you know a way in which I can now further improve this to be a AND gate operation? Many thanks for your help!