Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / vhdl_json / vhdl_files / 2-exportOK / ghdl / ghdl / testsuite / gna / bug040 / sub_207.vhd @ 2051e520

History | View | Annotate | Download (1.72 KB)

1 2051e520 Arnaud Dieumegard
library ieee;
2
use ieee.std_logic_1164.all;
3
4
library ieee;
5
use ieee.numeric_std.all;
6
7
entity sub_207 is
8
	port (
9
		ge : out std_logic;
10
		le : out std_logic;
11
		output : out std_logic_vector(40 downto 0);
12
		sign : in  std_logic;
13
		in_b : in  std_logic_vector(40 downto 0);
14
		in_a : in  std_logic_vector(40 downto 0)
15
	);
16
end sub_207;
17
18
architecture augh of sub_207 is
19
20
	signal carry_inA : std_logic_vector(42 downto 0);
21
	signal carry_inB : std_logic_vector(42 downto 0);
22
	signal carry_res : std_logic_vector(42 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(41 downto 1);
42
43
	-- Other comparison outputs
44
45
	-- Temporary signals
46
	msb_abr <= in_a(40) & in_b(40) & carry_res(41);
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" or msb_abr = "111" else
53
		'1' when tmp_sign = '0' and (msb_abr = "010" or msb_abr = "011") 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") else
61
		'0';
62
63
	ge <= tmp_ge;
64
	le <= tmp_le;
65
66
end architecture;