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

📄 fourbitsuber.vhd

📁 用VHDL写的一个小游戏
💻 VHD
字号:
--------------------------------------------------------------------------------------------------------------------
--实验题号   : Ex2-3
--项目名称   : 4bit减法器
--文件名     : FourBitSuber.vhd
--作者       : 田甲
--班号.      : 计45 
--创建日期   : 2006-03-23
--目标芯片   : EP1C6Q240C8
--电路模式   : 模式1
--功能描述   : 本文件给出了4bit减法器的结构描述,调用了4bit加法器和补码器元件,涉及port map等语法现象。
--------------------------------------------------------------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;

entity FourBitSuber is
port(Sa, Sb: in std_logic_vector(3 downto 0);
    Ss: out std_logic_vector(3 downto 0);
    Ssgn: out std_logic );
end entity;

architecture Impl of FourBitSuber is
component FourBitAdder is
port(a, b: in std_logic_vector(3 downto 0);
    s: out std_logic_vector(3 downto 0);
    carry: out std_logic );
end component;

component Complementor is
port(num: in std_logic_vector(3 downto 0);
     numout: out std_logic_vector(3 downto 0));
end component;

signal zero, tmpc, sgn: std_logic; 
signal tmp1, tmp2, tmp3: std_logic_vector(3 downto 0); 

begin
  zero<='0';
  u1: Complementor port map
    (num=>Sb, numout=>tmp1);    
  u2: FourBitAdder port map
    (a=>Sa, b=>tmp1, s=>tmp2, carry=>tmpc); 
  sgn<=tmpc xor '1';
  u3: Complementor port map
    (num=>tmp2, numout=>tmp3); 
  Ssgn<=sgn;
  Ss(0)<=(tmp2(0) and (not sgn))or(tmp3(0) and sgn);
  Ss(1)<=(tmp2(1) and (not sgn))or(tmp3(1) and sgn);
  Ss(2)<=(tmp2(2) and (not sgn))or(tmp3(2) and sgn);
  Ss(3)<=(tmp2(3) and (not sgn))or(tmp3(3) and sgn);
  
end architecture Impl;

⌨️ 快捷键说明

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