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

Subversion Repositories t400

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

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 101 arniml
-- $Id: t400_core.vhd,v 1.7 2006-06-05 14:19:15 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
-- Limitations :
45
-- =============
46
--
47
-- Compared to the original COP400 architecture, the following limitations
48
-- apply:
49
--
50
--   * Features of the COP42x devices are either not yet implemented or
51
--     not verified.
52
--
53
-------------------------------------------------------------------------------
54
 
55
library ieee;
56
use ieee.std_logic_1164.all;
57
 
58
use work.t400_opt_pack.all;
59
 
60
entity t400_core is
61
 
62
  generic (
63
    opt_type_g           : integer := t400_opt_type_420_c;
64
    opt_ck_div_g         : integer := t400_opt_ck_div_16_c;
65
    opt_cko_g            : integer := t400_opt_cko_crystal_c;
66
    opt_l_out_type_7_g   : integer := t400_opt_out_type_std_c;
67
    opt_l_out_type_6_g   : integer := t400_opt_out_type_std_c;
68
    opt_l_out_type_5_g   : integer := t400_opt_out_type_std_c;
69
    opt_l_out_type_4_g   : integer := t400_opt_out_type_std_c;
70
    opt_l_out_type_3_g   : integer := t400_opt_out_type_std_c;
71
    opt_l_out_type_2_g   : integer := t400_opt_out_type_std_c;
72
    opt_l_out_type_1_g   : integer := t400_opt_out_type_std_c;
73
    opt_l_out_type_0_g   : integer := t400_opt_out_type_std_c;
74
    opt_microbus_g       : integer := t400_opt_no_microbus_c;
75
    opt_d_out_type_3_g   : integer := t400_opt_out_type_std_c;
76
    opt_d_out_type_2_g   : integer := t400_opt_out_type_std_c;
77
    opt_d_out_type_1_g   : integer := t400_opt_out_type_std_c;
78
    opt_d_out_type_0_g   : integer := t400_opt_out_type_std_c;
79
    opt_g_out_type_3_g   : integer := t400_opt_out_type_std_c;
80
    opt_g_out_type_2_g   : integer := t400_opt_out_type_std_c;
81
    opt_g_out_type_1_g   : integer := t400_opt_out_type_std_c;
82
    opt_g_out_type_0_g   : integer := t400_opt_out_type_std_c;
83
    opt_so_output_type_g : integer := t400_opt_out_type_std_c;
84
    opt_sk_output_type_g : integer := t400_opt_out_type_std_c
85
  );
86
  port (
87
    ck_i      : in  std_logic;
88
    ck_en_i   : in  std_logic;
89
    por_n_i   : in  std_logic;
90
    reset_n_i : in  std_logic;
91
    cko_i     : in  std_logic;
92
    pm_addr_o : out std_logic_vector(9 downto 0);
93
    pm_data_i : in  std_logic_vector(7 downto 0);
94
    dm_addr_o : out std_logic_vector(5 downto 0);
95
    dm_we_o   : out std_logic;
96
    dm_data_o : out std_logic_vector(3 downto 0);
97
    dm_data_i : in  std_logic_vector(3 downto 0);
98
    io_l_i    : in  std_logic_vector(7 downto 0);
99
    io_l_o    : out std_logic_vector(7 downto 0);
100
    io_l_en_o : out std_logic_vector(7 downto 0);
101
    io_d_o    : out std_logic_vector(3 downto 0);
102
    io_d_en_o : out std_logic_vector(3 downto 0);
103
    io_g_i    : in  std_logic_vector(3 downto 0);
104
    io_g_o    : out std_logic_vector(3 downto 0);
105
    io_g_en_o : out std_logic_vector(3 downto 0);
106
    io_in_i   : in  std_logic_vector(3 downto 0);
107
    si_i      : in  std_logic;
108
    so_o      : out std_logic;
109
    so_en_o   : out std_logic;
110
    sk_o      : out std_logic;
111
    sk_en_o   : out std_logic
112
  );
113
 
114
end t400_core;
115
 
116
 
117
use work.t400_pack.all;
118
use work.t400_comp_pack.all;
119
 
