aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/bug042/centerconfig_generics_works.vhdl
blob: 716784a43195b6c960afaf1a24e9e8d06315c6a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
library ieee;
use ieee.std_logic_1164.all;

entity CenterConfig is
    generic (
        -- Width of S_AXI data bus
        C_S_AXI_DATA_WIDTH  : integer   := 32;
        -- Width of S_AXI address bus
        C_S_AXI_ADDR_WIDTH  : integer   := 4
    );
    port (
        center_height: out std_logic_vector(C_S_AXI_DATA_WIDTH - 1 downto 0);
        center_width: out std_logic_vector(C_S_AXI_DATA_WIDTH - 1 downto 0)
    );
end entity CenterConfig;

architecture foo of centerconfig is
    
begin
end architecture;

library ieee;
use ieee.std_logic_1164.all;

entity instance is
    generic (
           CENTERHEIGHT: integer := 32; -- 16;
           CENTERWIDTH:  integer := 32;  -- 16
           C_S_AXI_DATA_WIDTH: integer   := 32;
           C_S_AXI_ADDR_WIDTH: integer   := 4
    );
end entity;

architecture fum of instance is
    -- constant CENTERHEIGHT: integer := 32;   -- 16;
    -- constant  CENTERWIDTH:  integer := 32;  -- 16;
    -- constant C_S_AXI_DATA_WIDTH: integer   := 32;
    -- constant C_S_AXI_ADDR_WIDTH: integer   := 4;
    component centerconfig is
        generic (
            C_S_AXI_DATA_WIDTH  : integer   := 32;
            C_S_AXI_ADDR_WIDTH  : integer   := 4
        );
        port (
            center_height: 
                out std_logic_vector(C_S_AXI_DATA_WIDTH - 1 downto 0);
            center_width: 
                out std_logic_vector(C_S_AXI_DATA_WIDTH - 1 downto 0)
        );
    end component;
    signal std_center_height: std_logic_vector (CENTERHEIGHT - 1  downto 0);
    signal std_center_width: std_logic_vector (CENTERWIDTH - 1 downto 0);
begin
    
Config: 
    CenterConfig 
        generic map (
            C_S_AXI_DATA_WIDTH => C_S_AXI_DATA_WIDTH,
            C_S_AXI_ADDR_WIDTH => C_S_AXI_ADDR_WIDTH
        )
        port map (
            --center_height(std_center_height'range) => std_center_height,
            center_height(std_center_height'LEFT downto 
                          std_center_height'RIGHT) => std_center_height,
            -- center_height(C_S_AXI_DATA_WIDTH-1 downto std_center_height'length) => open, 
            -- not working, not elegant

            -- center_width(std_center_width'range) => std_center_width
            center_width(std_center_width'LEFT downto 
                         std_center_width'RIGHT) => std_center_width
        );
    
end architecture;