I have to design and implement a 4-bit processor for a course in uni using Xilinx, Virtex 6, VHDL. I don't really know what those all mean i'm only a first year student. These were the instructions we received for the program.
We need to be able to compute the following:
|X/2 - Y|
So the absolute value of X/2-Y, and we have to do it for X=9 and Y=12, and X=13 and Y=1.
I know that subtracting is addition with the negative version of a number (2's complement), and division by 2 is a right shift of the bits.
What I can't figure out is how do I represent 9, 12 and 13 as 4-bit numbers if we have to use 2's complement (since we are subtracting). I think it has something to do with the fact we need to take the absolute value but I can't figure it out. I'm not asking for the wiring of the processor, but I'm hoping for some tips towards solving the problem of doing that operation with 4 bits only.
Here is a schematic of the processor: