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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [rtl/] [vhdl/] [system/] [t8050_wb.vhd] - Blame information for rev 180

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

Line No. Rev Author Line
1 169 arniml
-------------------------------------------------------------------------------
2
--
3
-- T8048 Microcontroller System
4
-- 8050 toplevel with Wishbone interface
5
--
6 180 arniml
-- $Id: t8050_wb.vhd,v 1.2 2005-06-11 10:16:05 arniml Exp $
7 169 arniml
--
8
-- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
9
--
10
-- All rights reserved
11
--
12
-- Redistribution and use in source and synthezised forms, with or without
13
-- modification, are permitted provided that the following conditions are met:
14
--
15
-- Redistributions of source code must retain the above copyright notice,
16
-- this list of conditions and the following disclaimer.
17
--
18
-- Redistributions in synthesized form must reproduce the above copyright
19
-- notice, this list of conditions and the following disclaimer in the
20
-- documentation and/or other materials provided with the distribution.
21
--
22
-- Neither the name of the author nor the names of other contributors may
23
-- be used to endorse or promote products derived from this software without
24
-- specific prior written permission.
25
--
26
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
-- POSSIBILITY OF SUCH DAMAGE.
37
--
38
-- Please report bugs to the author, but before you do so, please
39
-- make sure that this is not a derivative work and that
40
-- you have the latest version of this file.
41
--
42
-- The latest version of this file can be found at:
43
--      http://www.opencores.org/cvsweb.shtml/t48/
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
entity t8050_wb is
51
 
52
  generic (
53
    gate_port_input_g : integer := 1
54
  );
55
 
56
  port (
57
    -- T48 Interface ----------------------------------------------------------
58
    xtal_i       : in  std_logic;
59
    reset_n_i    : in  std_logic;
60
    t0_i         : in  std_logic;
61
    t0_o         : out std_logic;
62
    t0_dir_o     : out std_logic;
63
    int_n_i      : in  std_logic;
64
    ea_i         : in  std_logic;
65
    rd_n_o       : out std_logic;
66
    psen_n_o     : out std_logic;
67
    wr_n_o       : out std_logic;
68
    ale_o        : out std_logic;
69
    t1_i         : in  std_logic;
70
    p2_i         : in  std_logic_vector( 7 downto 0);
71
    p2_o         : out std_logic_vector( 7 downto 0);
72
    p2_low_imp_o : out std_logic;
73
    p1_i         : in  std_logic_vector( 7 downto 0);
74
    p1_o         : out std_logic_vector( 7 downto 0);
75
    p1_low_imp_o : out std_logic;
76
    prog_n_o     : out std_logic;
77
    -- Wishbone Interface -----------------------------------------------------
78
    wb_cyc_o     : out std_logic;
79
    wb_stb_o     : out std_logic;
80
    wb_we_o      : out std_logic;
81
    wb_adr_o     : out std_logic_vector(23 downto 0);
82
    wb_ack_i     : in  std_logic;
83
    wb_dat_i     : in  std_logic_vector( 7 downto 0);
84
    wb_dat_o     : out std_logic_vector( 7 downto 0)
85
 
86
  );
87
 
88
end t8050_wb;
89
 
90
 
91
library ieee;
92
use ieee.numeric_std.all;
93
 
94
use work.t48_core_comp_pack.t48_core;
95
use work.t48_core_comp_pack.syn_rom;
96
use work.t48_core_comp_pack.syn_ram;
97 180 arniml
use work.t48_system_comp_pack.t48_wb_master;
98 169 arniml
 
99
architecture struct of t8050_wb is
100
 
101
  -- Address width of internal ROM
102
  constant rom_addr_width_c : natural := 12;
103
 
104
  signal xtal3_s          : std_logic;
105
  signal dmem_addr_s      : std_logic_vector( 7 downto 0);
106
  signal dmem_we_s        : std_logic;
107
  signal dmem_data_from_s : std_logic_vector( 7 downto 0);
108
  signal dmem_data_to_s   : std_logic_vector( 7 downto 0);
109
  signal pmem_addr_s      : std_logic_vector(11 downto 0);
110
  signal pmem_data_s      : std_logic_vector( 7 downto 0);
111
 
112
  signal ea_s             : std_logic;
113
 
114
  signal ale_s            : std_logic;
115
  signal wr_n_s           : std_logic;
116
  signal rd_n_s           : std_logic;
117
  signal db_bus_to_t48,
118
         db_bus_from_t48 : std_logic_vector( 7 downto 0);
119
 
120
  signal wb_en_clk_s      : std_logic;
121
  signal en_clk_s         : std_logic;
122
 
123
  signal p1_in_s,
124
         p1_out_s         : std_logic_vector( 7 downto 0);
125
  signal p2_in_s,
126
         p2_out_s         : std_logic_vector( 7 downto 0);
127
 
128
begin
129
 
130
  -----------------------------------------------------------------------------
131
  -- Check generics for valid values.
132
  -----------------------------------------------------------------------------
133
  -- pragma translate_off
134
  assert gate_port_input_g = 0 or gate_port_input_g = 1
135
    report "gate_port_input_g must be either 1 or 0!"
136
    severity failure;
137
  -- pragma translate_on
138
 
139
 
140
  t48_core_b : t48_core
141
    generic map (
142
      xtal_div_3_g        => 1,
143
      register_mnemonic_g => 1,
144
      include_port1_g     => 1,
145
      include_port2_g     => 1,
146
      include_bus_g       => 1,
147
      include_timer_g     => 1,
148
      sample_t1_state_g   => 4
149
    )
