Finding the difference between two numbers

T

techman

Guest
Hi All,
I would be grateful if someone can tell me the best way to find the difference between two std logic vectors which at any one time may or may not be signed.
In simple terms if I was to use the integer equivalents then I would be looking for the following answers
-2 -5 = 3
-2 +5 = 7
5 - 2 = 3
-5 -2 = 3
Thanks
 
On 23/12/2014 15:23, techman wrote:
Hi All,
I would be grateful if someone can tell me the best way to find the difference between two std logic vectors which at any one time may or may not be signed.
In simple terms if I was to use the integer equivalents then I would be looking for the following answers
-2 -5 = 3
-2 +5 = 7
5 - 2 = 3
-5 -2 = 3
Thanks

I'm sorry but this is very basic. Can I suggest you google for
arithmetic examples in VHDL?

--
Mike Perkins
Video Solutions Ltd
www.videosolutions.ltd.uk
 
Hello Mike, Can you help with an architecture for the below entity and conditions.

Thanks

Library ieee;
use IEEE.std_logic_1164.all;

entity Sorter IS
Port ( C: IN std_logic_vector (0 to 3);
Sel: IN STD_LOGIC_VECTOR(0 to 2);
out0: out std_logic;
out1: out std_logic;
out2: out std_logic;
out3: out std_logic
);
end sorter;

I am to write an architecture for the above with condition that:

When Sel equal 4, the resulting output as shown in the table below is generated

out0 out1 out2 out3
0 <= C < 4 1 0 0 0

4 <= C < 8 0 1 0 0

8 <= C < 12 0 0 1 0

12 <= C < 16 0 0 0 1

otherwise out0,out1,out2,out3 are all equal to zero.

Thanks
 

Welcome to EDABoard.com

Sponsor

Back
Top