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

Subversion Repositories t400

[/] [t400/] [trunk/] [rtl/] [vhdl/] [t400_decoder.vhd] - Blame information for rev 88

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

Line No. Rev Author Line
1 2 arniml
-------------------------------------------------------------------------------
2
--
3
-- The decoder unit.
4
-- Implements the instruction opcodes and controls all units of the T400 core.
5
--
6 88 arniml
-- $Id: t400_decoder.vhd,v 1.5 2006-05-28 15:32:14 arniml Exp $
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
use work.t400_pack.all;
52
 
53
entity t400_decoder is
54
 
55
  generic (
56
    opt_type_g : integer := t400_opt_type_420_c
57
  );
58
  port (
59
    ck_i       : in  std_logic;
60
    ck_en_i    : in  boolean;
61
    por_i      : in  boolean;
62
    res_i      : in  boolean;
63
    out_en_i   : in  boolean;
64
    in_en_i    : in  boolean;
65
    icyc_en_i  : in  boolean;
66
    pc_op_o    : out pc_op_t;
67
    stack_op_o : out stack_op_t;
68
    dmem_op_o  : out dmem_op_t;
69
    b_op_o     : out b_op_t;
70
    skip_op_o  : out skip_op_t;
71
    alu_op_o   : out alu_op_t;
72
    io_l_op_o  : out io_l_op_t;
73
    io_d_op_o  : out io_d_op_t;
74
    io_g_op_o  : out io_g_op_t;
75 48 arniml
    io_in_op_o : out io_in_op_t;
76 2 arniml
    sio_op_o   : out sio_op_t;
77
    dec_data_o : out dec_data_t;
78
    is_lbi_o   : out boolean;
79
    en_o       : out dw_t;
80
    skip_i     : in  boolean;
81
    skip_lbi_i : in  boolean;
82 70 arniml
    int_i      : in  boolean;
83 2 arniml
    pm_addr_i  : in  pc_t;
84
    pm_data_i  : in  byte_t
85
  );
86
 
87
end t400_decoder;
88
 
89
 
90
library ieee;
91
use ieee.numeric_std.all;
92
 
93
use work.t400_comp_pack.t400_opc_table;
94
 
95
architecture rtl of t400_decoder is
96
 
97
  signal cyc_cnt_q    : unsigned(2 downto 0);
98
  signal ibyte1_q,
99
         ibyte2_q     : byte_t;
100
 
101
  signal opcode_s     : byte_t;
102
  signal second_cyc_q : boolean;
103
  signal mnemonic_s,
104
         mnemonic_q   : mnemonic_t;
105
  signal multi_byte_s,
106
         multi_byte_q : boolean;
107
  signal last_cycle_s : boolean;
108
  signal force_mc_s   : boolean;
109
 
110
  signal en_q         : dw_t;
111
  signal set_en_s     : boolean;
112 70 arniml
  signal ack_int_s    : boolean;
113 2 arniml
 
114
begin
115
 
116
  -----------------------------------------------------------------------------
117
  -- Theory of operation:
118
  --
119 70 arniml
  -- a) One instruction cycle lasts at least 4 ck_i cycles.
120 2 arniml
  -- b) PC for instruction/parameter fetch must be valid during cycle 2.
121
  --      => cycle 2 is the opcode fetch cycle
122
  -- c) Cycle 3 is the opcode decode cycle.
123
  --      => opcode_s is valid with cycle 3
124
  -- d) mnemonic_q is then valid with cycle 0 until end of instruction.
125
  --    So is ibyte1_q.
126
  -- e) PC for is incremented during last instruction cycle.
127
  --      => fetch of either new instruction or second instruction byte
128
  -- f) Second instruction byte is saved in ibyte2_q for cycle 0.
129
  --    Valid until end of instruction.
130
  --
131
  -- Constraints:
132
  --
133
  -- a) PC of next instruction must be pushed in cycle 0 or 1.
134
  -- b) PC for next instruction must be poped latest in cycle 1.
135
  -- c) PC for next instruction can only be calculated latest in cycle 1.
136
  -- d) IO output is enabled by out_en_i
137
  -- e) IO inputs are sampled with in_en_i
138
  --
139
  -- d) and e) are required for proper timing in relation to phi1
140
  -- (SK clock/sync output).
141
  --
142
  -- Conventions:
143
  --
144
  -- a) ALU operations take place in cycle 1.
145
  --
146
  -----------------------------------------------------------------------------
147
 
148
  last_cycle_s <= (not multi_byte_q and
149
                   not second_cyc_q and not force_mc_s)
150
                  or
151
                  second_cyc_q;
152
 
153
 
154
  -----------------------------------------------------------------------------
155
  -- Process seq
156
  --
157
  -- Purpose:
158
  --   Implements the various sequential elements.
159
  --     Cycle counter:
160
  --       It identifies the execution cycle of the
161
  --       current instruction.
162
  --     Instruction registers:
163
  --       They save the first and second byte of an instruction for
164
  --       further processing.
165
  --     New instruction flag:
166
  --       Indicates when a new instruction is fetched from the program
167
  --       memory. Implemented as a flip-flop to control the multiplexer
168
  --       which saves power by gating the combinational opcode decoder.
169
  --     Mnemonic register:
170
  --       Latches the decoded mnemonic of the current instruction.
171
  --     Multi byte flag:
172
  --       Latches the decoded multi byte status information.
173
  --
174
  seq: process (ck_i, por_i)
175
  begin
176
    if por_i then
