Use a generic to determine (de)mux size in VHDL?

后端 未结 3 925
走了就别回头了
走了就别回头了 2021-01-20 03:39

I want to use a generic \'p\' to define how many outputs a demux will have. Input and all outputs are 1 bit. The outputs, control, and input can be something simple like:<

3条回答
  •  一向
    一向 (楼主)
    2021-01-20 03:53

    You need to feed log_p as generic and compute p as you go.

    library ieee;
    use ieee.std_logic_1164.all;
    entity demux is
        generic (
            log_p: integer);
        port(
            control : in std_logic_vector(log_p downto 0);
            input :in std_logic;
            outputs : out std_logic_vector(2**log_p - 1 downto 0)
            );
    end entity demux;
    

提交回复
热议问题