120
architecture struct of t400_core is
121
 
122
  signal ck_en_s         : boolean;
123
  signal por_s           : boolean;
124
  signal res_s           : boolean;
125
 
126
  signal phi1_s          : std_logic;
127
  signal out_en_s        : boolean;
128
  signal in_en_s         : boolean;
129
  signal icyc_en_s       : boolean;
130
 
131
  signal pm_addr_s       : pc_t;
132
 
133
  signal a_s             : dw_t;
134
  signal dec_data_s      : dec_data_t;
135
 
136
  signal pc_to_stack_s,
137
         pc_from_stack_s : pc_t;
138
 
139
  signal q_s             : byte_t;
140
  signal b_s             : b_t;
141
 
142
  signal c_s,
143
         carry_s         : std_logic;
144
 
145
  signal sio_s           : dw_t;
146
 
147
  signal pc_op_s         : pc_op_t;
148
  signal stack_op_s      : stack_op_t;
149
  signal dmem_op_s       : dmem_op_t;
150
  signal b_op_s          : b_op_t;
151
  signal skip_op_s       : skip_op_t;
152
  signal alu_op_s        : alu_op_t;
153
  signal io_l_op_s       : io_l_op_t;
154
  signal io_d_op_s       : io_d_op_t;
155
  signal io_g_op_s       : io_g_op_t;
156 49 arniml
  signal io_in_op_s      : io_in_op_t;
157 2 arniml
  signal sio_op_s        : sio_op_t;
158
  signal is_lbi_s        : boolean;
159
  signal en_s            : dw_t;
160
 
161
  signal skip_s,
162
         skip_lbi_s      : boolean;
163 37 arniml
  signal tim_c_s         : boolean;
164 2 arniml
 
165 49 arniml
  signal in_s            : dw_t;
166 68 arniml
  signal int_s           : boolean;
167 2 arniml
 
