Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用操作码在VHDL中实现4位ALU_Vhdl - Fatal编程技术网

如何使用操作码在VHDL中实现4位ALU

如何使用操作码在VHDL中实现4位ALU,vhdl,Vhdl,所以我有一个实验任务,这是从上一个任务开始的,我用VHDL实现了一个单位ALU。单位ALU模块接受一个操作码,并基于该操作码执行操作,例如加法或减法 entity alu_slice is Port ( a : in STD_LOGIC; b : in STD_LOGIC; s : out STD_LOGIC; opcode : in STD_LOGIC_VECTOR (2 downto 0); c

所以我有一个实验任务,这是从上一个任务开始的,我用VHDL实现了一个单位ALU。单位ALU模块接受一个操作码,并基于该操作码执行操作,例如加法或减法

entity alu_slice is
     Port ( a : in STD_LOGIC;
           b : in STD_LOGIC;
           s : out STD_LOGIC;
           opcode : in STD_LOGIC_VECTOR (2 downto 0);
           cin : in STD_LOGIC;
           cout : out STD_LOGIC);
end alu_slice;
上面的操作码向量是模拟时放置3位操作码的位置,用于告诉ALU要执行的算术运算。单位ALU的行为如下所示:

architecture Behavioural of alu_slice is
architecture Behavioural of alu_slice is

begin 

multiplex: process(a, b, opcode, cin)  is begin

case opcode is
when "000" =>
--cin <= '0';
--s <= (a xor b) xor cin;
s <= (a xor b) xor cin;
cout <= (a and b) xor ((a xor b) and cin);


when "001" =>
s <= (a xor not b) xor cin;
cout <= (a and not b) xor ((a xor not b) and cin);


when "010" =>
s <= a and b;

when "011" =>
s <= a or b;

when "100" =>
s <= a xor b;

when "101" =>
s <= not a;

when "110" =>
--a <= cin;
cout <= a;

when "111" =>
s <= a xor cin;
cout <= a and cin;

when others =>
s <= (a xor b) xor cin;
cout <= (a and b) xor ((a xor b) and cin);


end case;

end process;

end behavioural;
这是使用所有的信号,我被告知使用我的笔记。我注释掉了op向量,因为这是我为了解决这个问题而添加的东西。最后,我在项目的体系结构中有四个ALU片,但我无法编译,因为我似乎无法找到一种方法来更新ALU片组件中的操作码逻辑向量,从而在所有单独的片上复制它,在四个位之间执行适当的操作

以下是体系结构中的其余代码:

architecture Behavioral of alu_pb is

component alu_slice is
  Port(a: in STD_LOGIC;
       b: in STD_LOGIC;
       s: out STD_LOGIC;
       opcode: in STD_LOGIC_VECTOR(2 down to 0);
       cin: in STD_LOGIC;
       cout: out STD_LOGIC);
       end component;

signal carry: STD_LOGIC_VECTOR(3 down to 0);
signal op_carry: STD_LOGIC_VECTOR(2 down to 0);
signal sum_buffer: STD_LOGIC_VECTOR(3 down to 0);
signal carry_in: STD_LOGIC;


begin

slice_zero: alu_slice
port map(
--opcode(0) => op(0);
--opcode(1) => op(1);
--opcode(2) => op(2);
a => a(0),
b => b(0),
s => s(0),
--s => sum_buffer(0),
cin => carry_in,
cout=>carry(0)
);

slice_one: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(1),
b => b(1),
s => s(1),
--s => sum_buffer(1)
cin => carry(0),
cout => carry(1)
);

slice_two: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(2),
b => b(2),
s => s(2),
--s => sum_buffer(2)
cin => carry(1),
cout => carry(2)
);

slice_three: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(3),
b => b(3),
s => s(3),
--s => sum_buffer(3),
cin => carry(2),
cout => carry(3)
);



--op_carry(0) <= op(0);
--op_carry(1) <= op(1);
--op_carry(2) <= op(2);