177
      cyc_cnt_q    <= to_unsigned(1, cyc_cnt_q'length);
178
      second_cyc_q <= false;
179
      ibyte1_q     <= (others => '0');
180
      ibyte2_q     <= (others => '0');
181
      mnemonic_q   <= MN_CLRA;
182
      multi_byte_q <= false;
183
      en_q         <= (others => '0');
184
 
185
    elsif ck_i'event and ck_i = '1' then
186
      if    res_i then
187
        -- synchronous reset upon external reset event
188
        mnemonic_q     <= MN_CLRA;
189
        multi_byte_q   <= false;
190
        cyc_cnt_q      <= (others => '0');
191
        en_q           <= (others => '0');
192
 
193
      elsif ck_en_i then
194
        -- cycle counter ------------------------------------------------------
195
        if    icyc_en_i then
196
          -- new instruction cycle started
197
          cyc_cnt_q    <= (others => '0');
198
        elsif cyc_cnt_q /= 4 then
199
          cyc_cnt_q    <= cyc_cnt_q + 1;
200
        end if;
201
 
202
        -- second cycle flag --------------------------------------------------
203
        if icyc_en_i then
204
          if not last_cycle_s then
205
            second_cyc_q <= true;
206
          else
207
            second_cyc_q <= false;
208
          end if;
209
        end if;
210
 
211
        -- instruction byte 1 and mnemonic info -------------------------------
212
        if icyc_en_i and last_cycle_s then
213 88 arniml
          if not ack_int_s then
214
            -- update instruction descriptors in normal mode
215
            ibyte1_q     <= pm_data_i;
216
            mnemonic_q   <= mnemonic_s;
217
            multi_byte_q <= multi_byte_s;
218
          else
219
            -- force NOP instruction when vectoring to interrupt routine
220
            ibyte1_q     <= "01000100";
221
            mnemonic_q   <= MN_NOP;
222
            multi_byte_q <= false;
223
          end if;
224 2 arniml
        end if;
225
 
226
        -- instruction byte 2 -------------------------------------------------
227
        if icyc_en_i and not last_cycle_s then
228
          ibyte2_q     <= pm_data_i;
229
        end if;
230
 
231
        -- EN register --------------------------------------------------------
232 70 arniml
        if    set_en_s then
233 2 arniml
          en_q         <= ibyte2_q(dw_range_t);
234 70 arniml
        elsif ack_int_s then
235
          -- reset interrupt enable when INT has been acknowledged
236
          en_q(1)      <= '0';
237 2 arniml
        end if;
238
 
239
      end if;
240
    end if;
241
  end process seq;
242
  --
243
  -----------------------------------------------------------------------------
244
 
245
 
246
  -----------------------------------------------------------------------------
247
  -- Opcode multiplexer
248
  -----------------------------------------------------------------------------
249
  opcode_s <=   pm_data_i
250
              when icyc_en_i else
251
                ibyte1_q;
252
 
253
  -----------------------------------------------------------------------------
254
  -- Opcode decoder table
255
  -----------------------------------------------------------------------------
256
  opc_table_b : t400_opc_table
257
    generic map (
258
      opt_type_g   => opt_type_g
259
    )
260
    port map (
261
      opcode_i     => opcode_s,
262
      mnemonic_o   => mnemonic_s,
263
      multi_byte_o => multi_byte_s
264
    );
265
 
266
 
267
  -----------------------------------------------------------------------------
268
  -- Process decoder_ctrl
269
  --
270
  -- Purpose:
271
  --   Implements the controlling logic of the decoder module.
272
  --
273
  decoder_ctrl: process (icyc_en_i,
274
                         out_en_i, in_en_i,
275
                         cyc_cnt_q,
276 12 arniml
                         mnemonic_q, second_cyc_q, last_cycle_s,
277 2 arniml
                         ibyte1_q, ibyte2_q,
278
                         skip_i, skip_lbi_i,
279 70 arniml
                         en_q, int_i,
280 2 arniml
                         pm_addr_i, pm_data_i)
281 70 arniml
    variable cyc_v        : natural range 0 to 4;
282
    variable t41x_type_v,
283
             t420_type_v  : boolean;
284 88 arniml
    variable en_int_v     : boolean;
285 2 arniml
  begin
286
    -- default assignments
287
    pc_op_o     <= PC_NONE;
288
    stack_op_o  <= STACK_NONE;
289
    dmem_op_o   <= DMEM_RB;             -- default is read via B
290
    b_op_o      <= B_NONE;
291
    skip_op_o   <= SKIP_NONE;
292
    alu_op_o    <= ALU_NONE;
293
    io_l_op_o   <= IOL_NONE;
294
    io_d_op_o   <= IOD_NONE;
295
    io_g_op_o   <= IOG_NONE;
296 48 arniml
    io_in_op_o  <= IOIN_NONE;
297 2 arniml
    sio_op_o    <= SIO_NONE;
298
    dec_data_o  <= (others => '0');
299
    is_lbi_o    <= false;
300
    set_en_s    <= false;
301
    force_mc_s  <= false;
302 88 arniml
    en_int_v    := true;
303 70 arniml
    ack_int_s   <= false;
304 2 arniml
    cyc_v       := to_integer(cyc_cnt_q);
305
    -- determine type
306
    t41x_type_v := opt_type_g = t400_opt_type_410_c;
307 70 arniml
    t420_type_v := opt_type_g = t400_opt_type_420_c;
308 2 arniml
 
309
    if icyc_en_i then
310
      -- immediately increment program counter
311
      -- this happens at two occasions:
312
      -- a) right before new mnemonic becomes valid
313
      -- b) before the second instruction cycle begins
314
      pc_op_o   <= PC_INC_PC;
315
    end if;
316
 
317
    if icyc_en_i and last_cycle_s then
318
      -- update skip state when last instruction cycle ends
319
      skip_op_o <= SKIP_UPDATE;
320
    end if;
321
 
322
    -- skip instruction execution
323
    if not skip_i then
324
      -- implement instruction control
325
      case mnemonic_q is
326
        -- Mnemonic ASC -------------------------------------------------------
327
        when MN_ASC =>
328
          if cyc_v = 1 then
329
            alu_op_o     <= ALU_ADD_C;
330
            skip_op_o    <= SKIP_CARRY;
331
          end if;
332
 
333
        -- Mnemonic ADD -------------------------------------------------------
334
        when MN_ADD =>
335
          if cyc_v = 1 then
336
            alu_op_o     <= ALU_ADD;
337
          end if;
338
 
339
        -- Mnemonic ADT -------------------------------------------------------
340
        when MN_ADT =>
341
          if cyc_v = 1 then
342
            alu_op_o     <= ALU_ADD_10;
343
          end if;
344
 
345
        -- Mnemonic AISC ------------------------------------------------------
346
        when MN_AISC =>
