diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-11-24 22:03:27 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-11-24 22:03:27 +0100 |
commit | f31efd9ab679ed861794bf031819d5fe694b19d3 (patch) | |
tree | 3258270bc8dd76ab1796e1763da8e87aacbe7c84 /adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd | |
parent | a7fcbedbb3d3bc2c222775d6c6274ff5af6ea8fa (diff) | |
parent | 00af26cc9916c32cc279d8c741894d1000742b96 (diff) |
merge bin2bcd implementation from testbench into `master`
Diffstat (limited to 'adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd')
-rw-r--r-- | adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd b/adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd new file mode 100644 index 0000000..548c9e5 --- /dev/null +++ b/adder-and-display/adder-and-display.srcs/sources_1/bin2bcd.vhd @@ -0,0 +1,33 @@ +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; + +entity bin2bcd is port( + I: in std_logic_vector(4 downto 0); + X: out std_logic_vector(3 downto 0); + Y: out std_logic_vector(3 downto 0)); +end bin2bcd; + +architecture Behavioral of bin2bcd is +begin + with I select + X <= + b"0000" when b"00000" | b"01010" | b"10100" | b"11110", + b"0001" when b"00001" | b"01011" | b"10101" | b"11111", + b"0010" when b"00010" | b"01100" | b"10110", + b"0011" when b"00011" | b"01101" | b"10111", + b"0100" when b"00100" | b"01110" | b"11000", + b"0101" when b"00101" | b"01111" | b"11001", + b"0110" when b"00110" | b"10000" | b"11010", + b"0111" when b"00111" | b"10001" | b"11011", + b"1000" when b"01000" | b"10010" | b"11100", + b"1001" when b"01001" | b"10011" | b"11101", + (others => '0') when others; + with I select + Y <= + b"0000" when b"00000" | b"00001" | b"00010" | b"00011" | b"00100" | b"00101" | b"00110" | b"00111" | b"01000" | b"01001", + b"0001" when b"01010" | b"01011" | b"01100" | b"01101" | b"01110" | b"01111" | b"10000" | b"10001" | b"10010" | b"10011", + b"0010" when b"10100" | b"10101" | b"10110" | b"10111" | b"11000" | b"11001" | b"11010" | b"11011" | b"11100" | b"11101", + b"0011" when b"11110" | b"11111", + (others => '0') when others; +end Behavioral; + |