简体   繁体   English

如何在 VHDL 中为 std_logic_vector 赋值?

[英]How to assign value to std_logic_vector in VHDL?

I am trying to assign value to OUTPUT std_logic_vector in the below code, but it gives me errors that我试图在下面的代码中为 OUTPUT std_logic_vector 赋值,但它给了我错误

COMP96 ERROR COMP96_0143: "Object "OUTPUT" cannot be written." COMP96 错误 COMP96_0143:“无法写入对象“输出”。” "design.vhd" 20 18 “设计.vhd” 20 18

COMP96 ERROR COMP96_0143: "Object "OUTPUT" cannot be written." COMP96 错误 COMP96_0143:“无法写入对象“输出”。” "design.vhd" 21 18 “设计.vhd” 21 18

COMP96 ERROR COMP96_0143: "Object "OUTPUT" cannot be written." COMP96 错误 COMP96_0143:“无法写入对象“输出”。” "design.vhd" 22 18 “设计.vhd” 22 18

COMP96 ERROR COMP96_0143: "Object "OUTPUT" cannot be written." COMP96 错误 COMP96_0143:“无法写入对象“输出”。” "design.vhd" 23 20 “设计.vhd” 23 20

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
 
entity demux_1to4 is
 port(
 I : IN STD_LOGIC;
 S: IN STD_LOGIC_VECTOR(1 downto 0);
 OUTPUT: IN STD_LOGIC_VECTOR(3 downto 0)
 );
end demux_1to4;
 
architecture bhv of demux_1to4 is
begin
process (I,S) is
begin
    case(S) is 
    when "00" => OUTPUT <= "0001" ;
    when "01" => OUTPUT<= "0010" ;
    when "10" => OUTPUT<= "0100" ;
    when others => OUTPUT<= "1000" ;
    end case ; 
end process;
end bhv;

Where I am doing wrong?我在哪里做错了?

Error indicates that "Object "OUTPUT" cannot be written."错误表示"Object "OUTPUT" cannot be written."

OUTPUT is declared as an input port in the entity. OUTPUT在实体中被声明为输入端口。 To write/assign values, it must be an output port.要写入/分配值,它必须是 output 端口。 (or an internal signal in general). (或一般的内部信号)。

OUTPUT: OUT STD_LOGIC_VECTOR(3 downto 0)

 port(
 I     : IN STD_LOGIC;
 S     : IN STD_LOGIC_VECTOR(1 downto 0);
 OUTPUT: OUT STD_LOGIC_VECTOR(3 downto 0)
 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM