- 在这种情况下不能有这样的操作数
有人能告诉我出了什么问题以及如何解决它吗?
我试图在互联网上搜索问题,为什么我不能添加到STD_LOGIC_VECTOR,我没有找到任何解释我的问题的东西.所以我在这里问你们这是什么问题?
entity Modes is
Port ( RST : in STD_LOGIC;
CLK_33MHZ : in STD_LOGIC;
BTN : in STD_LOGIC;
LED : out STD_LOGIC);
end Modes;
architecture Behavioral of Modes is
signal ledstatus : STD_LOGIC;
signal mode : STD_LOGIC_VECTOR(1 downto 0);
signal modestatus : STD_LOGIC_VECTOR (1 downto 0);
begin
process(CLK_33MHZ,RST)
variable cnt : integer range 0 to 33000000;
begin
if(RST = '1') then
cnt := 0;
mode <= "00";
LED <= '0';
ledstatus <= '0';
elsif(rising_edge(CLK_33MHZ)) then
if(BTN = '1') then
elsif(mode = "11") then
mode <= "00";
else
**mode <= mode + "01";** -- the problem in the code
end if;
if(mode = "00") then
LED <= '0';
elsif(mode = "01") then
LED <= '1';
elsif(mode = "10") then
if(cnt = 33000000) then
LED <= not ledstatus;
else
cnt := cnt + 1;
end if;
elsif(mode = "11") then
if(cnt = 330000) then
LED <= not ledstatus;
else
cnt := cnt + 1;
end if;
end if;
end if;
LED <= ledstatus;
end process;
end Behavioral;
Run Code Online (Sandbox Code Playgroud)
小智 6
A std_logic_vector
只是一个位向量 - 它不一定是数字.+
在这种情况下,运营商没有任何意义.
您需要明确声明它是一个数字,在您的情况下是无符号数字,然后将其转换回std_logic_vector
:
mode <= std_logic_vector(unsigned(mode) + 1);
Run Code Online (Sandbox Code Playgroud)
当mode
等于3时,加1会使其回绕到0.
您的代码还有很多其他问题,但这将解决即时合成错误.