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

Subversion Repositories t400

[/] [t400/] [trunk/] [rtl/] [vhdl/] [t400_core.vhd] - Blame information for rev 121

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

Line No. Rev Author Line
1 2 arniml
-------------------------------------------------------------------------------
2
--
3
-- T400 Microcontroller Core
4
--
5 121 arniml
-- $Id: t400_core.vhd,v 1.9 2006-06-06 00:33:56 arniml Exp $
6 2 arniml
--
7
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
8
--
9
-- All rights reserved
10
--
11
-- Redistribution and use in source and synthezised forms, with or without
12
-- modification, are permitted provided that the following conditions are met:
13
--
14
-- Redistributions of source code must retain the above copyright notice,
15
-- this list of conditions and the following disclaimer.
16
--
17
-- Redistributions in synthesized form must reproduce the above copyright
18
-- notice, this list of conditions and the following disclaimer in the
19
-- documentation and/or other materials provided with the distribution.
20
--
21
-- Neither the name of the author nor the names of other contributors may
22
-- be used to endorse or promote products derived from this software without
23
-- specific prior written permission.
24
--
25
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
29
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
-- POSSIBILITY OF SUCH DAMAGE.
36
--
37
-- Please report bugs to the author, but before you do so, please
38
-- make sure that this is not a derivative work and that
39
-- you have the latest version of this file.
40
--
41
-- The latest version of this file can be found at:
42
--      http://www.opencores.org/cvsweb.shtml/t400/
43
--
44
-------------------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
 
49
use work.t400_opt_pack.all;
50
 
51
entity t400_core is
52
 
53
  generic (
54
    opt_type_g           : integer := t400_opt_type_420_c;
55
    opt_ck_div_g         : integer := t400_opt_ck_div_16_c;
56
    opt_cko_g            : integer := t400_opt_cko_crystal_c;
57
    opt_l_out_type_7_g   : integer := t400_opt_out_type_std_c;
58
    opt_l_out_type_6_g   : integer := t400_opt_out_type_std_c;
59
    opt_l_out_type_5_g   : integer := t400_opt_out_type_std_c;
60
    opt_l_out_type_4_g   : integer := t400_opt_out_type_std_c;
61
    opt_l_out_type_3_g   : integer := t400_opt_out_type_std_c;
62
    opt_l_out_type_2_g   : integer := t400_opt_out_type_std_c;
63
    opt_l_out_type_1_g   : integer := t400_opt_out_type_std_c;
64
    opt_l_out_type_0_g   : integer := t400_opt_out_type_std_c;
65
    opt_microbus_g       : integer := t400_opt_no_microbus_c;
66
    opt_d_out_type_3_g   : integer := t400_opt_out_type_std_c;
67
    opt_d_out_type_2_g   : integer := t400_opt_out_type_std_c;
68
    opt_d_out_type_1_g   : integer := t400_opt_out_type_std_c;
69
    opt_d_out_type_0_g   : integer := t400_opt_out_type_std_c;
70
    opt_g_out_type_3_g   : integer := t400_opt_out_type_std_c;
71
    opt_g_out_type_2_g   : integer := t400_opt_out_type_std_c;
72
    opt_g_out_type_1_g   : integer := t400_opt_out_type_std_c;
73
    opt_g_out_type_0_g   : integer := t400_opt_out_type_std_c;
74
    opt_so_output_type_g : integer := t400_opt_out_type_std_c;
75
    opt_sk_output_type_g : integer := t400_opt_out_type_std_c
76
  );
77
  port (
78
    ck_i      : in  std_logic;
79
    ck_en_i   : in  std_logic;
80
    por_n_i   : in  std_logic;
81
    reset_n_i : in  std_logic;
82
    cko_i     : in  std_logic;
83
    pm_addr_o : out std_logic_vector(9 downto 0);
84
    pm_data_i : in  std_logic_vector(7 downto 0);
85
    dm_addr_o : out std_logic_vector(5 downto 0);
86
    dm_we_o   : out std_logic;
87
    dm_data_o : out std_logic_vector(3 downto 0);
88
    dm_data_i : in  std_logic_vector(3 downto 0);
89
    io_l_i    : in  std_logic_vector(7 downto 0);
90
    io_l_o    : out std_logic_vector(7 downto 0);
91
    io_l_en_o : out std_logic_vector(7 downto 0);
92
    io_d_o    : out std_logic_vector(3 downto 0);
93
    io_d_en_o : out std_logic_vector(3 downto 0);
94
    io_g_i    : in  std_logic_vector(3 downto 0);
95
    io_g_o    : out std_logic_vector(3 downto 0);
96
    io_g_en_o : out std_logic_vector(3 downto 0);
97
    io_in_i   : in  std_logic_vector(3 downto 0);
98
    si_i      : in  std_logic;
99
    so_o      : out std_logic;
100
    so_en_o   : out std_logic;
101
    sk_o      : out std_logic;
102
    sk_en_o   : out std_logic
103
  );
104
 
105
end t400_core;
106
 
107
 
108
use work.t400_pack.all;
109
use work.t400_comp_pack.all;
110
 
111
architecture struct of t400_core is
112
 
113
  signal ck_en_s         : boolean;
114
  signal por_s           : boolean;
115
  signal res_s           : boolean;
116
 
117
  signal phi1_s          : std_logic;
118
  signal out_en_s        : boolean;
119
  signal in_en_s         : boolean;
120
  signal icyc_en_s       : boolean;
121
 
122
  signal pm_addr_s       : pc_t;
123
 
124
  signal a_s             : dw_t;
125
  signal dec_data_s      : dec_data_t;
126
 
127
  signal pc_to_stack_s,
128
         pc_from_stack_s : pc_t;
129
 
130
  signal q_s             : byte_t;
131
  signal b_s             : b_t;
132
 
133
  signal c_s,
134
         carry_s         : std_logic;
135
 
136
  signal sio_s           : dw_t;
137
 
138
  signal pc_op_s         : pc_op_t;
139
  signal stack_op_s      : stack_op_t;
140
  signal dmem_op_s       : dmem_op_t;
141
  signal b_op_s          : b_op_t;
142
  signal skip_op_s       : skip_op_t;
143
  signal alu_op_s        : alu_op_t;
144
  signal io_l_op_s       : io_l_op_t;
145
  signal io_d_op_s       : io_d_op_t;
146
  signal io_g_op_s       : io_g_op_t;
147 49 arniml
  signal io_in_op_s      : io_in_op_t;
148 2 arniml
  signal sio_op_s        : sio_op_t;
149
  signal is_lbi_s        : boolean;
150
  signal en_s            : dw_t;
151
 
152
  signal skip_s,
153
         skip_lbi_s      : boolean;
154 37 arniml
  signal tim_c_s         : boolean;
155 2 arniml
 
156 49 arniml
  signal in_s            : dw_t;
157 68 arniml
  signal int_s           : boolean;
158 2 arniml
 
