⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sub.vhd

📁 用VHDL编写的计算器:能实现简单的加减乘除四则运算
💻 VHD
字号:
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    16:41:55 11/21/2006 -- Design Name: -- Module Name:    sub - 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;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity sub is    Port ( num1 : in  STD_LOGIC_VECTOR (3 downto 0);           num2 : in  STD_LOGIC_VECTOR (3 downto 0);           num : out  STD_LOGIC_VECTOR (7 downto 0));end sub;architecture Behavioral of sub issignal q1,q2:integer range 0 to 9;signal q:integer range 0 to 9;beginq1<=conv_integer(num1);q2<=conv_integer(num2);
process(q1,q2)
begin
if q1>=q2 thenq<=q1-q2;
else
q<=q2-q1;
end if;
end process;num<=conv_std_logic_vector(q,8);end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -