在下面的代码中,我在表达式"individuos(x):=cout“中得到了这个错误。我尝试做的是依次为每个个体数组分配一个不同的随机"cout“输入。如果我将表达式更改为“function cout",它会将相同的"cout”赋给所有的“<=”,如果我尝试使用assert函数构建一条顺序语句,也会发生同样的情况。我该如何解决这个问题?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_TEXTIO.ALL;
use ieee.numeric_std.all;
--package genetica_type is
--type genetica is array(0 to 49) of unsigned(7 downto 0);
--type fitness is array(0 to 49) of unsigned (2 downto 0);
--end package genetica_type;
use work.genetica_type.all;
entity conexao is
Port (
clk : in bit;
cout: in unsigned (7 downto 0);
individuos: out genetica
);
end entity;
architecture Behavioral of conexao is
--type genetica is array (0 to 49) of std_logic_vector (7 downto 0);
--signal s_individuos : genetica;
--signal i: genetica;
begin
process (clk)
begin
If (clk 'event and clk = '1') then
for x in 0 to 49 loop
individuos(x) := cout;
end loop;
end if ;
end process;
end Behavioral;发布于 2015-12-10 01:12:09
在下面代码的表达式“
(X):=cout”中,我得到了这个错误。
这是一个语法错误。严格按照编译器的要求使用<=。
我想要做的是按顺序为每个个体数组分配一个不同的随机“
”输入。如果我将表达式更改为"individuos <= cout",则会将相同的"cout“分配给所有"individuos”。
这正是您要求它做的事情:
If (clk 'event and clk = '1') then
for x in 0 to 49 loop
individuos(x) <= cout;
end loop;
end if ;在每个上升时钟沿,循环50x对所有50个地址执行50次分配,每个分配相同的数据。
我认为您想要做的是,在每个时钟上,执行一个赋值,并递增地址以指向下一个位置。
signal x : natural range 0 to individuos'high;
...
if rising_edge(clk) then
individuos(x) <= cout;
x <= x + 1 mod individuos'length;
end if;此代码与您的代码还有其他几个不同之处:
type genetica is array(3 to 49) of ...
使用断言很容易捕捉到这一点:
Assert individuos'low = 0 report "Array Individuos bound error" severity failure;它也会持续运行。如果你想启动和停止它,或者重置地址计数器,或者在它达到50时停止,这需要额外的逻辑。
https://stackoverflow.com/questions/34183415
复制相似问题