159 53 arniml
  signal io_g_s          : std_logic_vector(io_g_i'range);
160
 
161 115 arniml
  signal cs_n_s,
162
         rd_n_s,
163
         wr_n_s          : std_logic;
164
 
165 2 arniml
  signal vdd_s  : std_logic;
166
  signal gnd4_s : dw_t;
167
 
168
begin
169
 
170
  -- dummies
171
  vdd_s  <= '1';
172
  gnd4_s <= (others => '0');
173
 
174
  ck_en_s <= ck_en_i = '1';
175 49 arniml
  por_s   <= por_n_i = '0';
176 2 arniml
 
177 53 arniml
  io_g_s  <= to_X01(io_g_i);
178
 
179 2 arniml
  -----------------------------------------------------------------------------
180
  -- Clock generator
181
  -----------------------------------------------------------------------------
182
  clkgen_b : t400_clkgen
183
    generic map (
184
      opt_ck_div_g => opt_ck_div_g
185
    )
186
    port map (
187
      ck_i      => ck_i,
188
      ck_en_i   => ck_en_s,
189
      por_i     => por_s,
190
      phi1_o    => phi1_s,
191
      out_en_o  => out_en_s,
192
      in_en_o   => in_en_s,
193
      icyc_en_o => icyc_en_s
194
    );
195
 
196
 
197
  -----------------------------------------------------------------------------
198
  -- Reset module
199
  -----------------------------------------------------------------------------
200
  reset_b : t400_reset
201
    port map (
202
      ck_i      => ck_i,
203
      icyc_en_i => icyc_en_s,
204
      por_i     => por_s,
205
      reset_n_i => reset_n_i,
206
      res_o     => res_s
207
    );
208
 
209
 
210
  -----------------------------------------------------------------------------
211
  -- Program memory controller
212
  -----------------------------------------------------------------------------
213
  pmem_ctrl_b : t400_pmem_ctrl
214
    generic map (
215
      opt_type_g => opt_type_g
216
    )
217
    port map (
218
      ck_i       => ck_i,
219
      ck_en_i    => ck_en_s,
220
      por_i      => por_s,
221
      res_i      => res_s,
222
      a_i        => a_s,
223
      m_i        => dm_data_i,
224
      op_i       => pc_op_s,
225
      dec_data_i => dec_data_s,
226
      pc_o       => pc_to_stack_s,
227
      pc_i       => pc_from_stack_s,
228
      pm_addr_o  => pm_addr_s
229
    );
230
  --
231
  pm_addr_o <= std_logic_vector(pm_addr_s);
232
 
233
 
234
  -----------------------------------------------------------------------------
235
  -- Data memory controller
236
  -----------------------------------------------------------------------------
237
  dmem_ctrl_b : t400_dmem_ctrl
238
    generic map (
239
      opt_type_g => opt_type_g
240
    )
241
    port map (
242
      ck_i       => ck_i,
243
      ck_en_i    => ck_en_s,
244
      por_i      => por_s,
245
      res_i      => res_s,
246
      dmem_op_i  => dmem_op_s,
247
      b_op_i     => b_op_s,
248
      dec_data_i => dec_data_s,
249
      a_i        => a_s,
250
      q_high_i   => q_s(7 downto 4),
251
      b_o        => b_s,
252
      dm_addr_o  => dm_addr_o,
253
      dm_data_i  => dm_data_i,
254
      dm_data_o  => dm_data_o,
255
      dm_we_o    => dm_we_o
256
    );
257
 
258
 
259
  -----------------------------------------------------------------------------
260
  -- Decoder
261
  -----------------------------------------------------------------------------
262
  decoder_b : t400_decoder
263
    generic map (
264
      opt_type_g => opt_type_g
265
    )
266
    port map (
267
      ck_i       => ck_i,
268
      ck_en_i    => ck_en_s,
269
      por_i      => por_s,
270
      res_i      => res_s,
271
      out_en_i   => out_en_s,
272
      in_en_i    => in_en_s,
273
      icyc_en_i  => icyc_en_s,
274
      pc_op_o    => pc_op_s,
275
      stack_op_o => stack_op_s,
276
      dmem_op_o  => dmem_op_s,
277
      b_op_o     => b_op_s,
278
      skip_op_o  => skip_op_s,
279
      alu_op_o   => alu_op_s,
280
      io_l_op_o  => io_l_op_s,
281
      io_d_op_o  => io_d_op_s,
282
      io_g_op_o  => io_g_op_s,
283 49 arniml
      io_in_op_o => io_in_op_s,
284 2 arniml
      sio_op_o   => sio_op_s,
285
      dec_data_o => dec_data_s,
286
      en_o       => en_s,
287
      skip_i     => skip_s,
288
      skip_lbi_i => skip_lbi_s,
289 101 arniml
      is_lbi_o   => is_lbi_s,
290 68 arniml
      int_i      => int_s,
291 2 arniml
      pm_addr_i  => pm_addr_s,
292
      pm_data_i  => pm_data_i
293
    );
294
 
295
 
296
  -----------------------------------------------------------------------------
297
  -- Skip logic
298
  -----------------------------------------------------------------------------
299
  skip_b : t400_skip
300 68 arniml
    generic map (
301
      opt_type_g => opt_type_g
302
    )
303 2 arniml
    port map (
304
      ck_i       => ck_i,
305
      ck_en_i    => ck_en_s,
306
      por_i      => por_s,
307
      res_i      => res_s,
308
      op_i       => skip_op_s,
309
      dec_data_i => dec_data_s,
310
      carry_i    => carry_s,
311
      c_i        => c_s,
312
      bd_i       => b_s(bd_range_t),
313
      is_lbi_i   => is_lbi_s,
314 101 arniml
      skip_o     => skip_s,
315
      skip_lbi_o => skip_lbi_s,
316 2 arniml
      a_i        => a_s,
317
      m_i        => dm_data_i,
318 53 arniml
      g_i        => io_g_s,
319 101 arniml
      tim_c_i    => tim_c_s
320 2 arniml
    );
321
 
322
 
323
  -----------------------------------------------------------------------------
324
  -- ALU
325
  -----------------------------------------------------------------------------
326
  alu_b : t400_alu
327 43 arniml
    generic map (
328
      opt_cko_g => opt_cko_g
329
    )
330 2 arniml
    port map (
331
      ck_i       => ck_i,
332
      ck_en_i    => ck_en_s,
333
      por_i      => por_s,
334
      res_i      => res_s,
335 43 arniml
      cko_i      => cko_i,
336 2 arniml
      op_i       => alu_op_s,
337
      m_i        => dm_data_i,
338
      dec_data_i => dec_data_s,
339
      q_low_i    => q_s(3 downto 0),
340
      b_i        => b_s,
341 53 arniml
      g_i        => io_g_s,
342 2 arniml
      in_i       => in_s,
343
      sio_i      => sio_s,
344
      a_o        => a_s,
345
      carry_o    => carry_s,
346
      c_o        => c_s
347
    );
348
 
349
 
350
  -----------------------------------------------------------------------------
351
  -- Stack module
352
  -----------------------------------------------------------------------------
353
  stack_b : t400_stack
354
    generic map (
355
      opt_type_g => opt_type_g
356
    )
357
    port map (
358
      ck_i    => ck_i,
359
      ck_en_i => ck_en_s,
360
      por_i   => por_s,
361
      op_i    => stack_op_s,
362
      pc_i    => pc_to_stack_s,
363
      pc_o    => pc_from_stack_s
364
    );
365
 
366
 
367
  -----------------------------------------------------------------------------
368
  -- IO L module
369
  -----------------------------------------------------------------------------
370 115 arniml
  cs_n_s <= io_in_i(2);
371
  rd_n_s <= io_in_i(1);
372
  wr_n_s <= io_in_i(3);
373
  --
374 2 arniml
  io_l_b : t400_io_l
375
    generic map (
376
      opt_out_type_7_g => opt_l_out_type_7_g,
377
      opt_out_type_6_g => opt_l_out_type_6_g,
378
      opt_out_type_5_g => opt_l_out_type_5_g,
379
      opt_out_type_4_g => opt_l_out_type_4_g,
380
      opt_out_type_3_g => opt_l_out_type_3_g,
381
      opt_out_type_2_g => opt_l_out_type_2_g,
382
      opt_out_type_1_g => opt_l_out_type_1_g,
383
      opt_out_type_0_g => opt_l_out_type_0_g,
384
      opt_microbus_g   => opt_microbus_g
385
    )
386
    port map (
387
      ck_i      => ck_i,
388
      ck_en_i   => ck_en_s,
389
      por_i     => por_s,
390 101 arniml
      in_en_i   => in_en_s,
391 2 arniml
      op_i      => io_l_op_s,
392
      en2_i     => en_s(2),
393
      m_i       => dm_data_i,
394
      a_i       => a_s,
395
      pm_data_i => pm_data_i,
396
      q_o       => q_s,
397 115 arniml
      cs_n_i    => cs_n_s,
398
      rd_n_i    => rd_n_s,
399
      wr_n_i    => wr_n_s,
400 2 arniml
      io_l_i    => io_l_i,
401
      io_l_o    => io_l_o,
402
      io_l_en_o => io_l_en_o
403
    );
404
 
405
 
406
  -----------------------------------------------------------------------------
407
  -- IO D module
408
  -----------------------------------------------------------------------------
409
  io_d_b : t400_io_d
410
    generic map (
411
      opt_out_type_3_g => opt_d_out_type_3_g,
412
      opt_out_type_2_g => opt_d_out_type_2_g,
413
      opt_out_type_1_g => opt_d_out_type_1_g,
414
      opt_out_type_0_g => opt_d_out_type_0_g
415
    )
416
    port map (
417
      ck_i      => ck_i,
418
      ck_en_i   => ck_en_s,
419
      por_i     => por_s,
420
      res_i     => res_s,
421
      op_i      => io_d_op_s,
422
      bd_i      => b_s(bd_range_t),
423
      io_d_o    => io_d_o,
424
      io_d_en_o => io_d_en_o
425
    );
426
 
427
 
428
  -----------------------------------------------------------------------------
429 49 arniml
  -- IO G module
430 2 arniml
  -----------------------------------------------------------------------------
431
  io_g_b : t400_io_g
432
    generic map (
433
      opt_out_type_3_g => opt_g_out_type_3_g,
434
      opt_out_type_2_g => opt_g_out_type_2_g,
435
      opt_out_type_1_g => opt_g_out_type_1_g,
436 115 arniml
      opt_out_type_0_g => opt_g_out_type_0_g,
437
      opt_microbus_g   => opt_microbus_g
438 2 arniml
    )
439
    port map (
440
      ck_i       => ck_i,
441
      ck_en_i    => ck_en_s,
442
      por_i      => por_s,
443
      res_i      => res_s,
444 115 arniml
      cs_n_i     => cs_n_s,
445
      wr_n_i     => wr_n_s,
446 2 arniml
      op_i       => io_g_op_s,
447
      m_i        => dm_data_i,
448
      dec_data_i => dec_data_s,
449
      io_g_o     => io_g_o,
450
      io_g_en_o  => io_g_en_o
451
    );
452
 
453
 
454
  -----------------------------------------------------------------------------
455 49 arniml
  -- IO IN module
456
  -----------------------------------------------------------------------------
457
  use_in: if opt_type_g = t400_opt_type_420_c generate
458
    io_in_b : t400_io_in
459
      port map (
460 68 arniml
        ck_i      => ck_i,
461
        ck_en_i   => ck_en_s,
462
        por_i     => por_s,
463
        icyc_en_i => icyc_en_s,
464
        in_en_i   => in_en_s,
465
        op_i      => io_in_op_s,
466
        en1_i     => en_s(1),
467
        io_in_i   => io_in_i,
468
        in_o      => in_s,
469
        int_o     => int_s
470 49 arniml
      );
471
  end generate;
472
 
473
  no_in: if opt_type_g /= t400_opt_type_420_c generate
474 68 arniml
    in_s  <= (others => '0');
475
    int_s <= false;
476 49 arniml
  end generate;
477
 
478
 
479
  -----------------------------------------------------------------------------
480 2 arniml
  -- SIO module
481
  -----------------------------------------------------------------------------
482
  sio_b : t400_sio
483
    generic map (
484
      opt_so_output_type_g => opt_so_output_type_g,
485
      opt_sk_output_type_g => opt_sk_output_type_g
486
    )
487
    port map (
488
      ck_i       => ck_i,
489
      ck_en_i    => ck_en_s,
490
      por_i      => por_s,
491
      res_i      => res_s,
492
      phi1_i     => phi1_s,
493
      out_en_i   => out_en_s,
494
      in_en_i    => in_en_s,
495
      op_i       => sio_op_s,
496
      en0_i      => en_s(0),
497
      en3_i      => en_s(3),
498
      a_i        => a_s,
499
      c_i        => c_s,
500
      sio_o      => sio_s,
501
      si_i       => si_i,
502
      so_o       => so_o,
503
      so_en_o    => so_en_o,
504
      sk_o       => sk_o,
505
      sk_en_o    => sk_en_o
506
    );
507
 
508 37 arniml
 
509
  -----------------------------------------------------------------------------
510
  -- Timer module
511
  -----------------------------------------------------------------------------
512 49 arniml
  use_tim: if opt_type_g = t400_opt_type_420_c generate
513 37 arniml
    timer_b : t400_timer
514
      port map (
515
        ck_i      => ck_i,
516
        ck_en_i   => ck_en_s,
517
        por_i     => por_s,
518
        icyc_en_i => icyc_en_s,
519
        op_i      => skip_op_s,
520
        c_o       => tim_c_s
521
      );
522
  end generate;
523
 
524
  notim: if opt_type_g /= t400_opt_type_420_c generate
525
    tim_c_s <= false;
526
  end generate;
527
 
528 2 arniml
end struct;
529
 
530
 
531
-------------------------------------------------------------------------------
532
-- File History:
533
--
534
-- $Log: not supported by cvs2svn $
535 121 arniml
-- Revision 1.8  2006/06/05 20:34:21  arniml
536
-- use dedicated microbus cs/rd/wr strobes
537
--
538 115 arniml
-- Revision 1.7  2006/06/05 14:19:15  arniml
539
-- connect microbus control signals to IO L
540
--
541 101 arniml
-- Revision 1.6  2006/05/27 19:11:33  arniml
542
-- updates for interrupt support
543
--
544 68 arniml
-- Revision 1.5  2006/05/23 01:13:56  arniml
545
-- use to_X01 for G input
546
--
547 53 arniml
-- Revision 1.4  2006/05/22 00:03:29  arniml
548
-- io_in added
549
--
550 49 arniml
-- Revision 1.3  2006/05/21 21:47:40  arniml
551
-- route cko to ALU for INIL instruction
552
--
553 43 arniml
-- Revision 1.2  2006/05/20 02:48:17  arniml
554
-- timer module included
555
--
556 37 arniml
-- Revision 1.1.1.1  2006/05/06 01:56:44  arniml
557
-- import from local CVS repository, LOC_CVS_0_1
558
--
559 2 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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