Logic Gates

Hey guys, I'm currently working on a project for school and I'm having trouble converting logic to gate level (mean AND's, OR's, XOR's, ...).

The logic i'm trying to incorporate (pseudo-code):

1
2
3
4
5
if (flag == 1) then
    a = !a + 4'b0001; // so invert all bits and then add 1 for two's complement (4-bit system btw)
else
    a = a;
end if

Any ideas?
Last edited on
bit by bit.
Choosing A or ~A
A F Z
0 0 0
0 1 1
1 0 1
1 1 0


Incrementing a number
A Ci Z Co
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
I have created an adder which utilizes the approach you are using.

However, in the project description, we are given an input called "flag" which indicates a negative or positive value. If flag is 1, then convert the bits to two's complement and do addition.

The part I'm struggling with is writing gate level description for the if statement.
Last edited on
A selector
A B S Z
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
1
2
3
4
if (s)
    T();
else
    F();

translates to http://imageshack.us/photo/my-images/822/clipboard01mt.png/
Of course, you may need more data lines if you're working with bigger numbers.
Last edited on
Thanks guys. This helped a lot. I've been struggling with this for days and I'm glad I posted.

Thank you ne555 and helios. :)
Topic archived. No new replies allowed.