and_44的建筑行为
variable zero_out : integer := 0;
variable temp_store : std_logic_vector(0 to 43);
variable temp_store_size : integer := 43;
variable output_count : integer := 0;
variable temp_z : std_logic := '1';
begin
for (i in 0 to 43) loop
if (fuse_map(i) = '1') then --fuse blown
temp_store_size := tem_store_size - 1;
temp_store := temp_store(0 to temp_store_size); --reduce temp storage by 1
elsif (fuse_map(i) = '0') then --fuse not blown, add to list
temp_store((43-temp_store_size)) <= and_44(i);
end if ;
end loop;
for j in 0 to temp_store_size loop
temp_z <= temp_z and temp_store(j);
end;
z <= temp_z;
end behavioral; 我试图创建一个44输入和门,有熔断器,以便可以选择输入基于fuse_map。我需要知道这一行是否正确,是否允许:
temp_store := temp_store(0 to temp_store_size); 另外,我的编译器告诉我在第一个for循环中有几个语法错误。
如有任何反馈,我们将不胜感激。
发布于 2014-04-10 18:29:30
您的描述有点模糊,但似乎您需要一个多输入和门的方式来控制哪些输入有助于输出。使用为std_logic_vector和相关数组类型定义的现有逻辑运算符在硬件术语中考虑这些类型的逻辑问题通常是有用的。
如果我们取一个输入向量,并从逻辑上使用从fuse_map派生的掩码或它们,我们将强制未使用的输入到'1‘,然后可以通过和减少操作来执行多路和。VHDL-2002在ieee.reduce_pack中增加了一组约简函数.VHDL-2008添加了本地逻辑约简作为一元运算符:and <vector>。对于VHDL-93,您必须提供自己的功能。这种技术的一个警告是,如果在fuse_map中禁用了所有输入,那么您的和关口将评估为'1‘。
您想要完成的任务可以在一个连续的任务中完成,如下所示:
output <= and_reduce(inputs or not fuse_map); -- VHDL-93 & 2002
output <= and (inputs or not fuse_map); -- VHDL-2008下面的实体给出了如何这样做的完整示例。在实际代码中,如果不需要多次实现该逻辑,则可以跳过实体,直接使用相同的技术。
library ieee;
use ieee.std_logic_1164.all;
entity and_map is
port (
-- Using unconstrained arrays here to maintain flexibility
-- The inputs and fuse_map signals must have the same width or
-- you will get an error upon elaboration.
inputs : in std_logic_vector;
fuse_map : in std_logic_vector; -- '1' for active inputs
output : out std_logic
);
end entity;
architecture rtl of and_map is
-- Use this and_reduce function for VHDL-93 or the and_reduce
-- from ieee.reduce_pack if you are using VHDL-2002
-- or the built-in reduction and from VHDL-2008
function and_reduce(inputs : std_logic_vector) return std_logic is
variable result : std_logic := '0';
begin
for i in inputs'range loop
result := result and inputs(i);
end loop;
return result;
end function;
begin
-- Continuous assignment sets unused inputs to '1'
-- and then uses and_reduce to evaluate them all.
output <= and_reduce(inputs or not fuse_map);
end architecture;样式注意: VHDL不需要控制结构中表达式的括号。
只有当temp_store := temp_store(0 to temp_store_size);为43时,行temp_store_size才有效。将片temp_store(0 to temp_store_size)看作是在赋值之前临时创建的隐式数组变量。一旦减少了temp_store_size,就需要在不同大小的数组之间分配,这是不允许的。
https://stackoverflow.com/questions/22976070
复制相似问题