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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_1/] [rtl/] [vhdl/] [t8243/] [t8243_core.vhd] - Blame information for rev 325

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

Line No. Rev Author Line
1 247 arniml
-------------------------------------------------------------------------------
2
--
3
-- The T8243 Core
4
-- This is the core module implementing all functionality of the
5
-- original 8243 chip.
6
--
7 275 arniml
-- $Id: t8243_core.vhd,v 1.2 2006-12-18 01:18:58 arniml Exp $
8 247 arniml
-- $Name: not supported by cvs2svn $
9
--
10
-- Copyright (c) 2006, Arnim Laeuger (arniml@opencores.org)
11
--
12
-- All rights reserved
13
--
14
-- Redistribution and use in source and synthezised forms, with or without
15
-- modification, are permitted provided that the following conditions are met:
16
--
17
-- Redistributions of source code must retain the above copyright notice,
18
-- this list of conditions and the following disclaimer.
19
--
20
-- Redistributions in synthesized form must reproduce the above copyright
21
-- notice, this list of conditions and the following disclaimer in the
22
-- documentation and/or other materials provided with the distribution.
23
--
24
-- Neither the name of the author nor the names of other contributors may
25
-- be used to endorse or promote products derived from this software without
26
-- specific prior written permission.
27
--
28
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
32
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
-- POSSIBILITY OF SUCH DAMAGE.
39
--
40
-- Please report bugs to the author, but before you do so, please
41
-- make sure that this is not a derivative work and that
42
-- you have the latest version of this file.
43
--
44
-- The latest version of this file can be found at:
45
--      http://www.opencores.org/cvsweb.shtml/t48/
46
--
47
-------------------------------------------------------------------------------
48
 
49
library ieee;
50
use ieee. std_logic_1164.all;
51
 
52
entity t8243_core is
53
 
54
  generic (
55
    clk_fall_level_g : integer := 0
56
  );
57
  port (
58
    -- System Interface -------------------------------------------------------
59
    clk_i         : in  std_logic;
60
    clk_rise_en_i : in  std_logic;
61
    clk_fall_en_i : in  std_logic;
62
    reset_n_i     : in  std_logic;
63
    -- Control Interface ------------------------------------------------------
64
    cs_n_i        : in  std_logic;
65
    prog_n_i      : in  std_logic;
66
    -- Port 2 Interface -------------------------------------------------------
67
    p2_i          : in  std_logic_vector(3 downto 0);
68
    p2_o          : out std_logic_vector(3 downto 0);
69
    p2_en_o       : out std_logic;
70
    -- Port 4 Interface -------------------------------------------------------
71
    p4_i          : in  std_logic_vector(3 downto 0);
72
    p4_o          : out std_logic_vector(3 downto 0);
73
    p4_en_o       : out std_logic;
74
    -- Port 5 Interface -------------------------------------------------------
75
    p5_i          : in  std_logic_vector(3 downto 0);
76
    p5_o          : out std_logic_vector(3 downto 0);
77
    p5_en_o       : out std_logic;
78
    -- Port 6 Interface -------------------------------------------------------
79
    p6_i          : in  std_logic_vector(3 downto 0);
80
    p6_o          : out std_logic_vector(3 downto 0);
81
    p6_en_o       : out std_logic;
82
    -- Port 7 Interface -------------------------------------------------------
83
    p7_i          : in  std_logic_vector(3 downto 0);
84
    p7_o          : out std_logic_vector(3 downto 0);
85
    p7_en_o       : out std_logic
86
  );
87
 
88
end t8243_core;
89
 
90
 
91
library ieee;
92
use ieee.numeric_std.all;
93
 
94
architecture rtl of t8243_core is
95
 
96
  function int2stdlogic_f(level_i : in integer) return std_logic is
97
  begin
98
    if level_i = 0 then
99
      return '0';
100
    else
101
      return '1';
102
    end if;
103
  end;
104
 
105
  constant clk_fall_level_c : std_logic := int2stdlogic_f(clk_fall_level_g);
106
 
107
  type     instr_t is (INSTR_READ, INSTR_WRITE, INSTR_ORLD, INSTR_ANLD);
108
  signal   instr_q : instr_t;
109
 
110
  constant port_4_c : integer := 4;
111
  constant port_5_c : integer := 5;
112
  constant port_6_c : integer := 6;
113
  constant port_7_c : integer := 7;
114
 
115
  subtype port_range_t is natural range port_7_c downto port_4_c;
116
  signal  px_sel_q : std_logic_vector(port_range_t);
117
 
118
  signal  px_en_q  : std_logic_vector(port_range_t);
119
  signal  p2_en_q  : std_logic;
120
 
121
  subtype port_vector_t is std_logic_vector(3 downto 0);
122
  type    four_ports_t  is array (port_range_t) of port_vector_t;
123
  signal  px_latch_q    : four_ports_t;
124
 
125
  signal  data_s        : port_vector_t;
126
 
127
  signal  p2_s,
128
          p4_s,
129
          p5_s,
130
          p6_s,
131
          p7_s          : port_vector_t;
132
 
133
begin
134
 
135
  -- get rid of H and L
136
  p2_s <= to_X01(p2_i);
137
  p4_s <= to_X01(p4_i);
138
  p5_s <= to_X01(p5_i);
139
  p6_s <= to_X01(p6_i);
140
  p7_s <= to_X01(p7_i);
141
 
142
  -----------------------------------------------------------------------------
