aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue660/testent.vhdl
blob: 8fa85ff38da7b4c5d152e09bce72fe4918449ec8 (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
library ieee;
	use ieee.std_logic_1164.all;
	use ieee.numeric_std.all;


entity test_core is
	generic (
		CONFIG_NUM_GPIO : natural := 2;
		GP_OFFSET : natural := 16
	);
	port (
		gpio         : inout unsigned(CONFIG_NUM_GPIO*16-1 downto 0);
		-- Inter-module connection wires for pin muxing: {
		gpio_in      : out std_logic_vector(CONFIG_NUM_GPIO*16-1 downto 0);
		gpio_out     : in  std_logic_vector(CONFIG_NUM_GPIO*16-1 downto 0);
		gpio_dir     : in  std_logic_vector(CONFIG_NUM_GPIO*16-1 downto 0)

	);
end entity;

architecture behaviour of test_core is

	constant num_pins : natural := CONFIG_NUM_GPIO*16;

	-- constant GP_OFFSET : natural := 16;

	subtype PORT_A_RANGE is natural range 16-1 downto 0;
	subtype PORT_B_RANGE is integer range GP_OFFSET+15 downto GP_OFFSET;

	signal io_read : std_logic_vector(num_pins-1 downto 0);
	signal out_int : std_logic_vector(num_pins-1 downto 0);
	signal io_dir  : std_logic_vector(num_pins-1 downto 0);

	alias out_b_int_mux : std_logic_vector(16-1 downto 0) is
		out_int(31 downto 16);

	alias iodir_b_mux : std_logic_vector(16-1 downto 0) is
		io_dir(PORT_B_RANGE);

	alias gpio_b_dir : std_logic_vector(16-1 downto 0) is
		gpio_dir(PORT_B_RANGE);

	alias gpio_b_out : std_logic_vector(16-1 downto 0) is
		gpio_out(PORT_B_RANGE);

	alias io_b_read : std_logic_vector(16-1 downto 0) is
		io_read(PORT_B_RANGE);

begin

gpio_direction:
	for i in 0 to num_pins-1 generate
		gpio(i) <= out_int(i) when io_dir(i) = '1' else 'Z';
	end generate;

	io_read <= std_logic_vector(gpio);
	gpio_in <= io_read;

mux_port_b:
	process (gpio_b_out, gpio_b_dir)
	begin
		-- default:
		out_b_int_mux <= gpio_b_out;
		iodir_b_mux   <= gpio_b_dir;


	end process;
end architecture;