| 1 |
3 |
Andrewski |
--------------------------------------------------------------------------------
|
| 2 |
13 |
Andrewski |
--This file is part of fpga_gpib_controller.
|
| 3 |
|
|
--
|
| 4 |
|
|
-- Fpga_gpib_controller is free software: you can redistribute it and/or modify
|
| 5 |
|
|
-- it under the terms of the GNU General Public License as published by
|
| 6 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
| 7 |
|
|
-- (at your option) any later version.
|
| 8 |
|
|
--
|
| 9 |
|
|
-- Fpga_gpib_controller is distributed in the hope that it will be useful,
|
| 10 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
|
|
-- GNU General Public License for more details.
|
| 13 |
|
|
|
| 14 |
|
|
-- You should have received a copy of the GNU General Public License
|
| 15 |
|
|
-- along with Fpga_gpib_controller. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
|
|
--------------------------------------------------------------------------------
|
| 17 |
3 |
Andrewski |
-- Entity: RegMultiplexer
|
| 18 |
|
|
-- Date:2011-11-14
|
| 19 |
13 |
Andrewski |
-- Author: Andrzej Paluch
|
| 20 |
3 |
Andrewski |
--
|
| 21 |
|
|
-- Description ${cursor}
|
| 22 |
|
|
--------------------------------------------------------------------------------
|
| 23 |
|
|
library ieee;
|
| 24 |
|
|
use ieee.std_logic_1164.all;
|
| 25 |
|
|
use ieee.std_logic_unsigned.all;
|
| 26 |
|
|
use ieee.std_logic_arith.all;
|
| 27 |
|
|
|
| 28 |
|
|
|
| 29 |
|
|
entity RegMultiplexer is
|
| 30 |
|
|
generic (
|
| 31 |
|
|
ADDR_WIDTH : integer := 15
|
| 32 |
|
|
);
|
| 33 |
|
|
port (
|
| 34 |
|
|
strobe_read : in std_logic;
|
| 35 |
|
|
strobe_write : in std_logic;
|
| 36 |
|
|
data_in : in std_logic_vector (15 downto 0);
|
| 37 |
|
|
data_out : out std_logic_vector (15 downto 0);
|
| 38 |
|
|
--------------------------------------------------------
|
| 39 |
|
|
reg_addr : in std_logic_vector((ADDR_WIDTH-1) downto 0);
|
| 40 |
|
|
--------------------------------------------------------
|
| 41 |
|
|
reg_strobe_0 : out std_logic;
|
| 42 |
|
|
reg_in_0 : out std_logic_vector (15 downto 0);
|
| 43 |
|
|
reg_out_0 : in std_logic_vector (15 downto 0);
|
| 44 |
|
|
|
| 45 |
|
|
reg_strobe_1 : out std_logic;
|
| 46 |
|
|
reg_in_1 : out std_logic_vector (15 downto 0);
|
| 47 |
|
|
reg_out_1 : in std_logic_vector (15 downto 0);
|
| 48 |
|
|
|
| 49 |
|
|
reg_strobe_2 : out std_logic;
|
| 50 |
|
|
reg_in_2 : out std_logic_vector (15 downto 0);
|
| 51 |
|
|
reg_out_2 : in std_logic_vector (15 downto 0);
|
| 52 |
|
|
|
| 53 |
|
|
reg_strobe_3 : out std_logic;
|
| 54 |
|
|
reg_in_3 : out std_logic_vector (15 downto 0);
|
| 55 |
|
|
reg_out_3 : in std_logic_vector (15 downto 0);
|
| 56 |
|
|
|
| 57 |
|
|
reg_strobe_4 : out std_logic;
|
| 58 |
|
|
reg_in_4 : out std_logic_vector (15 downto 0);
|
| 59 |
|
|
reg_out_4 : in std_logic_vector (15 downto 0);
|
| 60 |
|
|
|
| 61 |
|
|
reg_strobe_5 : out std_logic;
|
| 62 |
|
|
reg_in_5 : out std_logic_vector (15 downto 0);
|
| 63 |
|
|
reg_out_5 : in std_logic_vector (15 downto 0);
|
| 64 |
|
|
|
| 65 |
|
|
reg_strobe_6 : out std_logic;
|
| 66 |
|
|
reg_in_6 : out std_logic_vector (15 downto 0);
|
| 67 |
|
|
reg_out_6 : in std_logic_vector (15 downto 0);
|
| 68 |
|
|
|
| 69 |
|
|
reg_strobe_7 : out std_logic;
|
| 70 |
|
|
reg_in_7 : out std_logic_vector (15 downto 0);
|
| 71 |
|
|
reg_out_7 : in std_logic_vector (15 downto 0);
|
| 72 |
|
|
|
| 73 |
|
|
reg_strobe_8 : out std_logic;
|
| 74 |
|
|
reg_in_8 : out std_logic_vector (15 downto 0);
|
| 75 |
|
|
reg_out_8 : in std_logic_vector (15 downto 0);
|
| 76 |
|
|
|
| 77 |
|
|
reg_strobe_9 : out std_logic;
|
| 78 |
|
|
reg_in_9 : out std_logic_vector (15 downto 0);
|
| 79 |
|
|
reg_out_9 : in std_logic_vector (15 downto 0);
|
| 80 |
|
|
|
| 81 |
|
|
reg_strobe_10 : out std_logic;
|
| 82 |
|
|
reg_in_10 : out std_logic_vector (15 downto 0);
|
| 83 |
|
|
reg_out_10 : in std_logic_vector (15 downto 0);
|
| 84 |
|
|
|
| 85 |
|
|
reg_strobe_11 : out std_logic;
|
| 86 |
|
|
reg_in_11 : out std_logic_vector (15 downto 0);
|
| 87 |
|
|
reg_out_11 : in std_logic_vector (15 downto 0);
|
| 88 |
|
|
|
| 89 |
|
|
reg_strobe_other0 : out std_logic;
|
| 90 |
|
|
reg_in_other0 : out std_logic_vector (15 downto 0);
|
| 91 |
|
|
reg_out_other0 : in std_logic_vector (15 downto 0);
|
| 92 |
|
|
|
| 93 |
|
|
reg_strobe_other1 : out std_logic;
|
| 94 |
|
|
reg_in_other1 : out std_logic_vector (15 downto 0);
|
| 95 |
|
|
reg_out_other1 : in std_logic_vector (15 downto 0)
|
| 96 |
|
|
);
|
| 97 |
|
|
end RegMultiplexer;
|
| 98 |
|
|
|
| 99 |
|
|
architecture arch of RegMultiplexer is
|
| 100 |
|
|
|
| 101 |
|
|
constant REG_COUNT : integer := 14;
|
| 102 |
|
|
constant MAX_ADDR : integer := (2**ADDR_WIDTH - 1);
|
| 103 |
|
|
|
| 104 |
|
|
type SIGNAL_VECTOR is array ((REG_COUNT-1) downto 0) of std_logic;
|
| 105 |
|
|
type BUS_VECTOR is array ((REG_COUNT-1) downto 0) of
|
| 106 |
|
|
std_logic_vector (15 downto 0);
|
| 107 |
|
|
|
| 108 |
|
|
signal cur_reg_num : integer range 0 to 13;
|
| 109 |
|
|
signal dec_addr : integer range MAX_ADDR downto 0;
|
| 110 |
|
|
|
| 111 |
|
|
signal inputs : BUS_VECTOR;
|
| 112 |
|
|
signal outputs : BUS_VECTOR;
|
| 113 |
|
|
signal strobes : SIGNAL_VECTOR;
|
| 114 |
|
|
|
| 115 |
|
|
begin
|
| 116 |
|
|
|
| 117 |
|
|
(reg_strobe_other1, reg_strobe_other0, reg_strobe_11, reg_strobe_10,
|
| 118 |
|
|
reg_strobe_9, reg_strobe_8, reg_strobe_7, reg_strobe_6, reg_strobe_5,
|
| 119 |
|
|
reg_strobe_4, reg_strobe_3, reg_strobe_2, reg_strobe_1,
|
| 120 |
|
|
reg_strobe_0) <= strobes;
|
| 121 |
|
|
|
| 122 |
|
|
(reg_in_other1, reg_in_other0, reg_in_11, reg_in_10, reg_in_9, reg_in_8,
|
| 123 |
|
|
reg_in_7, reg_in_6, reg_in_5, reg_in_4, reg_in_3, reg_in_2, reg_in_1,
|
| 124 |
|
|
reg_in_0) <= inputs;
|
| 125 |
|
|
|
| 126 |
|
|
outputs <= (reg_out_other1, reg_out_other0, reg_out_11, reg_out_10,
|
| 127 |
|
|
reg_out_9, reg_out_8, reg_out_7, reg_out_6, reg_out_5, reg_out_4,
|
| 128 |
|
|
reg_out_3, reg_out_2, reg_out_1, reg_out_0);
|
| 129 |
|
|
|
| 130 |
|
|
dec_addr <= conv_integer(reg_addr);
|
| 131 |
|
|
|
| 132 |
|
|
process (dec_addr) begin
|
| 133 |
|
|
if dec_addr >= 0 and dec_addr < (REG_COUNT-2) then
|
| 134 |
|
|
cur_reg_num <= dec_addr;
|
| 135 |
|
|
elsif dec_addr = (REG_COUNT-2) then
|
| 136 |
|
|
cur_reg_num <= 12;
|
| 137 |
|
|
else
|
| 138 |
|
|
cur_reg_num <= 13;
|
| 139 |
|
|
end if;
|
| 140 |
|
|
end process;
|
| 141 |
|
|
|
| 142 |
|
|
process (strobe_read, strobe_write, data_in, outputs, cur_reg_num) begin
|
| 143 |
|
|
|
| 144 |
|
|
strobes <= (others => '0');
|
| 145 |
|
|
inputs <= (others => (others => '0'));
|
| 146 |
|
|
data_out <= (others => '0');
|
| 147 |
|
|
|
| 148 |
|
|
if cur_reg_num < REG_COUNT then
|
| 149 |
|
|
if cur_reg_num = 12 then
|
| 150 |
|
|
strobes(cur_reg_num) <= strobe_read;
|
| 151 |
|
|
else
|
| 152 |
|
|
strobes(cur_reg_num) <= strobe_write;
|
| 153 |
|
|
end if;
|
| 154 |
|
|
|
| 155 |
|
|
inputs(cur_reg_num) <= data_in;
|
| 156 |
|
|
data_out <= outputs(cur_reg_num);
|
| 157 |
|
|
end if;
|
| 158 |
|
|
end process;
|
| 159 |
|
|
|
| 160 |
|
|
end arch;
|
| 161 |
|
|
|