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

Subversion Repositories t400

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

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

powered by: WebSVN 2.1.0

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