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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_4/] [rtl/] [vhdl/] [upi41_db_bus.vhd] - Blame information for rev 344

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 303 arniml
-------------------------------------------------------------------------------
2
--
3
-- The UPI-41 BUS unit.
4
-- Implements the BUS port logic.
5
--
6
-- Copyright (c) 2004-2022, Arnim Laeuger (arniml@opencores.org)
7
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41
--      http://www.opencores.org/cvsweb.shtml/t48/
42
--
43
-------------------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
 
48
use work.t48_pack.word_t;
49
 
50
entity upi41_db_bus is
51
 
52
  generic (
53
    is_type_a_g : integer := 1
54
  );
55
  port (
56
    -- Global Interface -------------------------------------------------------
57
    clk_i        : in  std_logic;
58
    res_i        : in  std_logic;
59
    en_clk_i     : in  boolean;
60
    -- UPI41 Bus Interface ----------------------------------------------------
61
    data_i       : in  word_t;
62
    data_o       : out word_t;
63
    write_bus_i  : in  boolean;
64
    read_bus_i   : in  boolean;
65
    write_sts_i  : in  boolean;
66
    set_f1_o     : out boolean;
67
    clear_f1_o   : out boolean;
68
    f0_i         : in  std_logic;
69
    f1_i         : in  std_logic;
70
    ibf_o        : out std_logic;
71
    obf_o        : out std_logic;
72
    int_n_o      : out std_logic;
73
    ibf_int_i    : in  boolean;
74
    en_dma_i     : in  boolean;
75
    en_flags_i   : in  boolean;
76 317 arniml
    -- P2 interface -----------------------------------------------------------
77
    write_p2_i   : in  boolean;
78 313 arniml
    mint_ibf_n_o : out std_logic;
79
    mint_obf_o   : out std_logic;
80 317 arniml
    dma_o        : out boolean;
81 313 arniml
    drq_o        : out std_logic;
82
    dack_n_i     : in  std_logic;
83 303 arniml
    -- BUS Interface ----------------------------------------------------------
84
    a0_i         : in  std_logic;
85
    cs_n_i       : in  std_logic;
86
    rd_n_i       : in  std_logic;
87
    wr_n_i       : in  std_logic;
88
    db_i         : in  word_t;
89
    db_o         : out word_t;
90
    db_dir_o     : out std_logic
91
  );
92
 
93
end upi41_db_bus;
94
 
95
 
96
use work.t48_pack.clk_active_c;
97
use work.t48_pack.res_active_c;
98
use work.t48_pack.bus_idle_level_c;
99
use work.t48_pack.to_stdLogic;
100
 
101
architecture rtl of upi41_db_bus is
102
 
103
  signal read_s, read_q,
104
         write_s, write_q,
105
         read_pulse_s, write_pulse_s : boolean;
106
 
107 317 arniml
  signal a0_q : std_logic;
108
 
109 303 arniml
  signal ibf_q, obf_q : std_logic;
110
 
111
  -- the BUS output register
112
  signal dbbin_q,
113
         dbbout_q : word_t;
114
  -- the BUS status register
115 312 arniml
  signal sts_q    : std_logic_vector(7 downto 4);
116 323 arniml
  signal status_q : word_t;
117 303 arniml
 
118 313 arniml
  signal dma_q,
119
         flags_q : boolean;
120
 
121 317 arniml
  signal ext_acc_s : boolean;
122
  signal dack_s  : boolean;
123
 
124 303 arniml
begin
125
 
126
  -- pragma translate_off
127
 
128
  -- UPI41 configuration ------------------------------------------------------
129
  assert (is_type_a_g = 0) or (is_type_a_g = 1)
130
    report "is_type_a_g must be either 1 or 0!"
131
    severity failure;
132
 
133
  -- pragma translate_on
134
 
135
 
136
  -----------------------------------------------------------------------------
137
  -- Process master_access
138
  --
139
  -- Purpose:
140
  --   Generate read and write pulses based on master access.
141
  --
142 317 arniml
  dack_s    <= dack_n_i = '0' and dma_q;
143
  ext_acc_s <= cs_n_i = '0' or dack_s;
144
  read_s    <= ext_acc_s and rd_n_i = '0';
145
  write_s   <= ext_acc_s and wr_n_i = '0';
146 303 arniml
  --
147
  master_access: process (res_i, clk_i)
148
  begin
149
    if res_i = res_active_c then
150
      read_q      <= false;
151
      write_q     <= false;
152 317 arniml
      a0_q        <= '0';