143
  -- Process ctrl_seq
144
  --
145
  -- Purpose:
146
  --   Implements the sequential elements that control the T8243 core.
147
  --     * latch port number
148
  --     * latch instruction
149
  --
150 275 arniml
  ctrl_seq: process (clk_i, cs_n_i)
151 247 arniml
  begin
152
    if cs_n_i = '1' then
153
      px_sel_q <= (others => '0');
154
      p2_en_q  <= '0';
155
      instr_q  <= INSTR_WRITE;
156
 
157
    elsif clk_i'event and clk_i = clk_fall_level_c then
158
      if cs_n_i = '0' and clk_fall_en_i = '1' then
159
        -- enable addressed port ----------------------------------------------
160
        px_sel_q <= (others => '0');
161
        px_sel_q(to_integer(unsigned(p2_s(1 downto 0))) +
162
                 port_range_t'low) <= '1';
163
 
164
        p2_en_q <= '0';
165
 
166
        -- decode instruction -------------------------------------------------
167
        case p2_s(3 downto 2) is
168
          when "00" =>
169
            instr_q <= INSTR_READ;
170
            p2_en_q <= '1';
171
          when "01" =>
172
            instr_q <= INSTR_WRITE;
173
          when "10" =>
174
            instr_q <= INSTR_ORLD;
175
          when "11" =>
176
            instr_q <= INSTR_ANLD;
177
          when others =>
178
            null;
179
        end case;
180
 
181
      end if;
182
 
183
    end if;
184
  end process ctrl_seq;
185
  --
186
  -----------------------------------------------------------------------------
187
 
188
 
189
  -----------------------------------------------------------------------------
190
  -- Process port_seq
191
  --
192
  -- Purpose:
193
  --   Implements the sequential elements of the four ports.
194
  --
195
  port_seq: process (clk_i, reset_n_i)
196
  begin
197
    if reset_n_i = '0' then
198
      px_en_q    <= (others => '0');
199
      px_latch_q <= (others => (others => '0'));
200
 
201
    elsif rising_edge(clk_i) then
202
      if cs_n_i = '0' and clk_rise_en_i = '1' then
203
        for idx in port_range_t loop
204
          if px_sel_q(idx) = '1' then
205
            if instr_q = INSTR_READ then
206
              -- port is being read from, switch off output enable
207
              px_en_q(idx) <= '0';
208
 
209
            else
210
              -- port is being written to, enable output
211
              px_en_q(idx) <= '1';
212
              -- and latch value
213
              px_latch_q(idx) <= data_s;
214
            end if;
215
          end if;
216
        end loop;
217
      end if;
218
 
219
    end if;
220
  end process port_seq;
221
  --
222
  -----------------------------------------------------------------------------
223
 
224
 
225
  -----------------------------------------------------------------------------
226
  -- Process data_gen
227
  --
228
  -- Purpose:
229
  --   Generates the data for the four port latches.
230
  --     * determines data inputs
231
  --     * calculates result of instruction
232
  --
233
  --   Multiplexes the read value for P2.
234
  --
235
  data_gen: process (px_sel_q,
236
                     instr_q,
237
                     p2_s,
238
                     px_latch_q,
239
                     p4_s, p5_s, p6_s, p7_s)
240
    variable port_v : port_vector_t;
241
  begin
242
    -- select addressed port
243
    case px_sel_q is
244
      when "0001" =>
245
        port_v := px_latch_q(port_4_c);
246
        p2_o   <= p4_s;
247
      when "0010" =>
248
        port_v := px_latch_q(port_5_c);
249
        p2_o   <= p5_s;
250
      when "0100" =>
251
        port_v := px_latch_q(port_6_c);
252
        p2_o   <= p6_s;
253
      when "1000" =>
254
        port_v := px_latch_q(port_7_c);
255
        p2_o   <= p7_s;
256
      when others =>
257
        port_v := (others => '-');
258
        p2_o   <= (others => '-');
259
    end case;
260
 
261
    case instr_q is
262
      when INSTR_WRITE =>
263
        data_s <= p2_s;
264
      when INSTR_ORLD =>
265
        data_s <= p2_s or port_v;
266
      when INSTR_ANLD =>
267
        data_s <= p2_s and port_v;
268
      when others =>
269
        data_s <= (others => '-');
270
    end case;
271
 
272
  end process;
273
  --
274
  -----------------------------------------------------------------------------
275
 
276
 
277
  -----------------------------------------------------------------------------
278
  -- Output mapping
279
  -----------------------------------------------------------------------------
280
  p2_en_o <=   '1'
281
             when cs_n_i = '0' and prog_n_i = '0' and p2_en_q = '1' else
282
               '0';
283
  p4_o    <= px_latch_q(port_4_c);
284
  p4_en_o <= px_en_q(port_4_c);
285
  p5_o    <= px_latch_q(port_5_c);
286
  p5_en_o <= px_en_q(port_5_c);
287
  p6_o    <= px_latch_q(port_6_c);
288
  p6_en_o <= px_en_q(port_6_c);
289
  p7_o    <= px_latch_q(port_7_c);
290
  p7_en_o <= px_en_q(port_7_c);
291
 
292
end rtl;
293
 
294
 
295
-------------------------------------------------------------------------------
296
-- File History:
297
--
298
-- $Log: not supported by cvs2svn $
299 275 arniml
-- Revision 1.1  2006/07/13 22:53:56  arniml
300
-- initial check-in
301
--
302 247 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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