1 |
2 |
dimamali |
--------------------------------------------------------------------
|
2 |
|
|
-- Package: MultiIO
|
3 |
|
|
-- File: MultiIO.vhd
|
4 |
|
|
-- Author: Thomas Ameseder, Gleichmann Electronics
|
5 |
|
|
-- Based on an orginal version by Manfred.Helzle@embedd.it
|
6 |
|
|
--
|
7 |
|
|
-- Description: APB Multiple digital I/O Types and Components
|
8 |
|
|
--------------------------------------------------------------------
|
9 |
|
|
-- Functionality:
|
10 |
|
|
-- 8 LEDs, active low or high, r/w
|
11 |
|
|
-- dual 7Segment, active low or high, w only
|
12 |
|
|
-- 8 DIL Switches, active low or high, r only
|
13 |
|
|
-- 8 Buttons, active low or high, r only, with IRQ enables
|
14 |
|
|
--------------------------------------------------------------------
|
15 |
|
|
|
16 |
|
|
library ieee;
|
17 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
18 |
|
|
|
19 |
|
|
library grlib;
|
20 |
|
|
use grlib.amba.all;
|
21 |
|
|
|
22 |
|
|
package MultiIO is
|
23 |
|
|
|
24 |
|
|
-- maximum number of switches and LEDs
|
25 |
|
|
-- specific number that is used can be defined via a generic
|
26 |
|
|
constant N_SWITCHMAX : integer := 8;
|
27 |
|
|
constant N_LEDMAX : integer := 8;
|
28 |
|
|
|
29 |
|
|
constant N_BUTTONS : integer := 12; -- number of push-buttons
|
30 |
|
|
|
31 |
|
|
-- data width of the words for the codec configuration interface
|
32 |
|
|
constant N_CODECBITS : integer := 16;
|
33 |
|
|
|
34 |
|
|
-- data width of the words for the i2s digital samples
|
35 |
|
|
constant N_CODECI2SBITS : integer := 16;
|
36 |
|
|
|
37 |
|
|
-- the number of register bits that are assigned to the LCD
|
38 |
|
|
-- the enable control bit is set automatically
|
39 |
|
|
-- this constant should comprise the number of data bits as well
|
40 |
|
|
-- as the RW and RS control bits
|
41 |
|
|
constant N_LCDBITS : integer := 10;
|
42 |
|
|
|
43 |
|
|
-- number of bits to hold information for the (single/dual)
|
44 |
|
|
-- seven segment display;
|
45 |
|
|
constant N_SEVSEGBITS : integer := 16;
|
46 |
|
|
|
47 |
|
|
-- number of expansion connector i/o bits
|
48 |
|
|
constant N_EXPBITS : integer := 40;
|
49 |
|
|
|
50 |
|
|
-- number of high-speed connector bits per connector
|
51 |
|
|
constant N_HSCBITS : integer := 4;
|
52 |
|
|
|
53 |
|
|
-- number of childboard3 connector i/o bits
|
54 |
|
|
constant N_CB3 : integer := 32;
|
55 |
|
|
|
56 |
|
|
type asciichar_vect is array (16#30# to 16#46#) of character;
|
57 |
|
|
|
58 |
|
|
-- excerpt of the ASCII chart
|
59 |
|
|
constant ascii2char : asciichar_vect :=
|
60 |
|
|
-- -------------------------------------------
|
61 |
|
|
-- | 30 31 32 33 34 35 36 37 |
|
62 |
|
|
-- -------------------------------------------
|
63 |
|
|
('0', '1', '2', '3', '4', '5', '6', '7',
|
64 |
|
|
-- -------------------------------------------
|
65 |
|
|
-- | 38 39 3A 3B 3C 3D 3E 3F |
|
66 |
|
|
-- -------------------------------------------
|
67 |
|
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
68 |
|
|
-- -------------------------------------------
|
69 |
|
|
-- | 40 41 42 43 44 45 46 |
|
70 |
|
|
-- -------------------------------------------
|
71 |
|
|
'@', 'A', 'B', 'C', 'D', 'E', 'F');
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
---------------------------------------------------------------------------------------
|
75 |
|
|
-- AUDIO CODEC
|
76 |
|
|
---------------------------------------------------------------------------------------
|
77 |
|
|
|
78 |
|
|
subtype tReg is std_ulogic_vector(N_CODECBITS-1 downto 0);
|
79 |
|
|
|
80 |
|
|
type tRegMap is array(10 downto 0) of tReg;
|
81 |
|
|
subtype tRegData is std_ulogic_vector(8 downto 0);
|
82 |
|
|
subtype tRegAddr is std_ulogic_vector(6 downto 0);
|
83 |
|
|
|
84 |
|
|
-- ADDRESS
|
85 |
|
|
constant cAddrLLI : tRegAddr := "0000000"; -- Left line input channel volume control
|
86 |
|
|
constant cAddrRLI : tRegAddr := "0000001"; -- Right line input channel volume control
|
87 |
|
|
constant cAddrLCH : tRegAddr := "0000010"; -- Left channel headphone volume control
|
88 |
|
|
constant cAddrRCH : tRegAddr := "0000011"; -- Right channel headphone volume control
|
89 |
|
|
constant cAddrAAP : tRegAddr := "0000100"; -- Analog audio path control
|
90 |
|
|
constant cAddrDAP : tRegAddr := "0000101"; -- Digital audio path control
|
91 |
|
|
constant cAddrPDC : tRegAddr := "0000110"; -- Power down control
|
92 |
|
|
constant cAddrDAI : tRegAddr := "0000111"; -- Digital audio interface format
|
93 |
|
|
constant cAddrSRC : tRegAddr := "0001000"; -- Sample rate control
|
94 |
|
|
constant cAddrDIA : tRegAddr := "0001001"; -- Digital interface activation
|
95 |
|
|
constant cAddrReset : tRegAddr := "0001111"; -- Reset register
|
96 |
|
|
|
97 |
|
|
-- Data
|
98 |
|
|
constant cDataLLI : tRegData := "100011111";
|
99 |
|
|
constant cDataRLI : tRegData := "100011111";
|
100 |
|
|
constant cDataLCH : tRegData := "011111111";
|
101 |
|
|
constant cDataRCH : tRegData := "011111111";
|
102 |
|
|
constant cDataAAP : tRegData := "000011010";
|
103 |
|
|
constant cDataDAP : tRegData := "000000000";
|
104 |
|
|
constant cDataPDC : tRegData := "000001010";
|
105 |
|
|
constant cDataDAI : tRegData := "000000010";
|
106 |
|
|
constant cDataSRC : tRegData := "010000000";
|
107 |
|
|
constant cDataDIA : tRegData := "000000001";
|
108 |
|
|
constant cdataInit : tRegData := "000000000";
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
-- Register
|
112 |
|
|
constant cRegLLI : tReg := cAddrLLI & cDataLLI;
|
113 |
|
|
constant cRegRLI : tReg := cAddrRLI & cDataRLI;
|
114 |
|
|
constant cRegLCH : tReg := cAddrLCH & cDataLCH;
|
115 |
|
|
constant cRegRCH : tReg := cAddrRCH & cDataRCH;
|
116 |
|
|
constant cRegAAP : tReg := cAddrAAP & cDataAAP;
|
117 |
|
|
constant cRegDAP : tReg := cAddrDAP & cDataDAP;
|
118 |
|
|
constant cRegPDC : tReg := cAddrPDC & cDataPDC;
|
119 |
|
|
constant cRegDAI : tReg := cAddrDAI & cDataDAI;
|
120 |
|
|
constant cRegSRC : tReg := cAddrSRC & cDataSRC;
|
121 |
|
|
constant cRegDIA : tReg := cAddrDIA & cDataDIA;
|
122 |
|
|
constant cRegReset : tReg := CAddrReset & cdataInit;
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
-- Register Map
|
126 |
|
|
constant cregmap : tRegMap := (
|
127 |
|
|
|
128 |
|
|
1 => cRegRLI,
|
129 |
|
|
2 => cRegLCH,
|
130 |
|
|
3 => cRegRCH,
|
131 |
|
|
4 => cRegAAP,
|
132 |
|
|
5 => cRegDAP,
|
133 |
|
|
6 => cRegPDC,
|
134 |
|
|
7 => cRegDAI,
|
135 |
|
|
8 => cRegSRC,
|
136 |
|
|
9 => cRegDIA,
|
137 |
|
|
10 => cRegReset
|
138 |
|
|
);
|
139 |
|
|
|
140 |
|
|
---------------------------------------------------------------------------------------
|
141 |
|
|
|
142 |
|
|
type MultiIO_in_type is
|
143 |
|
|
record
|
144 |
|
|
switch_in : std_logic_vector(N_SWITCHMAX-1 downto 0); -- 8 DIL Switches
|
145 |
|
|
-- row input from the key matrix
|
146 |
|
|
row_in : std_logic_vector(3 downto 0);
|
147 |
|
|
|
148 |
|
|
-- expansion connector input bits
|
149 |
|
|
exp_in : std_logic_vector(N_EXPBITS/2-1 downto 0);
|
150 |
|
|
hsc_in : std_logic_vector(N_HSCBITS-1 downto 0);
|
151 |
|
|
|
152 |
|
|
-- childboard3 connector input bits
|
153 |
|
|
cb3_in : std_logic_vector(N_CB3-1 downto 0);
|
154 |
|
|
end record;
|
155 |
|
|
|
156 |
|
|
type MultiIO_out_type is
|
157 |
|
|
record
|
158 |
|
|
-- signals for the 7 segment display
|
159 |
|
|
-- data bits 0 to 7 of the LCD
|
160 |
|
|
-- LED signals for the Hpe_midi
|
161 |
|
|
led_a_out : std_logic;
|
162 |
|
|
led_b_out : std_logic;
|
163 |
|
|
led_c_out : std_logic;
|
164 |
|
|
led_d_out : std_logic;
|
165 |
|
|
led_e_out : std_logic;
|
166 |
|
|
led_f_out : std_logic;
|
167 |
|
|
led_g_out : std_logic;
|
168 |
|
|
led_dp_out : std_logic;
|
169 |
|
|
-- common anode for enabling left and/or right digit
|
170 |
|
|
-- data bit 7 for the LCD
|
171 |
|
|
led_ca_out : std_logic_vector(1 downto 0);
|
172 |
|
|
|
173 |
|
|
-- enable output to LED's for the Hpe_midi
|
174 |
|
|
led_enable : std_logic;
|
175 |
|
|
|
176 |
|
|
-- LCD-only control signals
|
177 |
|
|
lcd_regsel : std_logic;
|
178 |
|
|
lcd_rw : std_logic;
|
179 |
|
|
lcd_enable : std_logic;
|
180 |
|
|
|
181 |
|
|
-- LED register for all boards except the Hpe_midi
|
182 |
|
|
led_out : std_logic_vector(N_LEDMAX-1 downto 0); -- 8 LEDs
|
183 |
|
|
|
184 |
|
|
-- column output to the key matrix
|
185 |
|
|
column_out : std_logic_vector(2 downto 0);
|
186 |
|
|
|
187 |
|
|
-- signals for the SPI audio codec
|
188 |
|
|
codec_mode : std_ulogic;
|
189 |
|
|
codec_mclk : std_ulogic;
|
190 |
|
|
codec_sclk : std_ulogic;
|
191 |
|
|
codec_sdin : std_ulogic;
|
192 |
|
|
codec_cs : std_ulogic;
|
193 |
|
|
|
194 |
|
|
codec_din : std_ulogic; -- I2S format serial data input to the sigma-delta stereo DAC
|
195 |
|
|
codec_bclk : std_ulogic; -- I2S serial-bit clock
|
196 |
|
|
-- codec_dout : in std_ulogic; -- I2S format serial data output from the sigma-delta stereo ADC
|
197 |
|
|
codec_lrcin : std_ulogic; -- I2S DAC-word clock signal
|
198 |
|
|
codec_lrcout : std_ulogic; -- I2S ADC-word clock signal
|
199 |
|
|
|
200 |
|
|
-- expansion connector output bits
|
201 |
|
|
exp_out : std_logic_vector(N_EXPBITS/2-1 downto 0);
|
202 |
|
|
hsc_out : std_logic_vector(N_HSCBITS-1 downto 0);
|
203 |
|
|
|
204 |
|
|
-- childboard3 connector output bits
|
205 |
|
|
-- cb3_out : std_logic_vector(N_CB3-1 downto 0);
|
206 |
|
|
end record;
|
207 |
|
|
|
208 |
|
|
component MultiIO_APB
|
209 |
|
|
generic
|
210 |
|
|
(
|
211 |
|
|
hpe_version : integer := 0; -- adapt multiplexing for different boards
|
212 |
|
|
pindex : integer := 0; -- Leon-Index
|
213 |
|
|
paddr : integer := 0; -- Leon-Address
|
214 |
|
|
pmask : integer := 16#FFF#; -- Leon-Mask
|
215 |
|
|
pirq : integer := 0; -- Leon-IRQ
|
216 |
|
|
|
217 |
|
|
clk_freq_in : integer; -- Leons clock to calculate timings
|
218 |
|
|
|
219 |
|
|
led7act : std_logic := '0'; -- active level for 7Segment
|
220 |
|
|
ledact : std_logic := '0'; -- active level for LED's
|
221 |
|
|
switchact : std_logic := '1'; -- active level for LED's
|
222 |
|
|
buttonact : std_logic := '1'; -- active level for LED's
|
223 |
|
|
|
224 |
|
|
n_switches : integer := 8; -- number of switches
|
225 |
|
|
n_leds : integer := 8 -- number of LEDs
|
226 |
|
|
|
227 |
|
|
);
|
228 |
|
|
|
229 |
|
|
port (
|
230 |
|
|
rst_n : in std_ulogic; -- global Reset, active low
|
231 |
|
|
clk : in std_ulogic; -- global Clock
|
232 |
|
|
apbi : in apb_slv_in_type; -- APB-Input
|
233 |
|
|
apbo : out apb_slv_out_type; -- APB-Output
|
234 |
|
|
MultiIO_in : in MultiIO_in_type; -- MultIO-Inputs
|
235 |
|
|
MultiIO_out : out MultiIO_out_type -- MultiIO-Outputs
|
236 |
|
|
);
|
237 |
|
|
end component;
|
238 |
|
|
|
239 |
|
|
end package;
|