168 53 arniml
  signal io_g_s          : std_logic_vector(io_g_i'range);
169
 
170 2 arniml
  signal vdd_s  : std_logic;
171
  signal gnd4_s : dw_t;
172
 
173
begin
174
 
175
  -- dummies
176
  vdd_s  <= '1';
177
  gnd4_s <= (others => '0');
178
 
179
  ck_en_s <= ck_en_i = '1';
180 49 arniml
  por_s   <= por_n_i = '0';
181 2 arniml
 
182 53 arniml
  io_g_s  <= to_X01(io_g_i);
183
 
184 2 arniml
  -----------------------------------------------------------------------------
185
  -- Clock generator
186
  -----------------------------------------------------------------------------
187
  clkgen_b : t400_clkgen
188
    generic map (
189
      opt_ck_div_g => opt_ck_div_g
190
    )
191
    port map (
192
      ck_i      => ck_i,
193
      ck_en_i   => ck_en_s,
194
      por_i     => por_s,
195
      phi1_o    => phi1_s,
196
      out_en_o  => out_en_s,
197
      in_en_o   => in_en_s,
198
      icyc_en_o => icyc_en_s
199
    );
200
 
201
 
202
  -----------------------------------------------------------------------------
203
  -- Reset module
204
  -----------------------------------------------------------------------------
205
  reset_b : t400_reset
206
    port map (
207
      ck_i      => ck_i,
208
      icyc_en_i => icyc_en_s,
209
      por_i     => por_s,
210
      reset_n_i => reset_n_i,
211
      res_o     => res_s
212
    );
213
 
214
 
215
  -----------------------------------------------------------------------------
216
  -- Program memory controller
217
  -----------------------------------------------------------------------------
218
  pmem_ctrl_b : t400_pmem_ctrl
219
    generic map (
220
      opt_type_g => opt_type_g
221
    )
222
    port map (
223
      ck_i       => ck_i,
224
      ck_en_i    => ck_en_s,
225
      por_i      => por_s,
226
      res_i      => res_s,
227
      a_i        => a_s,
228
      m_i        => dm_data_i,
229
      op_i       => pc_op_s,
230
      dec_data_i => dec_data_s,
231
      pc_o       => pc_to_stack_s,
232
      pc_i       => pc_from_stack_s,
233
      pm_addr_o  => pm_addr_s
234
    );
235
  --
236
  pm_addr_o <= std_logic_vector(pm_addr_s);
237
 
238
 
239
  -----------------------------------------------------------------------------
240
  -- Data memory controller
241
  -----------------------------------------------------------------------------
242
  dmem_ctrl_b : t400_dmem_ctrl
243
    generic map (
244
      opt_type_g => opt_type_g
245
    )
246
    port map (
247
      ck_i       => ck_i,
248
      ck_en_i    => ck_en_s,
249
      por_i      => por_s,
250
      res_i      => res_s,
251
      dmem_op_i  => dmem_op_s,
252
      b_op_i     => b_op_s,
253
      dec_data_i => dec_data_s,
254
      a_i        => a_s,
255
      q_high_i   => q_s(7 downto 4),
256
      b_o        => b_s,
257
      dm_addr_o  => dm_addr_o,
258
      dm_data_i  => dm_data_i,
259
      dm_data_o  => dm_data_o,
260
      dm_we_o    => dm_we_o
261
    );
262
 
263
 
264
  -----------------------------------------------------------------------------
265
  -- Decoder
266
  -----------------------------------------------------------------------------
267
  decoder_b : t400_decoder
268
    generic map (
269
      opt_type_g => opt_type_g
270
    )
271
    port map (
272
      ck_i       => ck_i,
273
      ck_en_i    => ck_en_s,
274
      por_i      => por_s,
275
      res_i      => res_s,
276
      out_en_i   => out_en_s,
277
      in_en_i    => in_en_s,
278
      icyc_en_i  => icyc_en_s,
279
      pc_op_o    => pc_op_s,
280
      stack_op_o => stack_op_s,
281
      dmem_op_o  => dmem_op_s,
282
      b_op_o     => b_op_s,
283
      skip_op_o  => skip_op_s,
284
      alu_op_o   => alu_op_s,
285
      io_l_op_o  => io_l_op_s,
286
      io_d_op_o  => io_d_op_s,
287
      io_g_op_o  => io_g_op_s,
288 49 arniml
      io_in_op_o => io_in_op_s,
289 2 arniml
      sio_op_o   => sio_op_s,
290
      dec_data_o => dec_data_s,
291
      en_o       => en_s,
292
      skip_i     => skip_s,
293
      skip_lbi_i => skip_lbi_s,
294 101 arniml
      is_lbi_o   => is_lbi_s,
295 68 arniml
      int_i      => int_s,
296 2 arniml
      pm_addr_i  => pm_addr_s,
297
      pm_data_i  => pm_data_i
298
    );
299
 
300
 
301
  -----------------------------------------------------------------------------
302
  -- Skip logic
303
  -----------------------------------------------------------------------------
304
  skip_b : t400_skip
305 68 arniml
    generic map (
306
      opt_type_g => opt_type_g
307
    )
308 2 arniml
    port map (
309
      ck_i       => ck_i,
310
      ck_en_i    => ck_en_s,
311
      por_i      => por_s,
312
      res_i      => res_s,
313
      op_i       => skip_op_s,
314
      dec_data_i => dec_data_s,
315
      carry_i    => carry_s,
316
      c_i        => c_s,
317
      bd_i       => b_s(bd_range_t),
318
      is_lbi_i   => is_lbi_s,
319 101 arniml
      skip_o     => skip_s,
320
      skip_lbi_o => skip_lbi_s,
321 2 arniml
      a_i        => a_s,
322
      m_i        => dm_data_i,
323 53 arniml
      g_i        => io_g_s,
324 101 arniml
      tim_c_i    => tim_c_s
325 2 arniml
    );
326
 
327
 
328
  -----------------------------------------------------------------------------
329
  -- ALU
330
  -----------------------------------------------------------------------------
331
  alu_b : t400_alu
332 43 arniml
    generic map (
333
      opt_cko_g => opt_cko_g
334
    )
335 2 arniml
    port map (
336
      ck_i       => ck_i,
337
      ck_en_i    => ck_en_s,
338
      por_i      => por_s,
339
      res_i      => res_s,
340 43 arniml
      cko_i      => cko_i,
341 2 arniml
      op_i       => alu_op_s,
342
      m_i        => dm_data_i,
343
      dec_data_i => dec_data_s,
344
      q_low_i    => q_s(3 downto 0),
345
      b_i        => b_s,
346 53 arniml
      g_i        => io_g_s,
347 2 arniml
      in_i       => in_s,
348
      sio_i      => sio_s,
349
      a_o        => a_s,
350
      carry_o    => carry_s,
351
      c_o        => c_s
352
    );
353
 
354
 
355
  -----------------------------------------------------------------------------
356
  -- Stack module
357
  -----------------------------------------------------------------------------
358
  stack_b : t400_stack
359
    generic map (
360
      opt_type_g => opt_type_g
361
    )
362
    port map (
363
      ck_i    => ck_i,
364
      ck_en_i => ck_en_s,
365
      por_i   => por_s,
366
      op_i    => stack_op_s,
367
      pc_i    => pc_to_stack_s,
368
      pc_o    => pc_from_stack_s
369
    );
370
 
371
 
372
  -----------------------------------------------------------------------------
373
  -- IO L module
374
  -----------------------------------------------------------------------------
375
  io_l_b : t400_io_l
376
    generic map (
377
      opt_out_type_7_g => opt_l_out_type_7_g,
378
      opt_out_type_6_g => opt_l_out_type_6_g,
379
      opt_out_type_5_g => opt_l_out_type_5_g,
380
      opt_out_type_4_g => opt_l_out_type_4_g,
381
      opt_out_type_3_g => opt_l_out_type_3_g,
382
      opt_out_type_2_g => opt_l_out_type_2_g,
383
      opt_out_type_1_g => opt_l_out_type_1_g,
384
      opt_out_type_0_g => opt_l_out_type_0_g,
385
      opt_microbus_g   => opt_microbus_g
386
    )
387
    port map (
388
      ck_i      => ck_i,
389
      ck_en_i   => ck_en_s,
390
      por_i     => por_s,
391 101 arniml
      in_en_i   => in_en_s,
392 2 arniml
      op_i      => io_l_op_s,
393
      en2_i     => en_s(2),
394
      m_i       => dm_data_i,
395
      a_i       => a_s,
396
      pm_data_i => pm_data_i,
397
      q_o       => q_s,
398 101 arniml
      cs_n_i    => io_in_i(2),
399
      rd_n_i    => io_in_i(1),
400
      wr_n_i    => io_in_i(3),
401 2 arniml
      io_l_i    => io_l_i,
402
      io_l_o    => io_l_o,
403
      io_l_en_o => io_l_en_o
404
    );
405
 
406
 
407
  -----------------------------------------------------------------------------
408
  -- IO D module
409
  -----------------------------------------------------------------------------
410
  io_d_b : t400_io_d
411
    generic map (
412
      opt_out_type_3_g => opt_d_out_type_3_g,
413
      opt_out_type_2_g => opt_d_out_type_2_g,
414
      opt_out_type_1_g => opt_d_out_type_1_g,
415
      opt_out_type_0_g => opt_d_out_type_0_g
416
    )
417
    port map (
418
      ck_i      => ck_i,
419
      ck_en_i   => ck_en_s,
420
      por_i     => por_s,
421
      res_i     => res_s,
422
      op_i      => io_d_op_s,
423
      bd_i      => b_s(bd_range_t),
424
      io_d_o    => io_d_o,
425
      io_d_en_o => io_d_en_o
426
    );
427
 
428
 
429
  -----------------------------------------------------------------------------
430 49 arniml
  -- IO G module
431 2 arniml
  -----------------------------------------------------------------------------
432
  io_g_b : t400_io_g
433
    generic map (
434
      opt_out_type_3_g => opt_g_out_type_3_g,
435
      opt_out_type_2_g => opt_g_out_type_2_g,
436
      opt_out_type_1_g => opt_g_out_type_1_g,
437
      opt_out_type_0_g => opt_g_out_type_0_g
438
    )
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
      op_i       => io_g_op_s,
445
      m_i        => dm_data_i,
446
      dec_data_i => dec_data_s,
447
      io_g_o     => io_g_o,
448
      io_g_en_o  => io_g_en_o
449
    );
450
 
451
 
452
  -----------------------------------------------------------------------------
453 49 arniml
  -- IO IN module
454
  -----------------------------------------------------------------------------
455
  use_in: if opt_type_g = t400_opt_type_420_c generate
456
    io_in_b : t400_io_in
457
      port map (
458 68 arniml
        ck_i      => ck_i,
459
        ck_en_i   => ck_en_s,
460
        por_i     => por_s,
461
        icyc_en_i => icyc_en_s,
462
        in_en_i   => in_en_s,
463
        op_i      => io_in_op_s,
464
        en1_i     => en_s(1),
465
        io_in_i   => io_in_i,
466
        in_o      => in_s,
467
        int_o     => int_s
468 49 arniml
      );
469
  end generate;
470
 
471
  no_in: if opt_type_g /= t400_opt_type_420_c generate
472 68 arniml
    in_s  <= (others => '0');
473
    int_s <= false;
474 49 arniml
  end generate;
475
 
476
 
477
  -----------------------------------------------------------------------------
478 2 arniml
  -- SIO module
479
  -----------------------------------------------------------------------------
480
  sio_b : t400_sio
481
    generic map (
482
      opt_so_output_type_g => opt_so_output_type_g,
483
      opt_sk_output_type_g => opt_sk_output_type_g
484
    )
