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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [System09_Xess_XuLA/] [xula_iobus.vhd] - Blame information for rev 138

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

Line No. Rev Author Line
1 122 dilbert57
--===========================================================================--
2
--                                                                           --
3
--  xula_iobus.vhd - Synthesizable Dual Bidirectionsal I/O Port             --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : xula_iobusi.vhd
8
--
9
--  Purpose        : Implements a dual 8 bit bidirectional I/O bus
10
--                   for the XuLA implementation of System09
11
--                   Allows the XuLA System09 port to talk to
12
-- 
13
--  Dependencies   : ieee.std_logic_1164
14
--                   ieee.std_logic_unsigned
15
--                   unisim.vcomponents
16
--
17
--  Author         : John E. Kent
18
--
19
--  Email          : dilbert57@opencores.org      
20
--
21
--  Web            : http://opencores.org/project,system09
22
--
23
-- Description
24
--
25
--  system09 clk  /-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\_/-\
26
--
27
--  system09 cs   ---\_______________________________/--------------------
28
--
29
--  bus release   ______________________________/-------------------------
30
--
31
--  system09 hold ____/---------------------------\_______________________
32
--
33
--  bus cs_n      ----\______________________________/--------------------
34
--
35
--  bus rd_n      ---------------------\_____________/--------------------
36
--
37
--  bus ds        _____________________/-------------\____________________
38
--
39
--
40
--  Copyright (C) 2002 - 2011 John Kent
41
--
42
--  This program is free software: you can redistribute it and/or modify
43
--  it under the terms of the GNU General Public License as published by
44
--  the Free Software Foundation, either version 3 of the License, or
45
--  (at your option) any later version.
46
--
47
--  This program is distributed in the hope that it will be useful,
48
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
49
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50
--  GNU General Public License for more details.
51
--
52
--  You should have received a copy of the GNU General Public License
53
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
54
--
55
--===========================================================================--
56
--                                                                           --
57
--                              Revision  History                            --
58
--                                                                           --
59
--===========================================================================--
60
--
61
-- Version  Author        Date               Description
62
-- 0.1      John E. Kent  1 May 2011         Initial version 
63
--===========================================================================
64
--
65
 
66
library ieee;
67
  use ieee.std_logic_1164.all;
68
  use ieee.std_logic_unsigned.all;
69
--library unisim;
70
--  use unisim.vcomponents.all;
71
 
72
entity xula_iobus is
73
  port (
74
    clk        : in    std_logic;
75
    rst        : in    std_logic;
76
    cs         : in    std_logic;
77
    rw         : in    std_logic;
78
    addr       : in    std_logic_vector(4 downto 0);
79
    data_in    : in    std_logic_vector(7 downto 0);
80
    data_out   : out   std_logic_vector(7 downto 0);
81
         hold       : out   std_logic;
82
    irq        : out   std_logic;
83
         bus_cs     : out   std_logic;
84
    bus_ds_rdn : out   std_logic;
85
    bus_rw_wrn : out   std_logic;
86
    bus_addr   : out   std_logic_vector(3 downto 0);
87
    bus_data   : inout std_logic_vector(7 downto 0);
88
         bus_irq    : in    std_logic;
89
  );
90
end;
91
 
92
architecture rtl of xula_iobus is
93
 
94
begin
95
 
96
 
97
--------------------------------
98
--
99
-- read I/O bus control registers
100
--
101
--------------------------------
102
 
103
iobus_read : process( addr, bus_data, bus_reg )
104
begin
105
  if addr(4) = '0' then
106
    data_out <= bus_data;
107
  else
108
    data_out <= bus_reg;
109
  end if;
110
end process;
111
 
112
---------------------------------
113
--
114
-- Write bus data / register
115
--
116
---------------------------------
117
 
118
iobus_write : process( clk, rst, addr, cs, rw, data_in )
119
begin
120
  if clk'event and clk = '0' then
121
    if rst = '1' then
122
      bus_data <= (others=>'Z');
123
      bus_reg <= (others=>'0');
124
    else
125
      if cs = '1' then
