如何使用顺序语句(例如进程)来创建常量值而无需等待?

时间:2016-12-14 11:09:04

标签: vhdl xilinx xilinx-ise

为了保持一致性和易维护性,我想使用顺序语句制作一些常量,例如:正在进行中。

我使用以下方法定义了一个范围:

subtype FIELD is natural range 3 downto 0;

使该值看起来如下的过程:

process is
begin
    reg <= (others => '0');
    reg(FIELD) <= (others => '1');
    wait;  -- Error in Xilinx ISE
end process;

但是,Xilinx ISE综合工具不接受wait

当然,一种方法是在进程列表中使用未使用的信号,如时钟,但这是一种丑陋。

并发风格如下:

reg <= (FIELD => (others => '1'), others => '0');

但是,不能像在VHDL中那样使用FIELD。

有没有办法使用顺序语句制作常量,但是wait中不需要process

1 个答案:

答案 0 :(得分:1)

您可以使用函数来执行此操作。请注意,我不会对范围进行任何错误检查,但这并不困难。

-- subtypes
subtype FIELD is natural range 3 downto 0;

-- functions
function test_func(a: std_logic_vector) return std_logic_vector is
    variable result : std_logic_vector(a'left downto a'right) := a;
begin
    result(FIELD) := (others => '1');
    return result;
end function;

-- constants
constant ALL_ZEROS  : std_logic_vector(7 downto 0) := (others => '0');

-- signals
signal reg          : std_logic_vector(7 downto 0) := test_func(ALL_ZEROS);
相关问题