150
    port map (
151
      xtal_i       => xtal_i,
152
      reset_i      => reset_n_i,
153
      t0_i         => t0_i,
154
      t0_o         => t0_o,
155
      t0_dir_o     => t0_dir_o,
156
      int_n_i      => int_n_i,
157
      ea_i         => ea_s,
158
      rd_n_o       => rd_n_s,
159
      psen_n_o     => psen_n_o,
160
      wr_n_o       => wr_n_s,
161
      ale_o        => ale_s,
162
      db_i         => db_bus_to_t48,
163
      db_o         => db_bus_from_t48,
164
      db_dir_o     => open,
165
      t1_i         => t1_i,
166
      p2_i         => p2_in_s,
167
      p2_o         => p2_out_s,
168
      p2_low_imp_o => p2_low_imp_o,
169
      p1_i         => p1_in_s,
170
      p1_o         => p1_out_s,
171
      p1_low_imp_o => p1_low_imp_o,
172
      prog_n_o     => prog_n_o,
173
      clk_i        => xtal_i,
174
      en_clk_i     => en_clk_s,
175
      xtal3_o      => xtal3_s,
176
      dmem_addr_o  => dmem_addr_s,
177
      dmem_we_o    => dmem_we_s,
178
      dmem_data_i  => dmem_data_from_s,
179
      dmem_data_o  => dmem_data_to_s,
180
      pmem_addr_o  => pmem_addr_s,
181
      pmem_data_i  => pmem_data_s
182
    );
183
 
184
 
185
  -----------------------------------------------------------------------------
186
  -- Gate port 1 and 2 input bus with respetive output value
187
  -----------------------------------------------------------------------------
188
  gate_ports: if gate_port_input_g = 1 generate
189
    p1_in_s <= p1_i and p1_out_s;
190
    p2_in_s <= p2_i and p2_out_s;
191
  end generate;
192
 
193
  pass_ports: if gate_port_input_g = 0 generate
194
    p1_in_s <= p1_i;
195
    p2_in_s <= p2_i;
196
  end generate;
197
 
198
  p1_o <= p1_out_s;
199
  p2_o <= p2_out_s;
200
 
201
  ale_o  <= ale_s;
202
  wr_n_o <= wr_n_s;
203
  rd_n_o <= rd_n_s;
204
 
205
 
206
  -----------------------------------------------------------------------------
207
  -- Generate clock enable
208
  -----------------------------------------------------------------------------
209
  en_clk_s <= xtal3_s and wb_en_clk_s;
210
 
211
 
212
  -----------------------------------------------------------------------------
213
  -- Process ea
214
  --
215
  -- Purpose:
216
  --   Detects access to external program memory.
217
  --   Either by ea_i = '1' or when program memory address leaves address
218
  --   range of internal ROM.
219
  --
220
  ea: process (ea_i,
221
               pmem_addr_s)
222
  begin
223
    if ea_i = '1' then
224
      -- Forced external access
225
      ea_s <= '1';
226
 
227
--    elsif unsigned(pmem_addr_s(11 downto rom_addr_width_c)) = 0 then
228
    else
229
      -- Internal access
230
      ea_s <= '0';
231
 
232
--     else
233
--       -- Access to program memory out of internal range
234
--       ea_s <= '1';
235
 
236
    end if;
237
 
238
  end process ea;
239
  --
240
  -----------------------------------------------------------------------------
241
 
242
 
243 180 arniml
  wb_master_b : t48_wb_master
244 169 arniml
    port map (
245
      xtal_i   => xtal_i,
246
      res_i    => reset_n_i,
247
      en_clk_o => wb_en_clk_s,
248
      ale_i    => ale_s,
249
      rd_n_i   => rd_n_s,
250
      wr_n_i   => wr_n_s,
251
      adr_i    => p2_out_s(4),
252
      db_bus_i => db_bus_from_t48,
253
      db_bus_o => db_bus_to_t48,
254
      wb_cyc_o => wb_cyc_o,
255
      wb_stb_o => wb_stb_o,
256
      wb_we_o  => wb_we_o,
257
      wb_adr_o => wb_adr_o,
258
      wb_ack_i => wb_ack_i,
259
      wb_dat_i => wb_dat_i,
260
      wb_dat_o => wb_dat_o
261
    );
262
 
263
 
264
  rom_4k_b : syn_rom
265
    generic map (
266
      address_width_g => rom_addr_width_c
267
    )
268
    port map (
269
      clk_i      => xtal_i,
270
      rom_addr_i => pmem_addr_s(rom_addr_width_c-1 downto 0),
271
      rom_data_o => pmem_data_s
272
    );
273
 
274
  ram_256_b : syn_ram
275
    generic map (
276
      address_width_g => 8
277
    )
278
    port map (
279
      clk_i      => xtal_i,
280
      res_i      => reset_n_i,
281
      ram_addr_i => dmem_addr_s(7 downto 0),
282
      ram_data_i => dmem_data_to_s,
283
      ram_we_i   => dmem_we_s,
284
      ram_data_o => dmem_data_from_s
285
    );
286
 
287
end struct;
288
 
289
 
290
-------------------------------------------------------------------------------
291
-- File History:
292
--
293
-- $Log: not supported by cvs2svn $
294 180 arniml
-- Revision 1.1  2005/05/08 10:36:59  arniml
295
-- initial check-in
296
--
297 169 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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