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

📄 alu.vhd

📁 用vhdl写的
💻 VHD
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

ENTITY ALU IS
PORT(
  s1,s0: in std_logic;
  a: in std_logic_vector(7 downto 0);
  b: in std_logic_vector(7 downto 0);
  bcdout: out std_logic_vector(7 downto 0);
  cy,zi:out std_logic
 );
END ALU;

ARCHITECTURE ONE OF ALU IS
 BEGIN
    process(s1,s0)
    BEGIN
    if (s1='0' and s0='0') then  --add
       bcdout<=A+B;
       cy<='0';
       zi<='0';
    elsif (s1='0' and s0='1') then --cmp(sub)
     bcdout<=a-b;
     if(a<b) then
      cy<='1';
      zi<='0';
     elsif (a=b) then 
       cy<='0';
       zi<='1';
     else
      cy<='0';
      zi<='0';
     end if;
    elsif (s1='1' and s0='0') then --inc
     bcdout<=a+1;
     cy<='0';
     zi<='0';     
    else
       bcdout<="00000000";
       cy<='0';
       zi<='0';
    end if ;
    END process;
 END one;

⌨️ 快捷键说明

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