153 323 arniml
      status_q    <= (others => '0');
154 303 arniml
 
155
    elsif clk_i'event and clk_i = clk_active_c then
156
      read_q  <= read_s;
157
      write_q <= write_s;
158
 
159 317 arniml
      if dack_s then
160
        a0_q <= '0';
161
      elsif read_s or write_s then
162
        a0_q <= a0_i;
163
      end if;
164
 
165 323 arniml
      -- prevent change when master reads status
166
      if not read_s then
167
        if is_type_a_g = 1 then
168
          status_q <= sts_q  & f1_i & f0_i & ibf_q & obf_q;
169
        else
170
          status_q <= "0000" & f1_i & f0_i & ibf_q & obf_q;
171
        end if;
172
      end if;
173
 
174 303 arniml
    end if;
175
  end process master_access;
176
  --
177 322 arniml
  -- read/write pulses - flags are updated with rising RD' / WR'
178 303 arniml
  read_pulse_s  <= read_q and not read_s;
179
  write_pulse_s <= write_q and not write_s;
180
 
181
  -----------------------------------------------------------------------------
182
  -- Process bus_regs
183
  --
184
  -- Purpose:
185
  --   Implements the BUS output register.
186
  --
187
  bus_regs: process (res_i, clk_i)
188
  begin
189
    if res_i = res_active_c then
190 317 arniml
      dbbin_q  <= (others => '0');
191
      dbbout_q <= (others => '0');
192
      sts_q    <= (others => '0');
193
      ibf_q    <= '0';
194
      obf_q    <= '0';
195
      int_n_o  <= '1';
196
      dma_q    <= false;
197
      drq_o    <= '0';
198
      flags_q  <= false;
199 303 arniml
 
200
    elsif clk_i'event and clk_i = clk_active_c then
201
      -- master access
202 317 arniml
      if read_pulse_s and a0_q = '0' then
203 303 arniml
        obf_q <= '0';
204
      elsif write_pulse_s then
205
        dbbin_q <= db_i;
206
        ibf_q   <= '1';
207
        int_n_o <= '0';
208
      end if;
209
 
210 322 arniml
      -- DRQ is inactivated at beginning of access
211 319 arniml
      if dack_s and (read_s or write_s) then
212
        drq_o <= '0';
213
      end if;
214
 
215 303 arniml
      if en_clk_i then
216
        if write_bus_i then
217
          dbbout_q <= data_i;
218
          obf_q    <= '1';
219
        elsif read_bus_i then
220
          ibf_q    <= '0';
221
        elsif write_sts_i then
222 312 arniml
          sts_q    <= data_i(7 downto 4);
223 303 arniml
        end if;
224
 
225
        if ibf_int_i then
226
          int_n_o <= '1';
227
        end if;
228
 
229 313 arniml
        if is_type_a_g = 1 then
230
          if en_dma_i then
231
            dma_q <= true;
232 317 arniml
            drq_o <= '0';
233 313 arniml
          end if;
234
          if en_flags_i then
235
            flags_q <= true;
236
          end if;
237 317 arniml
 
238 319 arniml
          if dma_q and write_p2_i and data_i(6) = '1' then
239 317 arniml
            drq_o <= '1';
240
          end if;
241 313 arniml
        end if;
242
 
243 303 arniml
      end if;
244
 
245
    end if;
246
 
247
  end process bus_regs;
248
  --
249
  -----------------------------------------------------------------------------
250
 
251
 
252
  -----------------------------------------------------------------------------
253
  -- Output Mapping.
254
  -----------------------------------------------------------------------------
255 317 arniml
  set_f1_o   <= write_pulse_s and a0_q = '1';
256
  clear_f1_o <= write_pulse_s and a0_q = '0';
257 303 arniml
  ibf_o      <= ibf_q;
258
  obf_o      <= obf_q;
259 323 arniml
  db_o       <= dbbout_q when a0_i = '0' or (dack_s and dma_q) else
260
                status_q;
261
  db_dir_o   <= '1' when read_s else '0';
262 303 arniml
  data_o     <=   dbbin_q
263
                when read_bus_i else
264
                  (others => bus_idle_level_c);
265
 
266 315 arniml
  mint_ibf_n_o <= '0' when flags_q and ibf_q = '1' else '1';
267
  mint_obf_o   <= '0' when flags_q and obf_q = '0' else '1';
268 313 arniml
 
269 317 arniml
  dma_o <= dma_q;
270 313 arniml
 
271 303 arniml
end rtl;

powered by: WebSVN 2.1.0

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