For loop for循环中的vhdl异步赋值
我正在做这样的事情:For loop for循环中的vhdl异步赋值,for-loop,asynchronous,variable-assignment,vhdl,For Loop,Asynchronous,Variable Assignment,Vhdl,我正在做这样的事情: x : in STD_LOGIC_VECTOR(15 downto 0); signal x_d: std_logic_vector(15 downto 0); type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0); signal inp_concat : inp_concat_array; process (clk, reset) begin if
x : in STD_LOGIC_VECTOR(15 downto 0);
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0);
signal inp_concat : inp_concat_array;
process (clk, reset)
begin
if (rising_edge(clk)) then
if (reset = '1') then
for i in 0 to 15 loop
x_d(i) <= '0';
end loop;
else
for i in 0 to 15 loop
x_d(i) <= x(i);
end loop;
end if;
end if;
end process;
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
x:标准逻辑向量(15到0);
信号x_d:std_逻辑_向量(15到0);
inp_concat_类型数组是标准逻辑向量(1到0)的数组(0到15);
信号inp_concat:inp_concat_阵列;
过程(时钟、复位)
开始
如果(上升沿(clk)),则
如果(重置='1'),则
对于0到15循环中的i
如果看不到完整的设计描述来回答您的问题,那么x_d(i)可能有点冒险。您向我们提供了一个代码片段,并且没有语法错误的行号。代码片段包含三个for循环
现在,如果此片段表示从设计单元(体系结构)提取的连续段,那么您似乎试图在适合并发语句(体系结构主体)的位置使用循环语句(for循环,适用于流程或子程序的顺序语句)
为可能分析的内容提供缺少的位:
library ieee;
use ieee.std_logic_1164.all;
entity asyn is
port (
x : in STD_LOGIC_VECTOR(15 downto 0);
clk: in std_logic;
reset: in std_logic
);
end entity;
architecture foo of asyn is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0);
signal inp_concat : inp_concat_array;
begin
process (clk, reset)
begin
if (rising_edge(clk)) then
if (reset = '1') then
for i in 0 to 15 loop
x_d(i) <= '0';
end loop;
else
for i in 0 to 15 loop
x_d(i) <= x(i);
end loop;
end if;
end if;
end process;
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end architecture;
NEW_PROCESS:
process (x,x_d)
begin
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end process;
在架构体中适合并发语句的位置,唯一可以有for关键字的语句是generate语句,它需要一个标签
VHDL中不要求预先消除语法错误的歧义(这就是为什么会有模糊的错误消息)
另一种工具提供了更好的说明:
nvc -a async.vhdl
** Error: syntax error, unexpected for, expecting process
File async.vhdl, Line 32
for j in 0 to 15 loop
^^^
因此,如果将for循环放在流程中,它可能会分析:
library ieee;
use ieee.std_logic_1164.all;
entity asyn is
port (
x : in STD_LOGIC_VECTOR(15 downto 0);
clk: in std_logic;
reset: in std_logic
);
end entity;
architecture foo of asyn is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0);
signal inp_concat : inp_concat_array;
begin
process (clk, reset)
begin
if (rising_edge(clk)) then
if (reset = '1') then
for i in 0 to 15 loop
x_d(i) <= '0';
end loop;
else
for i in 0 to 15 loop
x_d(i) <= x(i);
end loop;
end if;
end if;
end process;
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end architecture;
NEW_PROCESS:
process (x,x_d)
begin
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end process;
新流程:
过程(x,x_d)
开始
对于0到15循环中的j
inp_concat(j)如果没有完整的设计描述来回答您的问题,可能会有点风险。您向我们提供了一个代码片段,并且没有语法错误的行号。代码片段包含三个for循环
现在,如果此片段表示从设计单元(体系结构)提取的连续段,那么您似乎试图在适合并发语句(体系结构主体)的位置使用循环语句(for循环,适用于流程或子程序的顺序语句)
为可能分析的内容提供缺少的位:
library ieee;
use ieee.std_logic_1164.all;
entity asyn is
port (
x : in STD_LOGIC_VECTOR(15 downto 0);
clk: in std_logic;
reset: in std_logic
);
end entity;
architecture foo of asyn is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0);
signal inp_concat : inp_concat_array;
begin
process (clk, reset)
begin
if (rising_edge(clk)) then
if (reset = '1') then
for i in 0 to 15 loop
x_d(i) <= '0';
end loop;
else
for i in 0 to 15 loop
x_d(i) <= x(i);
end loop;
end if;
end if;
end process;
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end architecture;
NEW_PROCESS:
process (x,x_d)
begin
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end process;
在架构体中适合并发语句的位置,唯一可以有for关键字的语句是generate语句,它需要一个标签
VHDL中不要求预先消除语法错误的歧义(这就是为什么会有模糊的错误消息)
另一种工具提供了更好的说明:
nvc -a async.vhdl
** Error: syntax error, unexpected for, expecting process
File async.vhdl, Line 32
for j in 0 to 15 loop
^^^
因此,如果将for循环放在流程中,它可能会分析:
library ieee;
use ieee.std_logic_1164.all;
entity asyn is
port (
x : in STD_LOGIC_VECTOR(15 downto 0);
clk: in std_logic;
reset: in std_logic
);
end entity;
architecture foo of asyn is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of std_logic_vector(1 downto 0);
signal inp_concat : inp_concat_array;
begin
process (clk, reset)
begin
if (rising_edge(clk)) then
if (reset = '1') then
for i in 0 to 15 loop
x_d(i) <= '0';
end loop;
else
for i in 0 to 15 loop
x_d(i) <= x(i);
end loop;
end if;
end if;
end process;
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end architecture;
NEW_PROCESS:
process (x,x_d)
begin
for j in 0 to 15 loop
inp_concat(j) <= x(j) & x_d(j);
end loop;
end process;
新流程:
过程(x,x_d)
开始
对于0到15循环中的j
inp_concat(j)问题在于异步for循环不在进程内,需要这样做:这应该可以做到
process(x,x_d)
begin
for j in 0 to 15 loop
inp_process(j) <= x(j) & x_d(j);
end loop;
end process;
过程(x,x\d)
开始
对于0到15循环中的j
inp_进程(j)问题在于异步for循环不在进程内,需要这样做:这应该可以做到
process(x,x_d)
begin
for j in 0 to 15 loop
inp_process(j) <= x(j) & x_d(j);
end loop;
end process;
过程(x,x\d)
开始
对于0到15循环中的j
inp_进程(j)必须使用generate
语句执行for
的并发循环,如:
inp_concat_loop : for j in 0 to 15 generate
inp_concat(j) <= x(j) & x_d(j);
end generate;
inp\u concat\u循环:对于0到15中的j生成
inp_concat(j)for
的并发循环必须使用generate
语句进行,如:
inp_concat_loop : for j in 0 to 15 generate
inp_concat(j) <= x(j) & x_d(j);
end generate;
inp\u concat\u循环:对于0到15中的j生成
下面的inp_concat(j)是一个更简单、更整洁的解决方案的建议。仿真结果如下
-----------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
-----------------------------------------------
entity test is
port (
clk, reset: in std_logic;
x: in std_logic_vector(15 downto 0);
--test signals:
test: out std_logic_vector(1 downto 0);
test_index: in natural range 0 to 15);
end entity;
-----------------------------------------------
architecture test of test is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of
std_logic_vector(1 downto 0);
signal inp_concat: inp_concat_array;
begin
process (clk, reset)
begin
if rising_edge(clk) then
if reset = '1' then
x_d <= (others => '0');
else
x_d <= x;
end if;
end if;
end process;
gen: for i in 0 to 15 generate
inp_concat(i) <= x(i) & x_d(i);
end generate;
test <= inp_concat(test_index);
end architecture;
-----------------------------------------------
-----------------------------------------------
图书馆ieee;
使用ieee.std_logic_1164.all;
-----------------------------------------------
实体测试是
港口(
时钟,复位:在标准逻辑中;
x:标准逻辑向量(15到0);
--测试信号:
测试:输出标准逻辑向量(1到0);
测试指数:在自然范围内(0至15);
终端实体;
-----------------------------------------------
测试的体系结构测试是
信号x_d:std_逻辑_向量(15到0);
类型inp_concat_数组是
标准逻辑向量(1到0);
信号inp_concat:inp_concat_阵列;
开始
过程(时钟、复位)
开始
如果上升沿(clk),则
如果重置='1',则
x_d'0');
其他的
下面是一个更简单、更整洁的解决方案的建议。仿真结果如下
-----------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
-----------------------------------------------
entity test is
port (
clk, reset: in std_logic;
x: in std_logic_vector(15 downto 0);
--test signals:
test: out std_logic_vector(1 downto 0);
test_index: in natural range 0 to 15);
end entity;
-----------------------------------------------
architecture test of test is
signal x_d: std_logic_vector(15 downto 0);
type inp_concat_array is array (0 to 15) of
std_logic_vector(1 downto 0);
signal inp_concat: inp_concat_array;
begin
process (clk, reset)
begin
if rising_edge(clk) then
if reset = '1' then
x_d <= (others => '0');
else
x_d <= x;
end if;
end if;
end process;
gen: for i in 0 to 15 generate
inp_concat(i) <= x(i) & x_d(i);
end generate;
test <= inp_concat(test_index);
end architecture;
-----------------------------------------------
-----------------------------------------------
图书馆ieee;
使用ieee.std_logic_1164.all;
-----------------------------------------------
实体测试是
港口(
时钟,复位:在标准逻辑中;
x:标准逻辑向量(15到0);
--测试信号:
测试:输出标准逻辑向量(1到0);
测试指数:在自然范围内(0至15);
终端实体;
-----------------------------------------------
测试的体系结构测试是
信号x_d:std_逻辑_向量(15到0);
类型inp_concat_数组是
标准逻辑向量(1到0);
信号inp_concat:inp_concat_阵列;
开始
过程(时钟、复位)
开始
如果上升沿(clk),则
如果重置='1',则
x_d'0');
其他的
克苏德