end Behavioral;
alu_pb的架构行为是 组件alu_片为 端口(a:标准_逻辑中; b:标准逻辑; s:输出标准逻辑; 操作码:标准逻辑向量(2到0); cin:标准逻辑; cout:输出标准逻辑); 端部元件; 信号进位:标准逻辑向量(3到0); 信号运算进位:标准逻辑矢量(2到0); 信号和缓冲区:标准逻辑向量(3到0); 信号进位:标准逻辑; 开始 切片0:alu切片 港口地图( --操作码(0)=>op(0); --操作码(1)=>op(1); --操作码(2)=>op(2); a=>a(0), b=>b(0), s=>s(0), --s=>sum_缓冲区(0), cin=>进位, cout=>进位(0) ); 一片:铝片 港口地图( --op(0)=>操作码(0), --操作(1)=>操作码(1), --op(2)=>操作码(2), a=>a(1), b=>b(1), s=>s(1), --s=>sum_缓冲区(1) cin=>进位(0), cout=>进位(1) ); 第二片:铝片 港口地图( --op(0)=>操作码(0), --操作(1)=>操作码(1), --op(2)=>操作码(2), a=>a(2), b=>b(2), s=>s(2), --s=>sum_缓冲区(2) cin=>进位(1), cout=>进位(2) ); 三片:铝片 港口地图( --op(0)=>操作码(0), --操作(1)=>操作码(1), --op(2)=>操作码(2), a=>a(3), b=>b(3), s=>s(3), --s=>sum_缓冲区(3), cin=>进位(2), cout=>进位(3) );
--op_carry(0)组件实例化中缺少操作码端口。您好@FritzDC,您能进一步说明吗?我曾试图查找有关您所说内容的一些信息,但我认为这是我在“s”端口下的组件中已经编写的内容。您有:--opcode(0)=>op(0);--错误:分号应该是逗号--op(0)=>操作码(0),--wring:端口应该是左的,而且您似乎有“下到”。应该是“downto”。谢谢,这帮了大忙。:)组件实例化中缺少操作码端口。您好@FritzDC,您能进一步说明吗?我曾试图查找有关您所说内容的一些信息,但我认为这是我在“s”端口下的组件中已经编写的内容。您有:--opcode(0)=>op(0);--错误:分号应该是逗号--op(0)=>操作码(0),--wring:端口应该是左的,而且您似乎有“下到”。应该是“downto”。谢谢,这帮了大忙。:)
architecture Behavioral of alu_pb is

component alu_slice is
  Port(a: in STD_LOGIC;
       b: in STD_LOGIC;
       s: out STD_LOGIC;
       opcode: in STD_LOGIC_VECTOR(2 down to 0);
       cin: in STD_LOGIC;
       cout: out STD_LOGIC);
       end component;

signal carry: STD_LOGIC_VECTOR(3 down to 0);
signal op_carry: STD_LOGIC_VECTOR(2 down to 0);
signal sum_buffer: STD_LOGIC_VECTOR(3 down to 0);
signal carry_in: STD_LOGIC;


begin

slice_zero: alu_slice
port map(
--opcode(0) => op(0);
--opcode(1) => op(1);
--opcode(2) => op(2);
a => a(0),
b => b(0),
s => s(0),
--s => sum_buffer(0),
cin => carry_in,
cout=>carry(0)
);

slice_one: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(1),
b => b(1),
s => s(1),
--s => sum_buffer(1)
cin => carry(0),
cout => carry(1)
);

slice_two: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(2),
b => b(2),
s => s(2),
--s => sum_buffer(2)
cin => carry(1),
cout => carry(2)
);

slice_three: alu_slice
port map(
--op(0) => opcode(0),
--op(1) => opcode(1),
--op(2) => opcode(2),
a => a(3),
b => b(3),
s => s(3),
--s => sum_buffer(3),
cin => carry(2),
cout => carry(3)
);



--op_carry(0) <= op(0);
--op_carry(1) <= op(1);
--op_carry(2) <= op(2);



end Behavioral;