ALU

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

ALU

Thomas Tetlaw
Can someone please give me some hints as to how to implement the negating part of the ALU ? I'm stuck and I don't want to continue without finishing this first!
Reply | Threaded
Open this post in threaded view
|

Re: ALU

Thomas Tetlaw
Can someone give me ANY hints at all? I've done a lot of googling and i can't find out how to do it/understand how to do it in HDL. :(
Reply | Threaded
Open this post in threaded view
|

Re: ALU

cadet1620
Administrator
In reply to this post by Thomas Tetlaw
Thomas Tetlaw wrote
Can someone please give me some hints as to how to implement the negating part of the ALU ? I'm stuck and I don't want to continue without finishing this first!
In this context, "negate" has two meanings.  Read 2.2.2 carefully to determine if you need arithmetic negation or logical negation.

Check out ybakos' worksheet http://questions-and-answers-forum.32033.n3.nabble.com/ALU-Worksheet-tp95834p95834.html

Also, since this is hardware and not software, it is easier to compute everything and choose the result you need than to build a circuit that does conditional computation.

If you need more help, send me a private message with your email address and I'll be happy to guide you further.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: ALU

culchie
cadet1620 wrote
Also, since this is hardware and not software, it is easier to compute everything and choose the result you need than to build a circuit that does conditional computation
I think that this is a a very important insight.
Reply | Threaded
Open this post in threaded view
|

Re: ALU

Thomas Tetlaw
In reply to this post by cadet1620
Okay, I looked at 2.2.2 and saw that it read bit-wise negation, and now I have code that when n(the negate bit) is 1 and in(the 16-bit input bus) is 1(in decimal) the output is -2. Is this correct output? (I don't know if I should post my whole code as it could be a spoiler.)
Reply | Threaded
Open this post in threaded view
|

Re: ALU

cadet1620
Administrator
Thomas Tetlaw wrote
Okay, I looked at 2.2.2 and saw that it read bit-wise negation, and now I have code that when n(the negate bit) is 1 and in(the 16-bit input bus) is 1(in decimal) the output is -2. Is this correct output? (I don't know if I should post my whole code as it could be a spoiler.)
  1 (decimal) = 0000 0000 0000 0001 (binary)
–2 (decimal) = 1111 1111 1111 1110 (binary)
so you're good so far.

For 2's complement numbers in general, NOT(x) = (-x)-1

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: ALU

linuxford
In reply to this post by culchie
culchie wrote
cadet1620 wrote
Also, since this is hardware and not software, it is easier to compute everything and choose the result you need than to build a circuit that does conditional computation
I think that this is a a very important insight.
 
Good point. Thank you for pointing this out.