Project

General

Profile

Download (1.74 KB) Statistics
| Branch: | Tag: | Revision:
1
library ieee;
2
use ieee.std_logic_1164.all;
3

    
4
library ieee;
5
use ieee.numeric_std.all;
6

    
7
entity sub_144 is
8
	port (
9
		output : out std_logic_vector(63 downto 0);
10
		le : out std_logic;
11
		sign : in  std_logic;
12
		ge : out std_logic;
13
		in_a : in  std_logic_vector(63 downto 0);
14
		in_b : in  std_logic_vector(63 downto 0)
15
	);
16
end sub_144;
17

    
18
architecture augh of sub_144 is
19

    
20
	signal carry_inA : std_logic_vector(65 downto 0);
21
	signal carry_inB : std_logic_vector(65 downto 0);
22
	signal carry_res : std_logic_vector(65 downto 0);
23

    
24
	-- Signals to generate the comparison outputs
25
	signal msb_abr  : std_logic_vector(2 downto 0);
26
	signal tmp_sign : std_logic;
27
	signal tmp_eq   : std_logic;
28
	signal tmp_le   : std_logic;
29
	signal tmp_ge   : std_logic;
30

    
31
begin
32

    
33
	-- To handle the CI input, the operation is '0' - CI
34
	-- If CI is not present, the operation is '0' - '0'
35
	carry_inA <= '0' & in_a & '0';
36
	carry_inB <= '0' & in_b & '0';
37
	-- Compute the result
38
	carry_res <= std_logic_vector(unsigned(carry_inA) - unsigned(carry_inB));
39

    
40
	-- Set the outputs
41
	output <= carry_res(64 downto 1);
42

    
43
	-- Other comparison outputs
44

    
45
	-- Temporary signals
46
	msb_abr <= in_a(63) & in_b(63) & carry_res(64);
47
	tmp_sign <= sign;
48
	tmp_eq  <= '1' when in_a = in_b else '0';
49

    
50
	tmp_le <=
51
		tmp_eq when msb_abr = "000" or msb_abr = "110" else
52
		'1' when msb_abr = "001"  else
53
		'1' when tmp_sign = '0' and (msb_abr = "010" or msb_abr = "001" or msb_abr = "111") else
54
		'1' when tmp_sign = '1' and (msb_abr = "100" or msb_abr = "101") else
55
		'0';
56

    
57
	tmp_ge <=
58
		'1' when msb_abr = "000" or msb_abr = "110" else
59
		'1' when tmp_sign = '0' and (msb_abr = "100" or msb_abr = "101") else
60
		'1' when tmp_sign = '1' and (msb_abr = "010" or msb_abr = "011" or msb_abr = "111") else
61
		'0';
62

    
63
	ge <= tmp_ge;
64
	le <= tmp_le;
65

    
66
end architecture;
(56-56/68)