126
                  if addr(4) = '0' then
127
                    if bus_release = '0' and bus_hold = '0' then
128
                           bus_hold <= '1';
129
            if rw = '0' then
130
              bus_data <= data_in;
131
            else
132
              bus_data <= (other=>'Z');
133
            end if;
134
          else
135
                           if bus_release = '1' and bus_hold = '1' then
136
                                  bus_hold <= '0';
137
                                end if;
138
                         end if;
139
        else
140
                    if rw = '0' then
141
             bus_reg <= data_in;
142
          end if;
143
        end if;
144
      end if;
145
    end if;
146
  end if;
147
end process;
148
 
149
 
150
---------------------------------
151
--
152
-- Write bus register
153
--
154
---------------------------------
155
 
156
iobus_reg_write : process( clk, rst, addr, cs, rw, data_in )
157
begin
158
  if clk'event and clk = '0' then
159
    if rst = '1' then
160
    else
161
      if cs = '1' and addr(4) = '1' then
162
                  if rw = '0' then
163
           bus_reg <= data_in;
164
        else
165
           bus_data <= (other=>'Z');
166
        end if;
167
      end if;
168
    end if;
169
  end if;
170
end process;
171
 
172
---------------------------------
173
--
174
-- direction control port a
175
--
176
---------------------------------
177
iobus_ctrl : process ( clk, rst,  )
178
begin
179
  if clk'event and clk = '0' then
180
    if rst = '1' then
181
      bus_data <= (others=>'0');
182
      bus_reg  <= (others=>'0');
183
    else
184
end process;
185
---------------------------------
186
--
187
-- hold CPU for one external bus cycle
188
--
189
---------------------------------
190
iobus_hold : process ( portb_data, portb_ddr, portb_io )
191
begin
192
end process;
193
---------------------------------
194
 
195
----------------------------------------------------------
196
--
197
-- Generate a bus clock with half cycle period
198
-- equal to the cpu clock cycle count
199
-- in the bus register bits 6 downto 0.
200
--
201
-- Generate a time out signal for one cpu clock cycle
202
-- when the bus timer reaches zero
203
--
204
----------------------------------------------------------
205
iobus_clk : process ( clk, rst )
206
begin
207
  if clk'event and clk = '0' then
208
    if rst = '1' then
209
           bus_timer <= (others=>'0');
210
                bus_clk   <= '0';
211
                bus_to    <= '0';
212
    else
213
           if bus_timer = "0000000" then
214
                  bus_timer <= bus_reg(6 downto 0);
215
                  bus_clk   <= not bus_clk;
216
                  bus_to    <= '1';
217
                else
218
                  bus_timer <= bus_timer - "0000001";
219
                  bus_to    <= '0';
220
                end if;
221
         end if;
222
  end if;
223
 
224
end process;
225
 
226
----------------------------------------------------------
227
--
228
--  Bus Request
229
--
230
--  Synchronize I/O bus cycle request to the start of the bus clock
231
--
232
--  The start of the io bus cycle is defined as there being
233
--  a bus timer timeout and the bus clock is low.
234
--
235
--  If there is a bus request wait for the start of the
236
--  io bus cycle before acknowledging
237
--
238
--  If the bus request is removed, wait for the start of the
239
--  io bus cycle before removing the acknowledge.
240
--
241
----------------------------------------------------------
242
iobus_req : process ( clk, rst, bus_req, bus_ack, bus_clk, bus_to )
243
begin
244
  if clk'event and clk = '0' then
245
    if rst = '1' then
246
           bus_ack <= '0';
247
    else
248
           if bus_req = '1' and bus_ack = '0' then
249
                  if bus_clk = '0' and bus_to = '1' then
250
                    bus_ack <= '1';
251
                  end if;
252
      elsif bus_req = '0' and bus_ack = '1' then
253
                  if bus_clk = '0' and bus_to = '1' then
254
                    bus_ack <= '0';
255
                  end if;
256
                end if;
257
         end if;
258
  end if;
259
 
260
end process;
261
 
262
end rtl;
263
 

powered by: WebSVN 2.1.0

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