VHDL Adavanced VHDL Arithmetic-Circuits

VHDL Concurrent-Statements

Counters

Flipflops

Logic-Circuits

Logic-Gates

Sequential-Statements

Shift-Registers

6.8.1 Binary to Excess-3 Code Converter :

The excess-three code is generated by adding the number three to the 8-4-2-1 code. Therefore, with some modification, calculations can be performed with the binary method. Each number has at least one "1", so that discrimination of mal-contact from the number zero is possible. A code conversion is a type of encoder designed to convert an input pattern to an output pattern.

1) Using selected signal assignment :

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY bin2ex3 IS

PORT (bin : IN std_logic_vector(3 DOWNTO 0);

ex3 : OUT std_logic_vector(3 DOWNTO 0));

END bin2ex3;

ARCHITECTURE exam OF bin2ex3 IS

BEGIN

WITH bin SELECT

ex3 <= “0011” WHEN "0000”,

“0100” WHEN ”0001”,

“0101” WHEN ”0010”,

“0110” WHEN ”0011”,

“0111” WHEN ”0100”,

“1000” WHEN ”0101”,

“1001” WHEN ”0110”,

“1010” WHEN ”0111”,

“1011” WHEN ”1000”,

“1100” WHEN ”1001”,

“1101” WHEN ”1010”,

“1110” WHEN ”1011”,

“1111” WHEN ”1100”,

“0000” WHEN ”1101”,

“0001” WHEN ”1110”,

“0010” WHEN OTHERS;

END exam;

2) Using case statement :

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY bin2ex3 IS

PORT (bin : IN std_logic_vector(3 DOWNTO 0);

ex3 : OUT std_logic_vector(3 DOWNTO 0));

END bin2ex3;

ARCHITECTURE exam OF bin2ex3 IS

begin

process (bin)

begin

case bin is

when “0000” => EX3 <= "0011";

when “0001” => EX3 <= "0100";

when “0010” => EX3 <= "0101";

when “0011” => EX3 <= "0110";

when “0100” => EX3 <= "1000";

when “0101” => EX3 <= "1001";

when “0110” => EX3 <= "1010";

when “0111” => EX3 <= "1011";

when “1000” => EX3 <= "1100";

when “1001” => EX3 <= "1101";

when “1010” => EX3 <= "1110";

when “1011” => EX3 <= "1111";

when “1100” => EX3 <= "0000";

when “1101” => EX3 <= "0001";

when “1110” => EX3 <= "0010";

when “1111” => EX3 <= "0011";

end case;

end process ;

END exam;

3) Using arithmetic operator :

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

ENTITY bin2ex3 IS

PORT (bin : IN std_logic_vector(3 DOWNTO 0);

ex3 : OUT std_logic_vector(3 DOWNTO 0));

END bin2ex3;

ARCHITECTURE exam OF bin2ex3 IS

BEGIN

ex3 <= bin + “0011”;

END exam;

FaceBook
Likes
Additonal Information