blob: 8f01c369b0d5add18d2978591a4eaa4bd8dfdc36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 05/05/2025 02:21:36 PM
-- Design Name:
-- Module Name: Bin2DualBCD_S - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Bin2DualBCD_S is
Port ( signed_in : in STD_LOGIC_VECTOR (3 downto 0);
signed_code : out STD_LOGIC_VECTOR (3 downto 0);
signed_units : out STD_LOGIC_VECTOR (3 downto 0));
end Bin2DualBCD_S;
architecture Behavioral of Bin2DualBCD_S is
begin
process (signed_in(0))
begin
case (signed_in(0)) is
when '0' =>
signed_code <= "0000";
when '1' =>
signed_code <= "1101";
when others =>
signed_code <= "1110"; -- E
end case;
end process;
-- Units are the same regardless of sign.
process (signed_in(2 downto 0))
begin
case (signed_in(2 downto 0)) is
when "000" =>
signed_units <= "0000";
when "001" =>
signed_units <= "0001";
when "010" =>
signed_units <= "0010";
when "011" =>
signed_units <= "0011";
when "100" =>
signed_units <= "0100";
when "101" =>
signed_units <= "0101";
when "110" =>
signed_units <= "0101";
when "111" =>
signed_units <= "0111";
when others =>
signed_units <= "1111"; -- r
end case;
end process;
end Behavioral;
|