首页 文章

以不同方式连接STD_LOGIC_VECTOR(Barrel Shifter) - VHDL

提问于
浏览
0

我正在实现一个N-bit Barrel Shifter .

这是我的组成部分:

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(带有通用的 Map 构造),所以我无法手动连接每根线,因为我不知道通用N的值 .

在我的barrel_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);

但我仍然无法找到正确的方法来进行这些连接 .

1 回答

  • 2

    哪个工具报告此内容?

    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
    

    解决了这个问题 .

相关问题