485
    port map (
486
      ck_i       => ck_i,
487
      ck_en_i    => ck_en_s,
488
      por_i      => por_s,
489
      res_i      => res_s,
490
      phi1_i     => phi1_s,
491
      out_en_i   => out_en_s,
492
      in_en_i    => in_en_s,
493
      op_i       => sio_op_s,
494
      en0_i      => en_s(0),
495
      en3_i      => en_s(3),
496
      a_i        => a_s,
497
      c_i        => c_s,
498
      sio_o      => sio_s,
499
      si_i       => si_i,
500
      so_o       => so_o,
501
      so_en_o    => so_en_o,
502
      sk_o       => sk_o,
503
      sk_en_o    => sk_en_o
504
    );
505
 
506 37 arniml
 
507
  -----------------------------------------------------------------------------
508
  -- Timer module
509
  -----------------------------------------------------------------------------
510 49 arniml
  use_tim: if opt_type_g = t400_opt_type_420_c generate
511 37 arniml
    timer_b : t400_timer
512
      port map (
513
        ck_i      => ck_i,
514
        ck_en_i   => ck_en_s,
515
        por_i     => por_s,
516
        icyc_en_i => icyc_en_s,
517
        op_i      => skip_op_s,
518
        c_o       => tim_c_s
519
      );
520
  end generate;
521
 
522
  notim: if opt_type_g /= t400_opt_type_420_c generate
523
    tim_c_s <= false;
524
  end generate;
525
 
526 2 arniml
end struct;
527
 
528
 
529
-------------------------------------------------------------------------------
530
-- File History:
531
--
532
-- $Log: not supported by cvs2svn $
533 101 arniml
-- Revision 1.6  2006/05/27 19:11:33  arniml
534
-- updates for interrupt support
535
--
536 68 arniml
-- Revision 1.5  2006/05/23 01:13:56  arniml
537
-- use to_X01 for G input
538
--
539 53 arniml
-- Revision 1.4  2006/05/22 00:03:29  arniml
540
-- io_in added
541
--
542 49 arniml
-- Revision 1.3  2006/05/21 21:47:40  arniml
543
-- route cko to ALU for INIL instruction
544
--
545 43 arniml
-- Revision 1.2  2006/05/20 02:48:17  arniml
546
-- timer module included
547
--
548 37 arniml
-- Revision 1.1.1.1  2006/05/06 01:56:44  arniml
549
-- import from local CVS repository, LOC_CVS_0_1
550
--
551 2 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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