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

Subversion Repositories sio

[/] [sio/] [trunk/] [rtl/] [sio_logic.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 buenos
-- Super-I/O Logic Istvan Nagy 2019 09 15
2
----------------------------------------------------------------------------------
3
-- A multiplexer logic block to create a super-I/O IP compatible with x86 systems.
4
-- A replacement for a chip like the Microchip SCH3227.
5
--  The LPC IP has a 32bit wishbone bus, but only lower 8bits used for SIO access, with 8bit LPC cycles.
6
-- Files from other projects needed:
7
--  - UART below this module: https://opencores.org/projects/uart16550
8
--     For the UART, use the 33MHz compliant version regs file: uart_regs_33m.v
9
--     In uart_defines.v uncomment the "`define DATA_BUS_WIDTH_8"
10
--  - PS2 below this module: http://www.opencores.org/projects/ps2/ 
11
--     In the ps2_defines, uncomment `define PS2_AUX to enble the keyboard
12
--  - LPC slave: https://opencores.org/projects/wb_lpc
13
--     Use these files: wb_lpc_periph.v, wb_lpc_defines.v, serirq_defines.v, serirq_slave.v
14
--     Some of the files had references, that needs rewriting to remove relative path: `include "wb_lpc_defines.v"
15
--     In wb_lpc_periph.v change a line: always @(posedge clk_i or negedge nrst_i) ===> always @(posedge clk_i) 
16
--  - Write your own device-top level file, instantiating/connecting the LPC and SIO.
17
-- Address range:
18
--  - COM1: 3F8-3FFh
19
--  - COM2: 2F8-2FFh
20
--  - COM3: 3E8-3EFh
21
--  - COM4: 2E8-2EFh
22
--  - PS2:  60h AND 64h
23
--  - post-code:  80h AND 81h
24
--  - Custom board logic registers: 200h...207h (r/w regs connect in/out outside, ro regs out NC)
25
----------------------------------------------------------------------------------
26
library IEEE;
27
use IEEE.STD_LOGIC_1164.ALL;
28
use IEEE.STD_LOGIC_ARITH.ALL;
29
use IEEE.STD_LOGIC_UNSIGNED.ALL;
30
--entity header  ----------------------------------------------------------------
31
entity sio_logic is
32
Port (  clk : in std_logic; --33.333MHz LPC or PCI-bus-derived clock
33
        reset_n  : in std_logic;
34
        wbm_adr_i  : in std_logic_vector(31 downto 0);
35
        wbm_dat_i  : in std_logic_vector(31 downto 0);
36
        wbm_dat_o  : out std_logic_vector(31 downto 0);
37
        wbm_sel_i  : in std_logic_vector(3 downto 0);
38
        wbm_tga_i  : in std_logic_vector(1 downto 0);
39
        wbm_we_i  : in std_logic;
40
        wbm_stb_i  : in std_logic;
41
        wbm_cyc_i  : in std_logic;
42
        wbm_ack_o  : out std_logic;
43
        wbm_err_o  : out std_logic;
44
        register_0_out   : out std_logic_vector(7 downto 0);
45
        register_0_in   : in std_logic_vector(7 downto 0);
46
        register_1_out   : out std_logic_vector(7 downto 0);
47
        register_1_in   : in std_logic_vector(7 downto 0);
48
        register_2_out   : out std_logic_vector(7 downto 0);
49
        register_2_in   : in std_logic_vector(7 downto 0);
50
        register_3_out   : out std_logic_vector(7 downto 0);
51
        register_3_in   : in std_logic_vector(7 downto 0);
52
        register_4_out   : out std_logic_vector(7 downto 0);
53
        register_4_in   : in std_logic_vector(7 downto 0);
54
        register_5_out   : out std_logic_vector(7 downto 0);
55
        register_5_in   : in std_logic_vector(7 downto 0);
56
        register_6_out   : out std_logic_vector(7 downto 0);
57
        register_6_in   : in std_logic_vector(7 downto 0);
58
        register_7_out   : out std_logic_vector(7 downto 0);
59
        register_7_in   : in std_logic_vector(7 downto 0);
60
        port80   : out std_logic_vector(7 downto 0);
61
        port81   : out std_logic_vector(7 downto 0);
62
        --kb_rstout: out std_logic;
63
        serial1_tx: out std_logic; serial1_rx: in std_logic; serial1_rts: out std_logic; serial1_cts: in std_logic; serial1_dtr: out std_logic; serial1_dsr: in std_logic; serial1_ri: in std_logic; serial1_dcd: in std_logic;
64
        serial2_tx: out std_logic; serial2_rx: in std_logic; serial2_rts: out std_logic; serial2_cts: in std_logic; serial2_dtr: out std_logic; serial2_dsr: in std_logic; serial2_ri: in std_logic; serial2_dcd: in std_logic;
65
        serial3_tx: out std_logic; serial3_rx: in std_logic; serial3_rts: out std_logic; serial3_cts: in std_logic; serial3_dtr: out std_logic; serial3_dsr: in std_logic; serial3_ri: in std_logic; serial3_dcd: in std_logic;
66
        serial4_tx: out std_logic; serial4_rx: in std_logic; serial4_rts: out std_logic; serial4_cts: in std_logic; serial4_dtr: out std_logic; serial4_dsr: in std_logic; serial4_ri: in std_logic; serial4_dcd: in std_logic;
67
        ps2_kbd_clk_pad_oe_o: out std_logic; ps2_kbd_clk_pad_o: out std_logic; ps2_kbd_data_pad_oe_o: out std_logic; ps2_kbd_data_pad_o: out std_logic;
68
        ps2_aux_clk_pad_oe_o: out std_logic; ps2_aux_clk_pad_o: out std_logic; ps2_aux_data_pad_oe_o: out std_logic; ps2_aux_data_pad_o: out std_logic;
69
        ps2_kbd_clk_pad_i: in std_logic; ps2_kbd_data_pad_i: in std_logic; ps2_aux_clk_pad_i : in std_logic; ps2_aux_data_pad_i: in std_logic
70
);
71
end sio_logic;
72
--architecture start ------------------------------------------------------------
73
architecture Behavioral of sio_logic is
74
 
75
--INTERNAL SIGNALS -------------------------------------------------------------
76
SIGNAL   serial1_wb_adr_i: std_logic_VECTOR(2 downto 0);
77
SIGNAL   serial1_wb_dat_i: std_logic_VECTOR(7 downto 0);
78
SIGNAL   serial1_wb_dat_o: std_logic_VECTOR(7 downto 0);
79
SIGNAL   serial1_wb_we: std_logic;
80
SIGNAL   serial1_wb_stb: std_logic;
81
SIGNAL   serial1_wb_cyc: std_logic;
82
SIGNAL   serial1_wb_ack_o: std_logic;
83
SIGNAL   serial1_wb_sel_i: std_logic_VECTOR(3 downto 0);
84
SIGNAL   serial1_int_o: std_logic;
85
SIGNAL   serial2_wb_adr_i: std_logic_VECTOR(2 downto 0);
86
SIGNAL   serial2_wb_dat_i: std_logic_VECTOR(7 downto 0);
87
SIGNAL   serial2_wb_dat_o: std_logic_VECTOR(7 downto 0);
88
SIGNAL   serial2_wb_we: std_logic;
89
SIGNAL   serial2_wb_stb: std_logic;
90
SIGNAL   serial2_wb_cyc: std_logic;
91
SIGNAL   serial2_wb_ack_o: std_logic;
92
SIGNAL   serial2_wb_sel_i: std_logic_VECTOR(3 downto 0);
93
SIGNAL   serial2_int_o: std_logic;
94
SIGNAL   serial3_wb_adr_i: std_logic_VECTOR(2 downto 0);
95
SIGNAL   serial3_wb_dat_i: std_logic_VECTOR(7 downto 0);
96
SIGNAL   serial3_wb_dat_o: std_logic_VECTOR(7 downto 0);
97
SIGNAL   serial3_wb_we: std_logic;
98
SIGNAL   serial3_wb_stb: std_logic;
99
SIGNAL   serial3_wb_cyc: std_logic;
100
SIGNAL   serial3_wb_ack_o: std_logic;
101
SIGNAL   serial3_wb_sel_i: std_logic_VECTOR(3 downto 0);
102
SIGNAL   serial3_int_o: std_logic;
103
SIGNAL   serial4_wb_adr_i: std_logic_VECTOR(2 downto 0);
104
SIGNAL   serial4_wb_dat_i: std_logic_VECTOR(7 downto 0);
105
SIGNAL   serial4_wb_dat_o: std_logic_VECTOR(7 downto 0);
106
SIGNAL   serial4_wb_we: std_logic;
107
SIGNAL   serial4_wb_stb: std_logic;
108
SIGNAL   serial4_wb_cyc: std_logic;
109
SIGNAL   serial4_wb_ack_o: std_logic;
110
SIGNAL   serial4_wb_sel_i: std_logic_VECTOR(3 downto 0);
111
SIGNAL   serial4_int_o: std_logic;
112
SIGNAL   ps2_wb_cyc: std_logic;
113
SIGNAL   ps2_wb_stb: std_logic;
114
SIGNAL   ps2_wb_we: std_logic;
115
SIGNAL   ps2_wb_sel_i: std_logic_VECTOR(3 downto 0);
116
SIGNAL   ps2_wb_adr_i: std_logic_VECTOR(3 downto 0);
117
SIGNAL   ps2_wb_dat_i: std_logic_VECTOR(31 downto 0);
118
SIGNAL   ps2_wb_dat_o: std_logic_VECTOR(31 downto 0);
119
SIGNAL   ps2_wb_ack_o : std_logic;
120
SIGNAL   ps2_wb_int_o: std_logic;
121
SIGNAL   ps2_wb_intb_o: std_logic;
122
SIGNAL  offset_reg  : std_logic_VECTOR(7 downto 0);
123
SIGNAL  device_reg  : std_logic_VECTOR(7 downto 0);
124
SIGNAL  reset_activehigh : std_logic;
125
 
126
 
127
 
128
---------COMPONENT DECLARATIONS (introducing the IPs) ----------------------------
129
        COMPONENT uart_top
130
        PORT(
131
                wb_clk_i : IN std_logic;
132
                wb_rst_i : IN std_logic;
133
                wb_adr_i : IN std_logic_vector(2 downto 0);
134
                wb_dat_i : IN std_logic_vector(7 downto 0);
135
                wb_we_i : IN std_logic;
136
                wb_stb_i : IN std_logic;
137
                wb_cyc_i : IN std_logic;
138
                wb_sel_i : IN std_logic_vector(3 downto 0);
139
                srx_pad_i : IN std_logic;
140
                cts_pad_i : IN std_logic;
141
                dsr_pad_i : IN std_logic;
142
                ri_pad_i : IN std_logic;
143
                dcd_pad_i : IN std_logic;
144
                wb_dat_o : OUT std_logic_vector(7 downto 0);
145
                wb_ack_o : OUT std_logic;
146
                int_o : OUT std_logic;
147
                stx_pad_o : OUT std_logic;
148
                rts_pad_o : OUT std_logic;
149
                dtr_pad_o : OUT std_logic
150
                );
151
        END COMPONENT;
152
        COMPONENT ps2_top
153
        PORT(
154
                wb_clk_i : IN std_logic;
155
                wb_rst_i : IN std_logic;
156
                wb_cyc_i : IN std_logic;
157
                wb_stb_i : IN std_logic;
158
                wb_we_i : IN std_logic;
159
                wb_sel_i : IN std_logic_vector(3 downto 0);
160
                wb_adr_i : IN std_logic_vector(3 downto 0);
161
                wb_dat_i : IN std_logic_vector(31 downto 0);
162
                ps2_kbd_clk_pad_i : IN std_logic;
163
                ps2_kbd_data_pad_i : IN std_logic;
164
                ps2_aux_clk_pad_i : IN std_logic;
165
                ps2_aux_data_pad_i : IN std_logic;
166
                wb_dat_o : OUT std_logic_vector(31 downto 0);
167
                wb_ack_o : OUT std_logic;
168
                wb_int_o : OUT std_logic;
169
                --kb_rstout : OUT std_logic;
170
                ps2_kbd_clk_pad_o : OUT std_logic;
171
                ps2_kbd_data_pad_o : OUT std_logic;
172
                ps2_kbd_clk_pad_oe_o : OUT std_logic;
173
                ps2_kbd_data_pad_oe_o : OUT std_logic;
174
                wb_intb_o : OUT std_logic;
175
                ps2_aux_clk_pad_o : OUT std_logic;
176
                ps2_aux_data_pad_o : OUT std_logic;
177
                ps2_aux_clk_pad_oe_o : OUT std_logic;
178
                ps2_aux_data_pad_oe_o : OUT std_logic
179
                );
180
        END COMPONENT;
181
 
182
--architecture body start -------------------------------------------------------
183
begin
184
---------COMPONENT INSTALLATIONS (connecting the IPs to local signals) ---------
185
        Inst_uart1_top: uart_top PORT MAP(
186
                wb_clk_i => clk,
187
                wb_rst_i => reset_activehigh,
188
                wb_adr_i => serial1_wb_adr_i(2 downto 0),
189
                wb_dat_i => serial1_wb_dat_i,
190
                wb_dat_o => serial1_wb_dat_o,
191
                wb_we_i => serial1_wb_we,
192
                wb_stb_i => serial1_wb_stb,
193
                wb_cyc_i => serial1_wb_cyc,
194
                wb_ack_o => serial1_wb_ack_o,
195
                wb_sel_i => serial1_wb_sel_i,
196
                int_o => serial1_int_o,
197
                stx_pad_o => serial1_tx,
198
                srx_pad_i => serial1_rx,
199
                rts_pad_o => serial1_rts,
200
                cts_pad_i => serial1_cts,
201
                dtr_pad_o => serial1_dtr,
202
                dsr_pad_i => serial1_dsr,
203
                ri_pad_i => serial1_ri,
204
                dcd_pad_i => serial1_dcd
205
        );
206
        Inst_uart2_top: uart_top PORT MAP(
207
                wb_clk_i => clk,
208
                wb_rst_i => reset_activehigh,
209
                wb_adr_i => serial2_wb_adr_i(2 downto 0),
210
                wb_dat_i => serial2_wb_dat_i,
211
                wb_dat_o => serial2_wb_dat_o,
212
                wb_we_i => serial2_wb_we,
213
                wb_stb_i => serial2_wb_stb,
214
                wb_cyc_i => serial2_wb_cyc,
215
                wb_ack_o => serial2_wb_ack_o,
216
                wb_sel_i => serial2_wb_sel_i,
217
                int_o => serial2_int_o,
218
                stx_pad_o => serial2_tx,
219
                srx_pad_i => serial2_rx,
220
                rts_pad_o => serial2_rts,
221
                cts_pad_i => serial2_cts,
222
                dtr_pad_o => serial2_dtr,
223
                dsr_pad_i => serial2_dsr,
224
                ri_pad_i => serial2_ri,
225
                dcd_pad_i => serial2_dcd
226
        );
227
        Inst_uart3_top: uart_top PORT MAP(
228
                wb_clk_i => clk,
229
                wb_rst_i => reset_activehigh,
230
                wb_adr_i => serial3_wb_adr_i(2 downto 0),
231
                wb_dat_i => serial3_wb_dat_i,
232
                wb_dat_o => serial3_wb_dat_o,
233
                wb_we_i => serial3_wb_we,
234
                wb_stb_i => serial3_wb_stb,
235
                wb_cyc_i => serial3_wb_cyc,
236
                wb_ack_o => serial3_wb_ack_o,
237
                wb_sel_i => serial3_wb_sel_i,
238
                int_o => serial3_int_o,
239
                stx_pad_o => serial3_tx,
240
                srx_pad_i => serial3_rx,
241
                rts_pad_o => serial3_rts,
242
                cts_pad_i => serial3_cts,
243
                dtr_pad_o => serial3_dtr,
244
                dsr_pad_i => serial3_dsr,
245
                ri_pad_i => serial3_ri,
246
                dcd_pad_i => serial3_dcd
247
        );
248
        Inst_uart4_top: uart_top PORT MAP(
249
                wb_clk_i => clk,
250
                wb_rst_i => reset_activehigh,
251
                wb_adr_i => serial4_wb_adr_i(2 downto 0),
252
                wb_dat_i => serial4_wb_dat_i,
253
                wb_dat_o => serial4_wb_dat_o,
254
                wb_we_i => serial4_wb_we,
255
                wb_stb_i => serial4_wb_stb,
256
                wb_cyc_i => serial4_wb_cyc,
257
                wb_ack_o => serial4_wb_ack_o,
258
                wb_sel_i => serial4_wb_sel_i,
259
                int_o => serial4_int_o,
260
                stx_pad_o => serial4_tx,
261
                srx_pad_i => serial4_rx,
262
                rts_pad_o => serial4_rts,
263
                cts_pad_i => serial4_cts,
264
                dtr_pad_o => serial4_dtr,
265
                dsr_pad_i => serial4_dsr,
266
                ri_pad_i => serial4_ri,
267
                dcd_pad_i => serial4_dcd
268
        );
269
 
270
 
271
        Inst_ps2_top: ps2_top PORT MAP(
272
                wb_clk_i => clk,
273
                wb_rst_i => reset_activehigh,
274
            wb_cyc_i => ps2_wb_cyc,
275
            wb_stb_i => ps2_wb_stb,
276
            wb_we_i => ps2_wb_we,
277
            wb_sel_i => ps2_wb_sel_i,
278
            wb_adr_i => ps2_wb_adr_i,
279
            wb_dat_i => ps2_wb_dat_i,
280
            wb_dat_o => ps2_wb_dat_o,
281
            wb_ack_o => ps2_wb_ack_o,
282
            wb_int_o => ps2_wb_int_o,
283
            --kb_rstout => kb_rstout,
284
            ps2_kbd_clk_pad_i => ps2_kbd_clk_pad_i,
285
            ps2_kbd_data_pad_i => ps2_kbd_data_pad_i,
286
            ps2_kbd_clk_pad_o => ps2_kbd_clk_pad_o,
287
            ps2_kbd_data_pad_o => ps2_kbd_data_pad_o,
288
            ps2_kbd_clk_pad_oe_o => ps2_kbd_clk_pad_oe_o,
289
            ps2_kbd_data_pad_oe_o => ps2_kbd_data_pad_oe_o,
290
            wb_intb_o => ps2_wb_intb_o,
291
            ps2_aux_clk_pad_i => ps2_aux_clk_pad_i,
292
            ps2_aux_data_pad_i => ps2_aux_data_pad_i,
293
            ps2_aux_clk_pad_o => ps2_aux_clk_pad_o,
294
            ps2_aux_data_pad_o => ps2_aux_data_pad_o,
295
            ps2_aux_clk_pad_oe_o => ps2_aux_clk_pad_oe_o,
296
            ps2_aux_data_pad_oe_o => ps2_aux_data_pad_oe_o
297
        );
298
 
299
--local Logic --------------------------------------------------------------------
300
reset_activehigh <= not reset_n;
301
 
302
 
303
process ( reset_n, clk, wbm_adr_i, serial1_wb_dat_o, serial2_wb_dat_o, serial3_wb_dat_o, serial4_wb_dat_o, ps2_wb_dat_o, ps2_wb_ack_o, serial1_wb_ack_o, serial2_wb_ack_o, serial3_wb_ack_o, serial4_wb_ack_o, wbm_cyc_i, wbm_we_i, wbm_stb_i, offset_reg, device_reg )
304
begin
305
if (reset_n='0') then
306
   wbm_dat_o <= (others => '0');
307
   offset_reg <=  (others => '0');
308
   device_reg <=  (others => '0');
309
else
310
 if (wbm_adr_i(9 downto 3) = "1111111") then --serial1
311
   wbm_dat_o(7 downto 0) <= serial1_wb_dat_o; wbm_ack_o <= serial1_wb_ack_o;
312
   ps2_wb_cyc <= '0'; serial1_wb_cyc <= wbm_cyc_i; serial2_wb_cyc <= '0'; serial3_wb_cyc <= '0'; serial4_wb_cyc <= '0';
313
   ps2_wb_we <= '0'; serial1_wb_we <= wbm_we_i; serial2_wb_we <= '0'; serial3_wb_we <= '0'; serial4_wb_we <= '0';
314
   ps2_wb_stb <= '0'; serial1_wb_stb <= wbm_stb_i; serial2_wb_stb <= '0'; serial3_wb_stb <= '0'; serial4_wb_stb <= '0';
315
 elsif (wbm_adr_i(9 downto 3) = "1011111") then  --serial2
316
   wbm_dat_o(7 downto 0) <= serial2_wb_dat_o;  wbm_ack_o <= serial2_wb_ack_o;
317
   ps2_wb_cyc <= '0'; serial1_wb_cyc <= '0'; serial2_wb_cyc <= wbm_cyc_i; serial3_wb_cyc <= '0'; serial4_wb_cyc <= '0';
318
   ps2_wb_we <= '0'; serial1_wb_we <= '0'; serial2_wb_we <= wbm_we_i; serial3_wb_we <= '0'; serial4_wb_we <= '0';
319
   ps2_wb_stb <= '0'; serial1_wb_stb <= '0'; serial2_wb_stb <= wbm_stb_i; serial3_wb_stb <= '0'; serial4_wb_stb <= '0';
320
 elsif (wbm_adr_i(9 downto 3) = "1111101") then  --serial3
321
   wbm_dat_o(7 downto 0) <= serial3_wb_dat_o;  wbm_ack_o <= serial3_wb_ack_o;
322
   ps2_wb_cyc <= '0'; serial1_wb_cyc <= '0'; serial2_wb_cyc <= '0'; serial3_wb_cyc <= wbm_cyc_i; serial4_wb_cyc <= '0';
323
   ps2_wb_we <= '0'; serial1_wb_we <= '0'; serial2_wb_we <= '0'; serial3_wb_we <= wbm_we_i; serial4_wb_we <= '0';
324
   ps2_wb_stb <= '0'; serial1_wb_stb <= '0'; serial2_wb_stb <= '0'; serial3_wb_stb <= wbm_stb_i; serial4_wb_stb <= '0';
325
 elsif (wbm_adr_i(9 downto 3) = "1011101") then  --serial4
326
   wbm_dat_o(7 downto 0) <= serial4_wb_dat_o;  wbm_ack_o <= serial4_wb_ack_o;
327
   ps2_wb_cyc <= '0'; serial1_wb_cyc <= '0'; serial2_wb_cyc <= '0'; serial3_wb_cyc <= '0'; serial4_wb_cyc <= wbm_cyc_i;
328
   ps2_wb_we <= '0'; serial1_wb_we <= '0'; serial2_wb_we <= '0'; serial3_wb_we <= '0'; serial4_wb_we <= wbm_we_i;
329
   ps2_wb_stb <= '0'; serial1_wb_stb <= '0'; serial2_wb_stb <= '0'; serial3_wb_stb <= '0'; serial4_wb_stb <= wbm_stb_i;
330
 elsif (wbm_adr_i(12 downto 3) = "0001100000") then --ps2
331
   wbm_dat_o(7 downto 0) <= ps2_wb_dat_o(31 downto 24); wbm_ack_o <= ps2_wb_ack_o;
332
   ps2_wb_cyc <= wbm_cyc_i; serial1_wb_cyc <= '0'; serial2_wb_cyc <= '0'; serial3_wb_cyc <= '0'; serial4_wb_cyc <= '0';
333
   ps2_wb_we <= wbm_we_i; serial1_wb_we <= '0'; serial2_wb_we <= '0'; serial3_wb_we <= '0'; serial4_wb_we <= '0';
334
   ps2_wb_stb <= wbm_stb_i; serial1_wb_stb <= '0'; serial2_wb_stb <= '0'; serial3_wb_stb <= '0'; serial4_wb_stb <= '0';
335
 elsif (wbm_adr_i(12 downto 3) = "0001100100") then --p2s
336
   wbm_dat_o(7 downto 0) <= ps2_wb_dat_o(31 downto 24); wbm_ack_o <= ps2_wb_ack_o;
337
   ps2_wb_cyc <= wbm_cyc_i; serial1_wb_cyc <= '0'; serial2_wb_cyc <= '0'; serial3_wb_cyc <= '0'; serial4_wb_cyc <= '0';
338
   ps2_wb_we <= wbm_we_i; serial1_wb_we <= '0'; serial2_wb_we <= '0'; serial3_wb_we <= '0'; serial4_wb_we <= '0';
339
   ps2_wb_stb <= wbm_stb_i; serial1_wb_stb <= '0'; serial2_wb_stb <= '0'; serial3_wb_stb <= '0'; serial4_wb_stb <= '0';
340
 else  --not serial or ps2 forwarding, decode locally: 
341
 
342
   ps2_wb_cyc <= '0'; serial1_wb_cyc <= '0'; serial2_wb_cyc <= '0'; serial3_wb_cyc <= '0'; serial4_wb_cyc <= '0';
343
   ps2_wb_we <= '0'; serial1_wb_we <= '0'; serial2_wb_we <= '0'; serial3_wb_we <= '0'; serial4_wb_we <= '0';
344
   ps2_wb_stb <= '0'; serial1_wb_stb <= '0'; serial2_wb_stb <= '0'; serial3_wb_stb <= '0'; serial4_wb_stb <= '0';
345
 
346
   if (clk'event and clk='1') then
347
 
348
          case ( wbm_adr_i(11 downto 0) ) is
349
          --registers:
350
          when X"200" =>
351
           wbm_dat_o(7 downto 0) <= register_0_in(7 downto 0); wbm_ack_o <= '1';
352
           register_0_out <= wbm_dat_i(7 downto 0);
353
          when X"201" =>
354
           wbm_dat_o(7 downto 0) <= register_1_in(7 downto 0); wbm_ack_o <= '1';
355
           register_1_out <= wbm_dat_i(7 downto 0);
356
          when X"202" =>
357
           wbm_dat_o(7 downto 0) <= register_2_in(7 downto 0); wbm_ack_o <= '1';
358
           register_2_out <= wbm_dat_i(7 downto 0);
359
          when X"203" =>
360
           wbm_dat_o(7 downto 0) <= register_3_in(7 downto 0); wbm_ack_o <= '1';
361
           register_3_out <= wbm_dat_i(7 downto 0);
362
          when X"204" =>
363
           wbm_dat_o(7 downto 0) <= register_4_in(7 downto 0); wbm_ack_o <= '1';
364
           register_4_out <= wbm_dat_i(7 downto 0);
365
          when X"205" =>
366
           wbm_dat_o(7 downto 0) <= register_5_in(7 downto 0); wbm_ack_o <= '1';
367
           register_5_out <= wbm_dat_i(7 downto 0);
368
          when X"206" =>
369
           wbm_dat_o(7 downto 0) <= register_6_in(7 downto 0); wbm_ack_o <= '1';
370
           register_6_out <= wbm_dat_i(7 downto 0);
371
          when X"207" =>
372
           wbm_dat_o(7 downto 0) <= register_7_in(7 downto 0); wbm_ack_o <= '1';
373
           register_7_out <= wbm_dat_i(7 downto 0);
374
          --post code PORT80:
375
          when X"080" =>
376
           port80 <=  wbm_dat_i(7 downto 0);
377
           wbm_dat_o(7 downto 0) <= offset_reg; wbm_ack_o <= '1';
378
          when X"081" =>
379
           port81 <=  wbm_dat_i(7 downto 0);
380
           wbm_dat_o(7 downto 0) <= offset_reg; wbm_ack_o <= '1';
381
          --sio plug and play logic, for the BIOS/OS to detect the number of ports available. ****
382
          when X"02E" =>
383
           if (wbm_we_i='1') then  offset_reg <=  wbm_dat_i(7 downto 0);  end if;
384
           wbm_dat_o(7 downto 0) <= offset_reg; wbm_ack_o <= '1';
385
          when X"02F" =>
386
           if (wbm_we_i='1') then  device_reg <=  wbm_dat_i(7 downto 0);  end if;
387
           wbm_ack_o <= '1';
388
             if (offset_reg = 7) then
389
               wbm_dat_o(7 downto 0) <= device_reg;
390
             elsif (offset_reg = X"60") then --offset LSB 
391
                if    (device_reg = 4) then --serial1
392
                  wbm_dat_o(7 downto 0) <= X"F8";
393
                elsif (device_reg = 3) then --serial2
394
                  wbm_dat_o(7 downto 0) <= X"F8";
395
                elsif (device_reg = 2) then --serial3
396
                  wbm_dat_o(7 downto 0) <= X"E8";
397
                elsif (device_reg = 1) then --serial4
398
                  wbm_dat_o(7 downto 0) <= X"E8";
399
                elsif (device_reg = 6) then --keyboard
400
                  wbm_dat_o(7 downto 0) <= X"60";
401
                elsif (device_reg = 5) then --mouse
402
                  wbm_dat_o(7 downto 0) <= X"60";
403
                else
404
                  wbm_dat_o(7 downto 0) <= "00000000";
405
                end if;
406
             elsif (offset_reg = X"61") then --offset MSB 
407
                if    (device_reg = 4) then --serial1
408
                  wbm_dat_o(7 downto 0) <= X"03";
409
                elsif (device_reg = 3) then --serial2
410
                  wbm_dat_o(7 downto 0) <= X"02";
411
                elsif (device_reg = 2) then --serial3
412
                  wbm_dat_o(7 downto 0) <= X"03";
413
                elsif (device_reg = 1) then --serial4
414
                  wbm_dat_o(7 downto 0) <= X"02";
415
                elsif (device_reg = 6) then --keyboard
416
                  wbm_dat_o(7 downto 0) <= X"00";
417
                elsif (device_reg = 5) then --mouse
418
                  wbm_dat_o(7 downto 0) <= X"00";
419
                else
420
                  wbm_dat_o(7 downto 0) <= "00000000";
421
                end if;
422
             elsif (offset_reg = X"70") then --interrupt info
423
                if    (device_reg = 4) then --serial1
424
                  wbm_dat_o(7 downto 0) <= X"04";
425
                elsif (device_reg = 3) then --serial2
426
                  wbm_dat_o(7 downto 0) <= X"03";
427
                elsif (device_reg = 2) then --serial3
428
                  wbm_dat_o(7 downto 0) <= X"04";
429
                elsif (device_reg = 1) then --serial4
430
                  wbm_dat_o(7 downto 0) <= X"03";
431
                elsif (device_reg = 6) then --keyboard
432
                  wbm_dat_o(7 downto 0) <= X"01";
433
                elsif (device_reg = 5) then --mouse
434
                  wbm_dat_o(7 downto 0) <= X"0C";
435
                else
436
                  wbm_dat_o(7 downto 0) <= "00000000";
437
                end if;
438
             end if;
439
          when others => --error
440
            wbm_dat_o <= (others => '0'); wbm_ack_o <= '0';
441
            --device_reg <= device_reg; port80 <= port80; port81 <= port81; offset_reg <= offset_reg;
442
            --register_0_out <= register_0_out; register_1_out <= register_1_out; register_2_out <= register_2_out; register_3_out <= register_3_out; 
443
            --register_4_out <= register_4_out; register_5_out <= register_5_out; register_6_out <= register_6_out; register_7_out <= register_7_out; 
444
          end case;
445
   end if;
446
 end if;
447
end if;
448
end process;
449
 
450
ps2_wb_dat_i(31 downto 24) <= wbm_dat_i(7 downto 0);
451
ps2_wb_dat_i(23 downto 16) <= wbm_dat_i(7 downto 0);
452
ps2_wb_dat_i(15 downto 8) <= wbm_dat_i(7 downto 0);
453
ps2_wb_sel_i(3) <= '1';
454
ps2_wb_sel_i(2 downto 0) <= "000";
455
ps2_wb_adr_i(3 downto 0) <= wbm_adr_i(3 downto 0);
456
serial1_wb_dat_i <= wbm_dat_i(7 downto 0);
457
serial1_wb_sel_i <= "1000";
458
serial1_wb_adr_i(2 downto 0) <= wbm_adr_i(2 downto 0);
459
serial2_wb_dat_i <= wbm_dat_i(7 downto 0);
460
serial2_wb_sel_i <= "1000";
461
serial2_wb_adr_i(2 downto 0) <= wbm_adr_i(2 downto 0);
462
serial3_wb_dat_i <= wbm_dat_i(7 downto 0);
463
serial3_wb_sel_i <= "1000";
464
serial3_wb_adr_i(2 downto 0) <= wbm_adr_i(2 downto 0);
465
serial4_wb_dat_i <= wbm_dat_i(7 downto 0);
466
serial4_wb_sel_i <= "1000";
467
serial4_wb_adr_i(2 downto 0) <= wbm_adr_i(2 downto 0);
468
 
469
--end file ----------------------------------------------------------------------
470
end Behavioral;
471
 
472
 
473
 
474
 
475
 

powered by: WebSVN 2.1.0

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