Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bus negation problem #5

Open
Sei-Lisa opened this issue Aug 16, 2020 · 3 comments
Open

Bus negation problem #5

Sei-Lisa opened this issue Aug 16, 2020 · 3 comments

Comments

@Sei-Lisa
Copy link

Not sure if this is the best place to report problems.

I'm having a problem with 2.0-b10:

Bus negation problem

The outputs should be the same, but the negated input of the top gate is not applied bitwise.

@bnoordhuis
Copy link
Owner

Can you post or upload a small sample file that demonstrates the issue? The more minimal, the better.

@Sei-Lisa
Copy link
Author

Issue 5 test case

I made the above example as a minimal test case to demonstrate wrong behaviour (top display) and correct behaviour (bottom display). It happens with any gate with buses as input, when negating an input. The negated input results in a value of zero, instead of the bitwise not of the input value. If it is an OR or XOR gate, the value is the one in the other input, regardless of the value in the negated input. If it is an AND gate, as above, the output is always zero.

This was working as expected in older versions, because I detected it when loading an old diagram that was working.

@Sei-Lisa
Copy link
Author

This patch fixes it for me:

--- a/src/tkgate/and.c	2020-08-18 00:59:55.055110382 +0200
+++ b/src/tkgate/and.c	2020-08-18 01:00:36.978226845 +0200
@@ -329,7 +329,7 @@
       first_pin = 0;
 
       if (gi->Pad[i].iotype == IN && w->invert)
-	inv = "!";
+	inv = "~";
 
       if (gi->Pad[i].CanAdd)
 	fprintf(f,".%s%d",gi->Pad[i].Name,j);

I can't tell if this may have other side effects, but it doesn't seem logical that inverting a bus wire behaves as logic NOT instead of bitwise NOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants