【发布时间】:2013-12-16 17:11:26
【问题描述】:
我正在尝试在 VHDL 中编写一个 4 位计数器,该计数器从“0000”计数到“1111”或从“1111”到“0000”,具体取决于我的 UD 变量的值(如果 UD='1' 它应该倒计时,如果它是 ='0' 向上)。当我的计数器到达计数器的一侧(0 或 15)时,还有一个信号 RCO_L 获得 value='0'。最后还有一个 ENP_L 信号,当它设置为 1 时会禁止我的计数器。
我发现很难编写代码,因为我是 VHDL 的新手,而且我遇到了很多错误。如果有人可以帮助我,我将不胜感激。
这是我到目前为止所做的:
*entity contador is
Port ( A : in STD_LOGIC_VECTOR(3 downto 0);
CLK : in STD_LOGIC;
LOAD_L : in STD_LOGIC;
UD : in STD_LOGIC;
ENP_L : in STD_LOGIC;
Q : out STD_LOGIC (3 downto 0);
RCO_L : out STD_LOGIC);
end contador;
architecture Behavioral_contador of contador is
signal contador : STD_LOGIC_VECTOR(3 downto 0);
begin
process (CLK,UD,LOAD_L,ENP_L)
begin
if (CLK'event AND LOAD_L='0') then
Q <= A;
elsif (CLK'event AND LOAD_L='1') then
if (UD='0') then
contador <= contador + 1;
elsif (UD='1') then
contador <= contador - 1;
end if;
if (contador="0000" and ENP_L='0') then
RCO_L='0';
if (UD='0') then
contador="0001";
elsif (UD='1') then
contador="1111";
end if;
else
RCO='1';
end if;
end if;
end process;
Q <= contador;
end Behavioral_contador;*
如果有帮助,这是错误控制台结果:
*ERROR:HDLCompiler:535 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 40: Index constraint prefix std_logic should be an array type
ERROR:HDLCompiler:854 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 34: Unit <contador> ignored due to previous errors.
ERROR:HDLCompiler:374 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 44: Entity <contador> is not yet compiled.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 46: <std_logic_vector> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 53: <q> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 56: <contador> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 58: <contador> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 57: <ud> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 55: <ud> is not declared.
ERROR:HDLCompiler:806 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 61: Syntax error near "=".
ERROR:HDLCompiler:806 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 63: Syntax error near "=".
ERROR:HDLCompiler:837 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 63: Type void does not match with a string literal
ERROR:HDLCompiler:806 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 65: Syntax error near "=".
ERROR:HDLCompiler:837 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 65: Type void does not match with a string literal
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 64: <ud> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 62: <ud> is not declared.
ERROR:HDLCompiler:806 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 68: Syntax error near "=".
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 60: <contador> is not declared.
ERROR:HDLCompiler:69 - "/home/edig/Escritorio/vhdl/contador.vhd" Line 54: <clk> is not declared.*
【问题讨论】: