📄 devider.vhdl
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity devider is
port(
a,b:in integer range 0 to 15;
y:out std_logic_vector(3 downto 0);
rest:out integer range 0 to 15;
err:out std_logic
);
end devider;
architecture Behavioral of devider is
begin
process(a,b)
variable temp1:integer range 0 to 15;
variable temp2:integer range 0 to 15;
begin
temp1:=a;
temp2:=b;
if b=0 then err<='1';
else err<='0';
end if;
if temp1>=temp2*8 then
y(3)<='1';
temp1:=temp1-temp2*8;
else
y(3)<='0';
end if;
if temp1>=temp2*4 then
y(2)<='1';
temp1:=temp1-temp2*4;
else
y(2)<='0';
end if;
if temp1>=temp2*2 then
y(1)<='1';
temp1:=temp1-temp2*2;
else
y(1)<='0';
end if;
if temp1>=temp2 then
y(0)<='1';
temp1:=temp1-temp2;
else
y(0)<='0';
end if;
rest<=temp1;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -