OpenCores
URL https://opencores.org/ocsvn/signed_unsigned_multiplier_and_divider/signed_unsigned_multiplier_and_divider/trunk

Subversion Repositories signed_unsigned_multiplier_and_divider

[/] [signed_unsigned_multiplier_and_divider/] [trunk/] [bcddigitadder.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zpekic
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    21:08:09 03/28/2018 
6
-- Design Name: 
7
-- Module Name:    bcddigitadder - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity bcddigitadder is
33
    Port ( ci : in  STD_LOGIC;
34
           a : in  STD_LOGIC_VECTOR (3 downto 0);
35
           b : in  STD_LOGIC_VECTOR (3 downto 0);
36
           y : out  STD_LOGIC_VECTOR (3 downto 0);
37
           cout : out  STD_LOGIC);
38
end bcddigitadder;
39
 
40
architecture Behavioral of bcddigitadder is
41
 
42
signal binarysum: std_logic_vector(5 downto 0);
43
signal adjustedsum: std_logic_vector(4 downto 0);
44
alias adjust: std_logic is cout;
45
 
46
begin
47
 
48
binarysum <= std_logic_vector(unsigned('0' & a & ci) + unsigned('0' & b & ci));
49
adjustedsum <= std_logic_vector(unsigned('0' & binarysum(4 downto 1)) + "00110");
50
adjust <= '1' when (binarysum(4 downto 2) = "101" or binarysum(4 downto 3) = "11") else binarysum(5);
51
 
52
y <= adjustedsum(3 downto 0) when adjust = '1' else binarysum(4 downto 1);
53
 
54
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.