Xilinx工具中的以下vhdl代码需要您的帮助 IEEE库; 使用IEEE.STD_LOGIC_1164.ALL; 使用IEEE.STD_LOGIC_ARITH.ALL; 使用IEEE.STD_LOGIC_UNSIGNED.ALL; 实体conv_enc为 端口(时钟:在标准逻辑中; rst:标准逻辑中; inp:in标准逻辑; 输出:输出标准逻辑向量(3到0); 结束会议; conv_enc的架构是 开始 过程 变量ff:std_逻辑_向量(3到0); 开始 等待上升沿(clk) 如果rst='1',则 ff
当Maria和jeff给出部分解决方案时,有几个错误: 您在三个位置声明了一个范围Xilinx工具中的以下vhdl代码需要您的帮助 IEEE库; 使用IEEE.STD_LOGIC_1164.ALL; 使用IEEE.STD_LOGIC_ARITH.ALL; 使用IEEE.STD_LOGIC_UNSIGNED.ALL; 实体conv_enc为 端口(时钟:在标准逻辑中; rst:标准逻辑中; inp:in标准逻辑; 输出:输出标准逻辑向量(3到0); 结束会议; conv_enc的架构是 开始 过程 变量ff:std_逻辑_向量(3到0); 开始 等待上升沿(clk) 如果rst='1',则 ff,vhdl,xilinx,xilinx-ise,xilinx-edk,Vhdl,Xilinx,Xilinx Ise,Xilinx Edk,当Maria和jeff给出部分解决方案时,有几个错误: 您在三个位置声明了一个范围下到,而不是下到 在进程中,您错过了终止wait语句的分号 您试图读取进程之外的变量(在其作用域之外) 下面是您纠正这些错误的代码,特别是使ff成为一个信号: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity conv_enc is
下到
,而不是下到
在进程中,您错过了终止wait语句的分号
您试图读取进程之外的变量(在其作用域之外)
下面是您纠正这些错误的代码,特别是使ff成为一个信号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity conv_enc is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
inp : in STD_LOGIC;
outp : out STD_LOGIC_VECTOR(3 DOWN TO 0));
end conv_enc;
architecture Behavioral of conv_enc is
begin
process
variable ff:std_logic_vector(3 down to 0);
begin
wait until rising_edge (clk)
if rst='1' then
ff<="0000";
else
for i in 2 down to 0 loop
ff(i)<=ff(i+1);
end loop;
ff(3)<=inp;
end if;
end process;
outp(0) <= inp xor ff(1) xor ff(0) ;
outp(1) <= inp xor ff(3) xor ff(2) xor ff(1) ;
outp(2) <= inp xor ff(3) xor ff(2) xor ff(1) xor ff(0);
end Behavioral;
ieee库;
使用ieee.std_logic_1164.all;
--使用IEEE.STD_LOGIC_ARITH.ALL;
--使用IEEE.STD_LOGIC_UNSIGNED.ALL;
实体conv_enc为
港口(
clk:标准逻辑中;
rst:标准逻辑中;
inp:in标准逻辑;
输出:输出标准逻辑向量(从3下降到0)--下降到
);
终端实体确认;
conv_enc的架构是
信号ff:std_逻辑_向量(3到0);--过程外部使用的变量
开始
过程
--变量ff:std_逻辑_向量(3到0);--原因是
开始
等待上升沿(clk);——正在用分号结尾吗
如果rst='1',则
ff您不应使用STD_LOGIC_UNSIGNED
或STD_LOGIC_ARITH
;您的代码不执行任何算术运算,即使执行了,您也会为此使用numeric\u std
包。
library ieee;
use ieee.std_logic_1164.all;
-- use IEEE.STD_LOGIC_ARITH.ALL;
-- use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity conv_enc is
port (
clk: in std_logic;
rst: in std_logic;
inp: in std_logic;
outp: out std_logic_vector(3 downto 0) -- WAS DOWN TO
);
end entity conv_enc;
architecture behavioral of conv_enc is
signal ff: std_logic_vector(3 downto 0); -- variable used outside process
begin
process
-- variable ff: std_logic_vector(3 downto 0); -- was down to
begin
wait until rising_edge (clk); -- was miaaing terminating semicolon
if rst = '1' then
ff <= "0000";
else
for i in 2 downto 0 loop -- was down to
ff(i) <= ff(i + 1);
end loop;
ff(3) <= inp;
end if;
end process;
outp(0) <= inp xor ff(1) xor ff(0);
outp(1) <= inp xor ff(3) xor ff(2) xor ff(1);
outp(2) <= inp xor ff(3) xor ff(2) xor ff(1) xor ff(0);
end architecture behavioral;