347
          dec_data_o(dw_range_t) <= ibyte1_q(dw_range_t);
348
          if cyc_v = 1 then
349
            alu_op_o     <= ALU_ADD_DEC;
350
            skip_op_o    <= SKIP_CARRY;
351
          end if;
352
 
353
        -- Mnemonic CASC ------------------------------------------------------
354
        when MN_CASC =>
355
          case cyc_v is
356
            when 0 =>
357
              alu_op_o   <= ALU_COMP;
358
            when 1 =>
359
              alu_op_o   <= ALU_ADD_C;
360
              skip_op_o  <= SKIP_CARRY;
361
            when others =>
362
              null;
363
          end case;
364
 
365
        -- Mnemonic CLRA ------------------------------------------------------
366
        when MN_CLRA =>
367
          if cyc_v = 1 then
368
            alu_op_o     <= ALU_CLRA;
369
          end if;
370
 
371
        -- Mnemonic COMP ------------------------------------------------------
372
        when MN_COMP =>
373
          if cyc_v = 1 then
374
            alu_op_o     <= ALU_COMP;
375
          end if;
376
 
377
        -- Mnemonic NOP -------------------------------------------------------
378
        when MN_NOP =>
379
          -- do nothing
380
          null;
381
 
382
        -- Mnemonic C ---------------------------------------------------------
383
        when MN_C =>
384
          if cyc_v = 1 then
385
            if ibyte1_q(4) = '1' then
386
              alu_op_o   <= ALU_RC;
387
            else
388
              alu_op_o   <= ALU_SC;
389
            end if;
390
          end if;
391
 
392
        -- Mnemonic XOR -------------------------------------------------------
393
        when MN_XOR =>
394
          if cyc_v = 1 then
395
            alu_op_o     <= ALU_XOR;
396
          end if;
397
 
398
        -- Mnemonic JID -------------------------------------------------------
399
        when MN_JID =>
400
          force_mc_s     <= true;
401 88 arniml
          en_int_v       := false;
