【发布时间】:2017-12-11 17:33:19
【问题描述】:
我的架构使用平方根组件,它有以下端口:
component SQRT is
port (sqrt_clock : in std_logic;
start : in std_logic;
value : in std_logic_vector (15 downto 0);
result : out std_logic_vector (7 downto 0);
busy : out std_logic
);
end component;
当 sqrt 模块完成它的工作时,忙碌信号将是 '0'
在我的主要过程中,我正在遍历一个输入数组并计算两个整数 a 和 b,它们是我的平方根模块的输入。然后,我想用输出文件填充第二个数据数组,它的数组大小与输入数组相同
Main_Process: process(clk)
variable a : integer := 0;
variable b : integer := 0;
begin
if reset = '0'then
...
elsif clk'event and clk = '1' then
for iter in 0 to arraySize-1 loop
-- x and y calculation with inputarray(iter)
value <= std_logic_vector(TO_UNSIGNED(a+b, 16));
start <= '1';
outputarray(iter) <= TO_INTEGER(unsigned(sqrt_output));
end loop;
end case;
end process;
我希望主进程在每次数组迭代后等到 sqrt 模块完成计算。在没有任何同步的情况下,来自 sqrt 模块的第一个结果将被填充到所有输出数组元素中。使用正确的行为,主进程应该等到 sqrt-module 完成计算,然后填充 output-array 元素并在最后一步继续 for 循环等等。
我尝试将“忙碌”信号放入主进程的敏感度列表中:
Main_Process: process(clk, busy)
variable a : integer := 0;
variable b : integer := 0;
begin
if reset = '0'then
...
elsif clk'event and clk = '1' then
--only iterate further then sqrt is finished (busy = 0)
for iter in 0 to arraySize-1 loop
-- x and y calculation with inputarray(iter)
value <= std_logic_vector(TO_UNSIGNED(a+b, 16));
start <= '1';
if busy = '0' then
outputarray(iter) <= TO_INTEGER(unsigned(sqrt_output));
start <= '0';
end if;
end loop;
end if;
end process;
不幸的是,它不起作用。有没有一种简单的方法来实现同步。没有第三个 FSM 进程?
注意:我希望代码也是可合成的。
【问题讨论】:
标签: vhdl