Vhdl 实例化4位全加器

Vhdl 实例化4位全加器,vhdl,instantiation,Vhdl,Instantiation,我很难实例化这段代码的fa0部分。我对VHDL相当陌生,所以可能不仅仅是一个答案会有所帮助 这个逻辑4模块是作为我正在处理的ALU组件的结构代码 多谢各位 ----------------------------------------------------------------- -- 4-bit adder/subtractor module ----------------------------------------------------------------- library

我很难实例化这段代码的fa0部分。我对VHDL相当陌生,所以可能不仅仅是一个答案会有所帮助

这个逻辑4模块是作为我正在处理的ALU组件的结构代码

多谢各位

-----------------------------------------------------------------
-- 4-bit adder/subtractor module
-----------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;

entity addsub4 is
    port (addl_subh : in std_logic;
        X, Y      : in std_logic_vector(3 downto 0);
        S         : out std_logic_vector(3 downto 0);
        cout, ovf : out std_logic);
end addsub4;

architecture addsub4_arch of addsub4 is

    component fa is
        port (cin, x, y : in std_logic;
            s, cout   : out std_logic);
    end component fa;

    -- let Yhat denote the signal after Y xor addl_subh
    signal Yhat: std_logic_vector(3 downto 0); 
    -- let carryout denote the cout signal for each fa module
    signal carryout: std_logic_vector(3 downto 0); 

begin

    Yhat(0) <= Y(0) xor addl_subh;
    Yhat(1) <= Y(1) xor addl_subh;
    Yhat(2) <= Y(2) xor addl_subh;
    Yhat(3) <= Y(3) xor addl_subh;

    fa0: fa
        port map ( cin => addl_subh, x => X(0), y => Yhat(0),
                s => S(0), cout => carryout(0));

    fa1: fa
        port map ( cin => carryout(0), x => X(1), y => Yhat(1),
                 s => S(1), cout => carryout(1));

    fa2: fa
        port map ( cin => carryout(1), x => X(2), y => Yhat(2),
                 s => S(2), cout => carryout(2));

    fa3: fa
        port map ( cin => carryout(2), x => X(3), y => Yhat(3),
                 s => S(3), cout => carryout(3));

    cout <= carryout(3);
    ovf <= carryout(2) xor carryout(3);

end addsub4_arch;
-----------------------------------------------------------------
--4位加法器/减法器模块
-----------------------------------------------------------------
图书馆ieee;
使用ieee.std_logic_1164.all;
实体addsub4是
端口(地址:标准逻辑中;
十、 Y:标准逻辑向量(3到0);
S:输出标准逻辑向量(3到0);
cout,ovf:输出标准逻辑);
结束addsub4;
addsub4的建筑addsub4_拱是
组分fa为
端口(cin,x,y:标准逻辑中;
s、 cout:输出标准逻辑);
端部成分fa;
--让Yhat表示Y xor addl_subh之后的信号
信号Yhat:std_逻辑_向量(3到0);
--让执行表示每个fa模块的cout信号
信号执行:标准逻辑向量(3到0);
开始
Yhat(0)S(0),cout=>carryout(0));
fa1:fa
端口映射(cin=>carryout(0),x=>x(1),y=>Yhat(1),
s=>s(1),cout=>carrout(1));
fa2:fa
端口图(cin=>carrout(1),x=>x(2),y=>Yhat(2),
s=>s(2),cout=>carrout(2));
fa3:fa
港口地图(cin=>carrout(2),x=>x(3),y=>Yhat(3),
s=>s(3),cout=>carrout(3));

cout您的代码没有错误,您应该向项目中添加一个包含fa(全加器)代码的单独文件。例如:

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY fa IS
PORT(x,y,cin : IN std_logic;
     s,cout  : OUT std_logic);
END ENTITY;

ARCHITECTURE dataflow OF fa IS
begin
    s <= x xor y xor cin;
    cout <= ((x xor y) and cin) or (x and y);
end dataflow;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
实体fa是
端口(x、y、cin:std_逻辑中;
s、 cout:输出标准逻辑);
终端实体;
fa的体系结构数据流是
开始

s实例:设计实体的子组件,其原型是组件声明、设计实体或配置声明。您有四个实体fa实例,其中一个用标签fa0修饰。注意您的代码分析,您的问题并不清楚。您在编写实体fa及其体系结构时有困难吗?你在详细阐述addsub4时有困难吗?我对所有这些都感到困惑,但我想我的问题是关于fa实体及其架构的编写。我正在学习一门名为“数字逻辑设计”的课程,但我们不会坐下来讨论VHDL的编码。这些代码大部分是我从不同网站拼凑的代码,包括教授给我的代码。为了帮助我,我正在创建这个4位模块,这就是我有四个fa实例的原因吗?也许你需要正确的介绍,例如Peter Ashenden的。这是82页,你可以略读,然后集中在第4章“基本建模概念”。您没有提出特定的编程问题,您的问题可能会被否决。好的,谢谢!我应该删除这个问题吗?