EDA 电子设计自动化VHDL系列课程5 – 代码转换
本EDA系列介绍的系统环境是:
软件: VHDL编程语言 ;
工具: Quartus13.0
FPGA 芯片是: Cyclone III : EP3C10E144C8
电路板细节在: https://blog.csdn.net/weixin_40935675/article/details/103316855
代码转换示例:BCD码 转 补3码
LIBRARY ieee;
USE ieee.std_logic_1164.all;
-- code convertion of BCDcode to Complimental-3 code
ENTITY BCDcode IS PORT
(
A: IN STD_LOGIC_VECTOR(4 DOWNTO 0);
Q: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
);
END BCDcode;
ARCHITECTURE coding OF BCDcode IS
BEGIN
PROCESS(A)
BEGIN
CASE A IS
WHEN "00000" => Q <= "0011";
WHEN "00001" => Q <= "0100";
WHEN "00010" => Q <= "0101";
WHEN "00011" => Q <= "0110";
WHEN "00100" => Q <= "0111";
WHEN "00101" => Q <= "1000";
WHEN "00110" => Q <= "1001";
WHEN "00111" => Q <= "0110";
WHEN "01000" => Q <= "0011";
WHEN "01001" => Q <= "1100";
WHEN OTHERS => Q <= "XXXX";
END CASE;
END PROCESS;
END coding;