【问题标题】:Connecting STD_LOGIC_VECTOR in different ways (Barrel Shifter) - VHDL以不同方式连接 STD_LOGIC_VECTOR (Barrel Shifter) - VHDL
【发布时间】:2012-12-15 21:35:47
【问题描述】:

我正在实现一个 N 位桶形移位器。

这是我的组件:

entity barrel_shifter is
    Generic ( N : integer := 4);
    Port ( data_in : in  STD_LOGIC_VECTOR (N-1 downto 0);
           shift : in  STD_LOGIC_VECTOR (integer(ceil(log2(real(N))))-1 downto 0); -- log2 of N => number of inputs for the shift
           data_out : out  STD_LOGIC_VECTOR (N-1 downto 0));
end barrel_shifter;

出于我的目的,我也创建了一个 N 位多路复用器,这是它的代码:

entity mux is
    Generic ( N : integer := 4);
    Port ( data_in : in  STD_LOGIC_VECTOR (N-1 downto 0);
           sel : in  STD_LOGIC_VECTOR (integer(ceil(log2(real(N))))-1 downto 0); -- log2 of N => number of inputs for the shift
           data_out : out  STD_LOGIC);
end mux;

architecture Behavioral of mux is

begin
    data_out <= data_in(to_integer(unsigned(sel)));
end Behavioral;

现在要实现圆桶移位器,我需要以不同的方式连接这些 N 个多路复用器。您可以找到示例here,第 2 页,图 1。如您所见,IN0 仅与 D0 多路复用器输入连接一次。下次IN0接D1多路复用器输入,以此类推……(其他输入逻辑相同)

但是我怎样才能在 VHDL 中实现类似的东西呢?如果我没有 STD_LOGIC_VECTOR 作为输入,那会很容易,但我需要制作一个通用的 Barrel Shifter(带有通用映射构造),所以我不能手动连接每条线,因为我不知道通用 N 的值.

在我的 bucket_shifter 实体中,我尝试了这个:

architecture Structural of barrel_shifter is

    signal q : STD_LOGIC_VECTOR (N-1 downto 0);

begin

    connections: for i in 0 to N-1 generate
        mux: entity work.mux(Behavioral) generic map(N) port map(std_logic_vector(unsigned(data_in) srl 1), shift, q(i));
    end generate connections;

    data_out <= q;

end Structural;

但它根本不起作用(“实际,运算符的结果,与正式信号关联,信号'data_in',不是信号。(LRM 2.1.1)”)。我试过使用变量和信号,像这样:

data_tmp := data_in(i downto 0) & data_in(N-i downto 1);

但我仍然想不出建立这些联系的正确方法。

【问题讨论】:

    标签: vhdl shift


    【解决方案1】:

    哪个工具报告了这个?

    Xilinx XST 报告

    barrel_shifter.vhd" Line 20: Actual for formal port data_in is neither a static 
    name nor a globally static expression
    

    这有助于确定问题,因为表达式std_logic_vector(unsigned(data_in) srl 1) 映射到多路复用器上的data_in。声明一个临时信号

    architecture Structural of barrel_shifter is
    
        signal q    : STD_LOGIC_VECTOR (N-1 downto 0);
        signal temp : STD_LOGIC_VECTOR (N-1 downto 0);
    begin
    
        temp <= std_logic_vector(unsigned(data_in) srl 1);
    
        connections: for i in 0 to N-1 generate
            mux: entity work.mux(Behavioral) generic map(N) 
                                             port map(temp, shift, q(i));
        end generate connections;
        ...
    end
    

    解决问题。

    【讨论】:

      猜你喜欢
      • 2015-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多