如何将 vhdl 中的向量分配为零?
how to assign a vector in vhdl to zero?
我在 vhdl 中有一个向量 temp,如果向量达到最大值,我希望向量等于零 count_limit..向量大小是通用的..我怎么能做这样的事情?
GENERIC ( SIZE : INTEGER := 8);
constant count_limit : std_logic_vector(SIZE - 1 downto 0) := ( others => '1'); -- max value
signal temp: std_logic_vector(SIZE - 1 downto 0);
-- here i want to check if temp was equal to the max vaue then i want temp to be zero
-- here is what i did but thats not correct !
temp <= ( others => '0');
对我来说,你想要做的似乎是这样的:
--inside declaration part of the architecture
signal temp : unsigned(SIZE-1 downto 0);
constant count_limit : unsigned(SIZE - 1 downto 0) := ( others => '1');
--in the body
clocked_count: process(clk) begin
if rising_edge(clk) then
if temp < count_limit then
temp <= temp +1;
else temp <= (others => '0');
end if;
end if;
end
只要保存的(最后)值小于count_limit,上述过程将在每个时钟周期递增temp 的值。当达到 count_limit 时,温度归零。仅当您将信号声明为无符号时比较才有效,因为这样就不会对位向量表示的内容产生歧义。
我在 vhdl 中有一个向量 temp,如果向量达到最大值,我希望向量等于零 count_limit..向量大小是通用的..我怎么能做这样的事情?
GENERIC ( SIZE : INTEGER := 8);
constant count_limit : std_logic_vector(SIZE - 1 downto 0) := ( others => '1'); -- max value
signal temp: std_logic_vector(SIZE - 1 downto 0);
-- here i want to check if temp was equal to the max vaue then i want temp to be zero
-- here is what i did but thats not correct !
temp <= ( others => '0');
对我来说,你想要做的似乎是这样的:
--inside declaration part of the architecture
signal temp : unsigned(SIZE-1 downto 0);
constant count_limit : unsigned(SIZE - 1 downto 0) := ( others => '1');
--in the body
clocked_count: process(clk) begin
if rising_edge(clk) then
if temp < count_limit then
temp <= temp +1;
else temp <= (others => '0');
end if;
end if;
end
只要保存的(最后)值小于count_limit,上述过程将在每个时钟周期递增temp 的值。当达到 count_limit 时,温度归零。仅当您将信号声明为无符号时比较才有效,因为这样就不会对位向量表示的内容产生歧义。