402 2 arniml
          dec_data_o(byte_t'range) <= pm_data_i;
403
          if cyc_v = 1 then
404
            if not second_cyc_q then
405
              -- first cycle: load PC from A and M
406
              pc_op_o    <= PC_LOAD_A_M;
407
            else
408
              -- second cycle: load PC from program memory
409
              pc_op_o    <= PC_LOAD_8;
410
            end if;
411
          end if;
412
 
413
          if icyc_en_i and not second_cyc_q then
414
            -- do not increment PC for second instruction cycle
415
            pc_op_o      <= PC_NONE;
416
          end if;
417
 
418
        -- Mnemonic JMP -------------------------------------------------------
419
        when MN_JMP =>
420 88 arniml
          en_int_v       := false;
421 2 arniml
          dec_data_o <= ibyte1_q(1) & ibyte1_q(0) & ibyte2_q;
422
          if second_cyc_q and cyc_v = 1 then
423
            pc_op_o      <= PC_LOAD;
424
          end if;
425
 
426
        -- Mnemonic JP_JSRP ---------------------------------------------------
427
        when MN_JP_JSRP =>
428 88 arniml
          en_int_v       := false;
429 2 arniml
          -- universal decoder data
430
          dec_data_o <= '0' & "01" & ibyte1_q(6 downto 0);
431
          if cyc_v = 1 then
432
            if    pm_addr_i(9 downto 7) = "001" then
433
              -- JP within pages 2 & 3
434
              pc_op_o    <= PC_LOAD_7;
435
            elsif ibyte1_q(6) = '1' then
436
              -- JP outside of pages 2 & 3
437
              pc_op_o    <= PC_LOAD_6;
438
            else
439
              -- JSRP to page 2
440
              pc_op_o    <= PC_LOAD;
441
              stack_op_o <= STACK_PUSH;
442
            end if;
443
          end if;
444
 
445
        -- Mnemonic JSR -------------------------------------------------------
446
        when MN_JSR =>
447 88 arniml
          en_int_v       := false;
448 2 arniml
          dec_data_o <= ibyte1_q(1) & ibyte1_q(0) & ibyte2_q;
449
          if second_cyc_q and cyc_v = 1 then
450
            pc_op_o      <= PC_LOAD;
451
            stack_op_o   <= STACK_PUSH;
452
          end if;
453
 
454
        -- Mnemonic RET -------------------------------------------------------
455
        when MN_RET =>
456 88 arniml
          en_int_v       := false;
457 2 arniml
          if cyc_v = 1 then
458
            pc_op_o      <= PC_POP;
459
            stack_op_o   <= STACK_POP;
460 70 arniml
 
461
            if t420_type_v then
462
              -- always restore skip state in case this was an interrupt
463
              skip_op_o  <= SKIP_POP;
464
            end if;
465 2 arniml
          end if;
466
 
467
        -- Mnemonic RETSK -----------------------------------------------------
468
        when MN_RETSK =>
469 88 arniml
          en_int_v       := false;
470 2 arniml
          if cyc_v = 1 then
471
            pc_op_o      <= PC_POP;
472
            stack_op_o   <= STACK_POP;
473
            skip_op_o    <= SKIP_NOW;
474
          end if;
475
 
476
        -- Mnemonic LD --------------------------------------------------------
477
        when MN_LD =>
478
          dec_data_o(br_range_t) <= ibyte1_q(br_range_t);
479
          if cyc_v = 1 then
480
            alu_op_o     <= ALU_LOAD_M;
481
            b_op_o       <= B_XOR_BR;
482
          end if;
483
 
484
        -- Mnemonic LDD_XAD ---------------------------------------------------
485
        when MN_LDD_XAD =>
486
          -- preload decoder data
487
          dec_data_o(b_range_t) <= ibyte2_q(b_range_t);
488
 
489
          if second_cyc_q then
490
            case ibyte2_q(7 downto 6) is
491
              -- LDD
492
              when "00" =>
493
                if not t41x_type_v then
494
                  case cyc_v is
495
                    when 1 =>
496
                      dmem_op_o <= DMEM_RDEC;
497
                    when 2 =>
498
                      alu_op_o  <= ALU_LOAD_M;
499
                    when others =>
500
                      null;
501
                  end case;
502
                end if;
503
                -- XAD
504
              when "10" =>
505
                if not t41x_type_v                   or
506
                  unsigned(ibyte2_q(b_range_t)) = 63 then
507
                  case cyc_v is
508
                    when 1 =>
509
                      dmem_op_o <= DMEM_RDEC;
510
                    when 2 =>
511
                      alu_op_o  <= ALU_LOAD_M;
512
                      dmem_op_o <= DMEM_WDEC_SRC_A;
513
                    when others =>
514
                      null;
515
                  end case;
516
                end if;
517
 
518
              when others =>
519
                null;
520
            end case;
521
          end if;
522
 
523
        -- Mnemonic LQID ------------------------------------------------------
524
        when MN_LQID =>
525
          force_mc_s     <= true;
526 88 arniml
          en_int_v       := false;
527 2 arniml
          if not second_cyc_q then
528
            -- first cycle: push PC and set PC from A/M,
529
            --              read IOL from program memory
530
            if cyc_v = 1 then
531
              stack_op_o <= STACK_PUSH;
532
              pc_op_o    <= PC_LOAD_A_M;
533
            end if;
534
 
535
            if out_en_i then
536
              io_l_op_o  <= IOL_LOAD_PM;
537
            end if;
538
          else
539
            if cyc_v = 1 then
540
              -- second cycle: pop PC
541
              stack_op_o <= STACK_POP;
542
              pc_op_o    <= PC_POP;
543
            end if;
544
          end if;
545
 
546
          if icyc_en_i and not second_cyc_q then
547
            -- do not increment PC for second instruction cycle
548
            pc_op_o      <= PC_NONE;
549
          end if;
550
 
551
        -- Mnemonic RMB -------------------------------------------------------
552
        when MN_RMB =>
553
          if cyc_v = 1 then
554
            dmem_op_o  <= DMEM_WB_RES_BIT;
555
            -- select bit to be reset
556
            case ibyte1_q(dw_range_t) is
557
              when "1100" =>
558
                dec_data_o(dw_range_t) <= "0001";
559
              when "0101" =>
560
                dec_data_o(dw_range_t) <= "0010";
561
              when "0010" =>
562
                dec_data_o(dw_range_t) <= "0100";
563
              when "0011" =>
564
                dec_data_o(dw_range_t) <= "1000";
565
              when others =>
566
                null;
567
            end case;
568
          end if;
569
 
570
        -- Mnemonic SMB -------------------------------------------------------
571
        when MN_SMB =>
572
          if cyc_v = 1 then
573
            dmem_op_o  <= DMEM_WB_SET_BIT;
574
            -- select bit to be set
575
            case ibyte1_q(dw_range_t) is
576
              when "1101" =>
577
                dec_data_o(dw_range_t) <= "0001";
578
              when "0111" =>
579
                dec_data_o(dw_range_t) <= "0010";
580
              when "0110" =>
581
                dec_data_o(dw_range_t) <= "0100";
582
              when "1011" =>
583
                dec_data_o(dw_range_t) <= "1000";
584
              when others =>
585
                null;
586
            end case;
587
          end if;
588
 
589
        -- Mnemonic STII ------------------------------------------------------
590
        when MN_STII =>
591
          dec_data_o(dw_range_t) <= ibyte1_q(dw_range_t);
592
          if cyc_v = 1 then
593
            dmem_op_o    <= DMEM_WB_SRC_DEC;
594
            b_op_o       <= B_INC_BD;
595
          end if;
596
 
597
        -- Mnemonic X ---------------------------------------------------------
598
        when MN_X =>
599
          dec_data_o(br_range_t) <= ibyte1_q(br_range_t);
600
          if cyc_v = 1 then
601
            alu_op_o     <= ALU_LOAD_M;
602
            dmem_op_o    <= DMEM_WB_SRC_A;
603
            b_op_o       <= B_XOR_BR;
604
          end if;
605
 
606
        -- Mnemonic XDS -------------------------------------------------------
607
        when MN_XDS =>
608
          dec_data_o(br_range_t) <= ibyte1_q(br_range_t);
609
          case cyc_v is
610
            when 1 =>
611
              alu_op_o   <= ALU_LOAD_M;
612
              dmem_op_o  <= DMEM_WB_SRC_A;
613
              b_op_o     <= B_DEC_BD;
614
            when 2 =>
615
              b_op_o     <= B_XOR_BR;
616
              skip_op_o  <= SKIP_BD_UFLOW;
617
            when others =>
618
              null;
619
          end case;
620
 
621
        -- Mnemonic XIS -------------------------------------------------------
622
        when MN_XIS =>
623
          dec_data_o(br_range_t) <= ibyte1_q(br_range_t);
624
          case cyc_v is
625
            when 1 =>
626
              alu_op_o   <= ALU_LOAD_M;
627
              dmem_op_o  <= DMEM_WB_SRC_A;
628
              b_op_o     <= B_INC_BD;
629
            when 2 =>
630
              b_op_o     <= B_XOR_BR;
631
              skip_op_o  <= SKIP_BD_OFLOW;
632
            when others =>
633
              null;
634
          end case;
635
 
636
        -- Mnemonic CAB -------------------------------------------------------
637
        when MN_CAB =>
638
          if cyc_v = 1 then
639
            b_op_o       <= B_SET_BD;
640
          end if;
641
 
642
        -- Mnemonic CBA -------------------------------------------------------
643
        when MN_CBA =>
644
          if cyc_v = 1 then
645
            alu_op_o     <= ALU_LOAD_BD;
646
          end if;
647
 
648
        -- Mnemonic LBI -------------------------------------------------------
649
        when MN_LBI =>
650
          is_lbi_o       <= true;
651 88 arniml
          en_int_v       := false;
652 2 arniml
          dec_data_o(br_range_t) <= ibyte1_q(br_range_t);
653
          dec_data_o(bd_range_t) <= ibyte1_q(bd_range_t);
654
          if cyc_v = 1 and not skip_lbi_i then
655
            -- increment Bd by 1
656
            b_op_o       <= B_SET_B_INC;
657
            skip_op_o    <= SKIP_LBI;
658
          end if;
659
 
660
        -- Mnemonic XABR ------------------------------------------------------
661
        when MN_XABR =>
662
          if cyc_v = 1 then
663
            alu_op_o     <= ALU_LOAD_BR;
664
            b_op_o       <= B_SET_BR;
665
          end if;
666
 
667
        -- Mnemonic SKC -------------------------------------------------------
668
        when MN_SKC =>
669
          if cyc_v = 1 then
670
            skip_op_o    <= SKIP_C;
671
          end if;
672
 
673
        -- Mnemonic SKE -------------------------------------------------------
674
        when MN_SKE =>
675
          if cyc_v = 1 then
676
            skip_op_o    <= SKIP_A_M;
677
          end if;
678
 
679
        -- Mnemonic SKMBZ -----------------------------------------------------
680
        when MN_SKMBZ =>
681
          if cyc_v = 1 then
682
            skip_op_o  <= SKIP_M_BIT;
683
            -- select bit to be checked
684
            case ibyte1_q is
685
              when "00000001" =>
686
                dec_data_o(dw_range_t) <= "0001";
687
              when "00010001" =>
688
                dec_data_o(dw_range_t) <= "0010";
689
              when "00000011" =>
690
                dec_data_o(dw_range_t) <= "0100";
691
              when "00010011" =>
692
                dec_data_o(dw_range_t) <= "1000";
693
              when others =>
694
                null;
695
            end case;
696
          end if;
697
 
698
        -- Mnemonic SKT -------------------------------------------------------
699
        when MN_SKT =>
700
          if cyc_v = 1 then
701
            skip_op_o  <= SKIP_TIMER;
702
          end if;
703
 
704
        -- Mnemonic XAS -------------------------------------------------------
705
        when MN_XAS =>
706
          if out_en_i then
707
            sio_op_o <= SIO_LOAD;
708
            alu_op_o <= ALU_LOAD_SIO;
709
          end if;
710
 
711
        -- Mnemonic EXT -------------------------------------------------------
712
        when MN_EXT =>
713
          if second_cyc_q then
714
            case ibyte2_q is
715
              -- CAMQ
716
              when "00111100" =>
717
                if out_en_i then
718
                  io_l_op_o <= IOL_LOAD_AM;
719
                end if;
720
              -- CQMA
721
              when "00101100" =>
722
                if not t41x_type_v and in_en_i then
723
                  io_l_op_o <= IOL_OUTPUT_Q;
724
                  alu_op_o  <= ALU_LOAD_Q;
725
                  dmem_op_o <= DMEM_WB_SRC_Q;
726
                end if;
727
              -- SKGZ
728
              when "00100001" =>
729
                if in_en_i then
730
                  skip_op_o <= SKIP_G_ZERO;
731
                end if;
732
              -- SKGBZ
733
              when "00000001" =>
734
                if in_en_i then
735
                  skip_op_o <= SKIP_G_BIT;
736
                  dec_data_o(dw_range_t) <= "0001";
737
                end if;
738
              when "00010001" =>
739
                if in_en_i then
740
                  skip_op_o <= SKIP_G_BIT;
741
                  dec_data_o(dw_range_t) <= "0010";
742
                end if;
743
              when "00000011" =>
744
                if in_en_i then
745
                  skip_op_o <= SKIP_G_BIT;
746
                  dec_data_o(dw_range_t) <= "0100";
747
                end if;
748
              when "00010011" =>
749
                if in_en_i then
750
                  skip_op_o <= SKIP_G_BIT;
751
                  dec_data_o(dw_range_t) <= "1000";
752
                end if;
753
              -- ING
754
              when "00101010" =>
755
                if cyc_v = 1 then
756
                  alu_op_o  <= ALU_LOAD_G;
757
                end if;
758
              -- INL
759
              when "00101110" =>
760
                if in_en_i then
761
                  io_l_op_o <= IOL_OUTPUT_L;
762
                  alu_op_o  <= ALU_LOAD_Q;
763
                  dmem_op_o <= DMEM_WB_SRC_Q;
764
                end if;
765 48 arniml
              -- ININ
766
              when "00101000" =>
767
                if not t41x_type_v and in_en_i then
768
                  alu_op_o  <= ALU_LOAD_IN;
769
                end if;
770
              -- INIL
771
              when "00101001" =>
772
                if not t41x_type_v and in_en_i then
773
                  alu_op_o   <= ALU_LOAD_IL;
774
                  io_in_op_o <= IOIN_INIL;
775
                end if;
776 2 arniml
              -- OBD
777
              when "00111110" =>
778
                if out_en_i then
779
                  io_d_op_o <= IOD_LOAD;
780
                end if;
781
              -- OMG
782
              when "00111010" =>
783
                if out_en_i then
784
                  io_g_op_o <= IOG_LOAD_M;
785
                end if;
786
              -- multiple codes
787
              when others =>
788
                -- apply default decoder output, largest required vector
789
                dec_data_o(b_range_t) <= ibyte2_q(b_range_t);
790
                -- LBI
791
                if ibyte2_q(7 downto 6) = "10" and not t41x_type_v then
792
                  is_lbi_o    <= true;
793 88 arniml
                  en_int_v    := false;
794 2 arniml
                  if cyc_v > 0 and not skip_lbi_i then
795
                    b_op_o    <= B_SET_B;
796
                    skip_op_o <= SKIP_LBI;
797
                  end if;
798
                end if;
799
                -- LEI
800
                if ibyte2_q(7 downto 4) = "0110" and in_en_i then
801
                  -- dec_data_o applied by default
802
                  set_en_s   <= true;
803 70 arniml
 
804
                  -- acknowledge pending interrupt when EN(1) is not
805
                  -- enabled - will clear them until interrupts are
806
                  -- enabled with EN(1) = '1'
807
                  if en_q(1) = '0' then
808
                    io_in_op_o <= IOIN_INTACK;
809
                  end if;
810 2 arniml
                end if;
811
                -- OGI
812
                if ibyte2_q(7 downto 4) = "0101" and out_en_i and
813
                   not t41x_type_v then
814
                  -- dec_data_o applied by default
815
                  io_g_op_o  <= IOG_LOAD_DEC;
816
                end if;
817
            end case;
818
          end if;
819
 
820
        when others =>
821
          null;
822
      end case;
823
    end if;
824 70 arniml
 
825
 
826
    -- Interrupt handling -----------------------------------------------------
827
    if t420_type_v and
828 88 arniml
       en_q(1) = '1' and int_i and en_int_v then
829 70 arniml
      if last_cycle_s then
830
        if cyc_v = 1 then
831
          stack_op_o <= STACK_PUSH;
832
        end if;
833
        if icyc_en_i then
834
          ack_int_s  <= true;
835
          io_in_op_o <= IOIN_INTACK;
836 88 arniml
          pc_op_o    <= PC_INT;
837 70 arniml
          -- push skip state that was determined by current instruction
838
          -- and will be valid for the next instruction which is delayed
839
          -- by the interrupt
840
          skip_op_o  <= SKIP_PUSH;
841
        end if;
842
      end if;
843
    end if;
844
 
845 2 arniml
  end process decoder_ctrl;
846
  --
847
  -----------------------------------------------------------------------------
848
 
849
 
850
  -----------------------------------------------------------------------------
851
  -- Output mapping
852
  -----------------------------------------------------------------------------
853
  en_o <= en_q;
854
 
855
end rtl;
856
 
857
 
858
-------------------------------------------------------------------------------
859
-- File History:
860
--
861
-- $Log: not supported by cvs2svn $
862 88 arniml
-- Revision 1.4  2006/05/27 19:14:18  arniml
863
-- interrupt functionality added
864
--
865 70 arniml
-- Revision 1.3  2006/05/22 00:02:36  arniml
866
-- instructions ININ and INIL implemented
867
--
868 48 arniml
-- Revision 1.2  2006/05/07 02:24:16  arniml
869
-- fix sensitivity list
870
--
871 12 arniml
-- Revision 1.1.1.1  2006/05/06 01:56:44  arniml
872
-- import from local CVS repository, LOC_CVS_0_1
873
--
874 2 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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