Reverse bit order on VHDL

后端 未结 6 1030
闹比i
闹比i 2021-01-31 19:48

I\'m having trouble doing something like

b(0 to 7) <= a(7 downto 0)

when I compile it with ghdl, I have an order error. The only way I have

6条回答
  •  爱一瞬间的悲伤
    2021-01-31 20:27

    That's not allowed - VHDL is so strongly typed that if you want to reverse bit orders, you have to do it explicitly.

    The standard solution is to use a function (I didn't write this - Jonathan Bromley did):

    function reverse_any_vector (a: in std_logic_vector)
    return std_logic_vector is
      variable result: std_logic_vector(a'RANGE);
      alias aa: std_logic_vector(a'REVERSE_RANGE) is a;
    begin
      for i in aa'RANGE loop
        result(i) := aa(i);
      end loop;
      return result;
    end; -- function reverse_any_vector
    

提交回复
热议问题