OpenCores
URL https://opencores.org/ocsvn/gpib_controller/gpib_controller/trunk

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [wrapper/] [RegMultiplexer.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2
-- Entity: RegMultiplexer
3
-- Date:2011-11-14  
4
-- Author: apaluch     
5
--
6
-- Description ${cursor}
7
--------------------------------------------------------------------------------
8
library ieee;
9
use ieee.std_logic_1164.all;
10
use ieee.std_logic_unsigned.all;
11
use ieee.std_logic_arith.all;
12
 
13
 
14
entity RegMultiplexer is
15
        generic (
16
                ADDR_WIDTH : integer := 15
17
        );
18
        port (
19
                strobe_read : in std_logic;
20
                strobe_write : in std_logic;
21
                data_in : in std_logic_vector (15 downto 0);
22
                data_out : out std_logic_vector (15 downto 0);
23
                --------------------------------------------------------
24
                reg_addr : in std_logic_vector((ADDR_WIDTH-1) downto 0);
25
                --------------------------------------------------------
26
                reg_strobe_0 : out std_logic;
27
                reg_in_0 : out std_logic_vector (15 downto 0);
28
                reg_out_0 : in std_logic_vector (15 downto 0);
29
 
30
                reg_strobe_1 : out std_logic;
31
                reg_in_1 : out std_logic_vector (15 downto 0);
32
                reg_out_1 : in std_logic_vector (15 downto 0);
33
 
34
                reg_strobe_2 : out std_logic;
35
                reg_in_2 : out std_logic_vector (15 downto 0);
36
                reg_out_2 : in std_logic_vector (15 downto 0);
37
 
38
                reg_strobe_3 : out std_logic;
39
                reg_in_3 : out std_logic_vector (15 downto 0);
40
                reg_out_3 : in std_logic_vector (15 downto 0);
41
 
42
                reg_strobe_4 : out std_logic;
43
                reg_in_4 : out std_logic_vector (15 downto 0);
44
                reg_out_4 : in std_logic_vector (15 downto 0);
45
 
46
                reg_strobe_5 : out std_logic;
47
                reg_in_5 : out std_logic_vector (15 downto 0);
48
                reg_out_5 : in std_logic_vector (15 downto 0);
49
 
50
                reg_strobe_6 : out std_logic;
51
                reg_in_6 : out std_logic_vector (15 downto 0);
52
                reg_out_6 : in std_logic_vector (15 downto 0);
53
 
54
                reg_strobe_7 : out std_logic;
55
                reg_in_7 : out std_logic_vector (15 downto 0);
56
                reg_out_7 : in std_logic_vector (15 downto 0);
57
 
58
                reg_strobe_8 : out std_logic;
59
                reg_in_8 : out std_logic_vector (15 downto 0);
60
                reg_out_8 : in std_logic_vector (15 downto 0);
61
 
62
                reg_strobe_9 : out std_logic;
63
                reg_in_9 : out std_logic_vector (15 downto 0);
64
                reg_out_9 : in std_logic_vector (15 downto 0);
65
 
66
                reg_strobe_10 : out std_logic;
67
                reg_in_10 : out std_logic_vector (15 downto 0);
68
                reg_out_10 : in std_logic_vector (15 downto 0);
69
 
70
                reg_strobe_11 : out std_logic;
71
                reg_in_11 : out std_logic_vector (15 downto 0);
72
                reg_out_11 : in std_logic_vector (15 downto 0);
73
 
74
                reg_strobe_other0 : out std_logic;
75
                reg_in_other0 : out std_logic_vector (15 downto 0);
76
                reg_out_other0 : in std_logic_vector (15 downto 0);
77
 
78
                reg_strobe_other1 : out std_logic;
79
                reg_in_other1 : out std_logic_vector (15 downto 0);
80
                reg_out_other1 : in std_logic_vector (15 downto 0)
81
        );
82
end RegMultiplexer;
83
 
84
architecture arch of RegMultiplexer is
85
 
86
        constant REG_COUNT : integer := 14;
87
        constant MAX_ADDR : integer := (2**ADDR_WIDTH - 1);
88
 
89
        type SIGNAL_VECTOR is array ((REG_COUNT-1) downto 0) of std_logic;
90
        type BUS_VECTOR is array ((REG_COUNT-1) downto 0) of
91
                std_logic_vector (15 downto 0);
92
 
93
        signal cur_reg_num : integer range 0 to 13;
94
        signal dec_addr : integer range MAX_ADDR downto 0;
95
 
96
        signal inputs : BUS_VECTOR;
97
        signal outputs : BUS_VECTOR;
98
        signal strobes : SIGNAL_VECTOR;
99
 
100
begin
101
 
102
        (reg_strobe_other1, reg_strobe_other0, reg_strobe_11, reg_strobe_10,
103
        reg_strobe_9, reg_strobe_8, reg_strobe_7, reg_strobe_6, reg_strobe_5,
104
        reg_strobe_4, reg_strobe_3, reg_strobe_2, reg_strobe_1,
105
        reg_strobe_0) <= strobes;
106
 
107
        (reg_in_other1, reg_in_other0, reg_in_11, reg_in_10, reg_in_9, reg_in_8,
108
        reg_in_7, reg_in_6, reg_in_5, reg_in_4, reg_in_3, reg_in_2, reg_in_1,
109
        reg_in_0) <= inputs;
110
 
111
        outputs <= (reg_out_other1, reg_out_other0, reg_out_11, reg_out_10,
112
                reg_out_9, reg_out_8, reg_out_7, reg_out_6, reg_out_5, reg_out_4,
113
                reg_out_3, reg_out_2, reg_out_1, reg_out_0);
114
 
115
        dec_addr <= conv_integer(reg_addr);
116
 
117
        process (dec_addr) begin
118
                if dec_addr >= 0 and dec_addr < (REG_COUNT-2) then
119
                        cur_reg_num <= dec_addr;
120
                elsif dec_addr = (REG_COUNT-2) then
121
                        cur_reg_num <= 12;
122
                else
123
                        cur_reg_num <= 13;
124
                end if;
125
        end process;
126
 
127
        process (strobe_read, strobe_write, data_in, outputs, cur_reg_num) begin
128
 
129
                strobes <= (others => '0');
130
                inputs <= (others => (others => '0'));
131
                data_out <= (others => '0');
132
 
133
                if cur_reg_num < REG_COUNT then
134
                        if cur_reg_num = 12 then
135
                                strobes(cur_reg_num) <= strobe_read;
136
                        else
137
                                strobes(cur_reg_num) <= strobe_write;
138
                        end if;
139
 
140
                        inputs(cur_reg_num) <= data_in;
141
                        data_out <= outputs(cur_reg_num);
142
                end if;
143
        end process;
144
 
145
end arch;
146
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.