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

Subversion Repositories t400

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

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

powered by: WebSVN 2.1.0

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