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

Subversion Repositories t400

[/] [t400/] [tags/] [rel_0_1_beta/] [rtl/] [vhdl/] [t400_decoder.vhd] - Blame information for rev 176

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

powered by: WebSVN 2.1.0

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