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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_6_beta/] [rtl/] [vhdl/] [decoder.vhd] - Blame information for rev 292

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Decoder unit.
4
-- It decodes the instruction opcodes and executes them.
5
--
6 188 arniml
-- $Id: decoder.vhd,v 1.20 2005-09-13 21:08:34 arniml Exp $
7 4 arniml
--
8
-- Copyright (c) 2004, 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/t48/
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
use work.t48_pack.word_t;
51
use work.t48_pack.mstate_t;
52 179 arniml
use work.t48_alu_pack.alu_op_t;
53
use work.t48_cond_branch_pack.all;
54
use work.t48_dmem_ctrl_pack.all;
55
use work.t48_pmem_ctrl_pack.all;
56 4 arniml
 
57 179 arniml
entity t48_decoder is
58 4 arniml
 
59
  generic (
60
    -- store mnemonic in flip-flops (registered-out)
61
    register_mnemonic_g   : integer := 1
62
  );
63
 
64
  port (
65
    -- Global Interface -------------------------------------------------------
66
    clk_i                  : in  std_logic;
67
    res_i                  : in  std_logic;
68
    en_clk_i               : in  boolean;
69
    ea_i                   : in  std_logic;
70
    ale_i                  : in  boolean;
71
    int_n_i                : in  std_logic;
72
    t0_dir_o               : out std_logic;
73
    -- T48 Bus Interface ------------------------------------------------------
74
    data_i                 : in  word_t;
75
    data_o                 : out word_t;
76
    alu_write_accu_o       : out boolean;
77
    alu_write_shadow_o     : out boolean;
78
    alu_write_temp_reg_o   : out boolean;
79
    alu_read_alu_o         : out boolean;
80
    bus_write_bus_o        : out boolean;
81
    bus_read_bus_o         : out boolean;
82
    dm_write_dmem_addr_o   : out boolean;
83
    dm_write_dmem_o        : out boolean;
84
    dm_read_dmem_o         : out boolean;
85
    p1_write_p1_o          : out boolean;
86
    p1_read_p1_o           : out boolean;
87
    p2_write_p2_o          : out boolean;
88
    p2_write_exp_o         : out boolean;
89
    p2_read_p2_o           : out boolean;
90 21 arniml
    p2_read_exp_o          : out boolean;
91 4 arniml
    pm_write_pcl_o         : out boolean;
92
    pm_read_pcl_o          : out boolean;
93
    pm_write_pch_o         : out boolean;
94
    pm_read_pch_o          : out boolean;
95
    pm_read_pmem_o         : out boolean;
96
    psw_read_psw_o         : out boolean;
97
    psw_read_sp_o          : out boolean;
98
    psw_write_psw_o        : out boolean;
99
    psw_write_sp_o         : out boolean;
100
    -- ALU Interface ----------------------------------------------------------
101
    alu_carry_i            : in  std_logic;
102
    alu_op_o               : out alu_op_t;
103
    alu_use_carry_o        : out boolean;
104 27 arniml
    alu_da_high_o          : out boolean;
105 38 arniml
    alu_accu_low_o         : out boolean;
106 27 arniml
    alu_p06_temp_reg_o     : out boolean;
107
    alu_p60_temp_reg_o     : out boolean;
108
    alu_da_overflow_i      : in  boolean;
109 4 arniml
    -- BUS Interface ----------------------------------------------------------
110
    bus_output_pcl_o       : out boolean;
111
    bus_bidir_bus_o        : out boolean;
112
    -- Clock Controller Interface ---------------------------------------------
113
    clk_multi_cycle_o      : out boolean;
114
    clk_assert_psen_o      : out boolean;
115
    clk_assert_prog_o      : out boolean;
116
    clk_assert_rd_o        : out boolean;
117
    clk_assert_wr_o        : out boolean;
118
    clk_mstate_i           : in  mstate_t;
119
    clk_second_cycle_i     : in  boolean;
120
    -- Conditional Branch Logic Interface -------------------------------------
121
    cnd_compute_take_o     : out boolean;
122
    cnd_branch_cond_o      : out branch_conditions_t;
123
    cnd_take_branch_i      : in  boolean;
124
    cnd_comp_value_o       : out comp_value_t;
125
    cnd_f1_o               : out std_logic;
126
    cnd_tf_o               : out std_logic;
127
    -- Data Memory Controller Interface ---------------------------------------
128
    dm_addr_type_o         : out dmem_addr_ident_t;
129
    -- Port 1 Interface -------------------------------------------------------
130
    p1_read_reg_o          : out boolean;
131
    -- Port 2 Interface -------------------------------------------------------
132
    p2_read_reg_o          : out boolean;
133
    p2_output_pch_o        : out boolean;
134
    p2_output_exp_o        : out boolean;
135
    -- Program Memory Controller Interface ------------------------------------
136
    pm_inc_pc_o            : out boolean;
137
    pm_write_pmem_addr_o   : out boolean;
138
    pm_addr_type_o         : out pmem_addr_ident_t;
139
    -- Program Status Word Interface ------------------------------------------
140
    psw_special_data_o     : out std_logic;
141
    psw_carry_i            : in  std_logic;
142 27 arniml
    psw_aux_carry_i        : in  std_logic;
143 4 arniml
    psw_f0_i               : in  std_logic;
144
    psw_inc_stackp_o       : out boolean;
145
    psw_dec_stackp_o       : out boolean;
146
    psw_write_carry_o      : out boolean;
147
    psw_write_aux_carry_o  : out boolean;
148
    psw_write_f0_o         : out boolean;
149
    psw_write_bs_o         : out boolean;
150
    -- Timer Interface --------------------------------------------------------
151
    tim_read_timer_o       : out boolean;
152
    tim_write_timer_o      : out boolean;
153
    tim_start_t_o          : out boolean;
154
    tim_start_cnt_o        : out boolean;
155
    tim_stop_tcnt_o        : out boolean;
156
    tim_overflow_i         : in  boolean
157
  );
158
 
159 179 arniml
end t48_decoder;
160 4 arniml
 
161
 
162
use work.t48_pack.all;
163 179 arniml
use work.t48_alu_pack.all;
164
use work.t48_decoder_pack.all;
165 4 arniml
 
166 179 arniml
use work.t48_comp_pack.t48_opc_decoder;
167
use work.t48_comp_pack.t48_int;
168 4 arniml
 
169 53 arniml
-- pragma translate_off
170
use work.t48_tb_pack.tb_istrobe_s;
171
-- pragma translate_on
172
 
173 179 arniml
architecture rtl of t48_decoder is
174 4 arniml
 
175 92 arniml
  -- Enable fixing a bug of Quartus II 4.0
176
  constant enable_quartus_bugfix_c : boolean := true;
177
 
178 4 arniml
  -- Opcode Decoder
179
  signal opc_multi_cycle_s : boolean;
180
  signal opc_read_bus_s    : boolean;
181
  signal opc_inj_int_s     : boolean;
182
  signal opc_opcode_s      : word_t;
183
  signal opc_mnemonic_s    : mnemonic_t;
184
  signal last_cycle_s      : boolean;
185
 
186
  -- state translators
187
  signal assert_psen_s     : boolean;
188
 
189
  -- branch taken handshake
190
  signal branch_taken_s,
191
         branch_taken_q        : boolean;
192
  signal pm_inc_pc_s           : boolean;
193
  signal pm_write_pmem_addr_s  : boolean;
194
  -- additional signal to increment PC during CALL
195
  signal add_inc_pc_s          : boolean;
196
  -- addtional signal to set PC during RET(R)
197
  signal add_write_pmem_addr_s : boolean;
198
 
199
  -- Flag 1
200
  signal clear_f1_s,
201
         cpl_f1_s          : boolean;
202
  signal f1_q              : std_logic;
203
  -- memory bank select
204
  signal clear_mb_s,
205
         set_mb_s          : boolean;
206
  signal mb_q              : std_logic;
207
 
208
  -- T0 direction selection
209
  signal ent0_clk_s        : boolean;
210
  signal t0_dir_q          : std_logic;
211
 
212
  signal data_s            : word_t;
213
  signal read_dec_s        : boolean;
214
 
215
  signal tf_s              : std_logic;
216
 
217
  signal bus_read_bus_s    : boolean;
218
  signal add_read_bus_s    : boolean;
219
 
220
  signal dm_write_dmem_s   : boolean;
221
 
222
  -- interrupt handling
223
  signal jtf_executed_s    : boolean;
224
  signal en_tcnti_s        : boolean;
225
  signal dis_tcnti_s       : boolean;
226
  signal en_i_s            : boolean;
227
  signal dis_i_s           : boolean;
228
  signal tim_int_s         : boolean;
229
  signal retr_executed_s   : boolean;
230
  signal int_executed_s    : boolean;
231
  signal int_pending_s     : boolean;
232 120 arniml
  signal int_in_progress_s : boolean;
233 4 arniml
 
234 38 arniml
  -- pragma translate_off
235 64 arniml
  signal istrobe_res_q     : std_logic;
236
  signal istrobe_q         : std_logic;
237 60 arniml
  signal injected_int_q    : std_logic;
238 38 arniml
  -- pragma translate_on
239
 
240 4 arniml
begin
241
 
242
  -----------------------------------------------------------------------------
243
  -- Opcode Decoder
244
  -----------------------------------------------------------------------------
245 179 arniml
  opc_decoder_b : t48_opc_decoder
246 4 arniml
    generic map (
247
      register_mnemonic_g => register_mnemonic_g
248
    )
249
    port map (
250
      clk_i         => clk_i,
251
      res_i         => res_i,
252
      en_clk_i      => en_clk_i,
253
      data_i        => data_i,
254
      read_bus_i    => opc_read_bus_s,
255
      inj_int_i     => opc_inj_int_s,
256
      opcode_o      => opc_opcode_s,
257
      mnemonic_o    => opc_mnemonic_s,
258
      multi_cycle_o => opc_multi_cycle_s
259
    );
260
 
261
 
262
  -----------------------------------------------------------------------------
263
  -- Interrupt Controller.
264
  -----------------------------------------------------------------------------
265 179 arniml
  int_b : t48_int
266 4 arniml
    port map (
267 120 arniml
      clk_i             => clk_i,
268
      res_i             => res_i,
269
      en_clk_i          => en_clk_i,
270
      clk_mstate_i      => clk_mstate_i,
271
      jtf_executed_i    => jtf_executed_s,
272
      tim_overflow_i    => tim_overflow_i,
273
      tf_o              => tf_s,
274
      en_tcnti_i        => en_tcnti_s,
275
      dis_tcnti_i       => dis_tcnti_s,
276
      int_n_i           => int_n_i,
277
      ale_i             => ale_i,
278
      last_cycle_i      => last_cycle_s,
279
      en_i_i            => en_i_s,
280
      dis_i_i           => dis_i_s,
281
      ext_int_o         => open,
282
      tim_int_o         => tim_int_s,
283
      retr_executed_i   => retr_executed_s,
284
      int_executed_i    => int_executed_s,
285
      int_pending_o     => int_pending_s,
286
      int_in_progress_o => int_in_progress_s
287 4 arniml
    );
288
 
289
  last_cycle_s <= not opc_multi_cycle_s or
290
                  (opc_multi_cycle_s and clk_second_cycle_i);
291
 
292
  -----------------------------------------------------------------------------
293
  -- Process machine_cycle
294
  --
295
  -- Purpose:
296
  --   Generates the control signals that are basically needed for the
297
  --   handling of a machine cycle.
298
  --
299
  machine_cycle: process (clk_mstate_i,
300
                          clk_second_cycle_i,
301 64 arniml
                          last_cycle_s,
302 4 arniml
                          ea_i,
303
                          assert_psen_s,
304
                          branch_taken_q,
305
                          int_pending_s)
306
 
307
   variable need_address_v      : boolean;
308
 
309
  begin
310
    -- default assignments
311
    clk_assert_psen_o    <= false;
312
    pm_inc_pc_s          <= false;
313
    pm_write_pmem_addr_s <= false;
314
    pm_read_pmem_o       <= false;
315
    bus_output_pcl_o     <= false;
316
    p2_output_pch_o      <= false;
317
    opc_read_bus_s       <= false;
318
    opc_inj_int_s        <= false;
319
    bus_read_bus_s       <= false;
320
 
321
    need_address_v    := not clk_second_cycle_i or
322
                         (clk_second_cycle_i and assert_psen_s);
323
 
324
    case clk_mstate_i is
325
      when MSTATE1 =>
326 188 arniml
        if need_address_v then
327 4 arniml
          if ea_i = '0' then
328 188 arniml
            if not int_pending_s then
329
              pm_read_pmem_o <= true;
330
            end if;
331
 
332 4 arniml
          else
333 188 arniml
            bus_read_bus_s   <= true;
334
            p2_output_pch_o  <= true;
335 4 arniml
          end if;
336 188 arniml
 
337 4 arniml
        end if;
338
 
339
        if not clk_second_cycle_i then
340
          if not int_pending_s then
341
            opc_read_bus_s  <= true;
342
          else
343
            opc_inj_int_s   <= true;    -- inject interrupt call
344
          end if;
345
        end if;
346
 
347
      when MSTATE2 =>
348
        if need_address_v and not branch_taken_q and
349
           not int_pending_s then
350
          pm_inc_pc_s       <= true;
351
        end if;
352
 
353
      when MSTATE3 =>
354
        if need_address_v then
355 106 arniml
          -- Theory of operation:
356
          -- Program Memory address is updated at end of State 3 (or end of
357
          -- State 2 in case of a RET). Address information is thus available
358
          -- latest with State 4.
359
          -- This is the time where we need information about access target
360
          -- (internal or external = EA). EA information needs to be stable
361
          -- until end of State 1.
362 4 arniml
          pm_write_pmem_addr_s <= true;
363 64 arniml
        end if;
364 4 arniml
 
365
      when MSTATE4 =>
366 64 arniml
        if ea_i = '1' and
367 134 arniml
           ((not clk_second_cycle_i and assert_psen_s)
368
            or last_cycle_s) then
369 4 arniml
          clk_assert_psen_o <= true;
370 64 arniml
          p2_output_pch_o   <= true;
371
          bus_output_pcl_o  <= true;
372 4 arniml
        end if;
373
 
374
      when MSTATE5 =>
375 64 arniml
        if ea_i = '1' and
376 106 arniml
           (need_address_v or last_cycle_s) then
377 64 arniml
          p2_output_pch_o   <= true;
378 4 arniml
        end if;
379
 
380
      when others =>
381
        -- pragma translate_off
382
        assert false
383
          report "Unkown machine state!"
384
          severity error;
385
        -- pragma translate_on
386
 
387
    end case;
388
 
389
  end process machine_cycle;
390
  --
391
  -----------------------------------------------------------------------------
392
 
393
 
394
  -----------------------------------------------------------------------------
395
  -- Process decode
396
  --
397
  -- Purpose:
398
  --   Indentifies each single instruction and steps through the related
399
  --   execution sequence.
400
  --
401
  decode: process (alu_carry_i,
402 27 arniml
                   psw_aux_carry_i,
403
                   alu_da_overflow_i,
404 4 arniml
                   clk_mstate_i,
405
                   clk_second_cycle_i,
406
                   cnd_take_branch_i,
407
                   opc_opcode_s,
408
                   opc_mnemonic_s,
409
                   psw_carry_i,
410
                   psw_f0_i,
411
                   f1_q,
412
                   mb_q,
413
                   tim_int_s,
414 120 arniml
                   int_pending_s,
415
                   int_in_progress_s)
416 4 arniml
 
417
    procedure address_indirect_3_f is
418
    begin
419
      -- apply dmem address from selected register for indirect mode
420 92 arniml
      if opc_opcode_s(3) = '0' or enable_quartus_bugfix_c then
421 4 arniml
        dm_read_dmem_o       <= true;
422
        dm_write_dmem_addr_o <= true;
423
        dm_addr_type_o       <= DM_PLAIN;
424
      end if;
425
    end;
426
 
427
    procedure and_or_xor_add_4_f is
428
    begin
429
      -- write dmem contents to Temp Reg
430
      dm_read_dmem_o         <= true;
431
      alu_write_temp_reg_o   <= true;
432
    end;
433
 
434
    procedure and_or_xor_add_5_f (alu_op : alu_op_t) is
435
    begin
436
      -- perform ALU operation and store in Accumulator
437
      alu_op_o               <= alu_op;
438
      alu_read_alu_o         <= true;
439
      alu_write_accu_o       <= true;
440
    end;
441
 
442
    procedure cond_jump_c2_m1_f is
443
    begin
444
      -- store address in Program Counter low byte if branch has to
445
      -- be taken
446 92 arniml
--      if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
447 4 arniml
        pm_write_pcl_o       <= true;
448
        branch_taken_s       <= true;
449 92 arniml
--      end if;
450 4 arniml
    end;
451
 
452 120 arniml
    -- intermediate value of the Program Memory Bank Flag
453
    variable mb_v : std_logic;
454
 
455 4 arniml
  begin
456
    -- default assignments
457
    data_s                 <= (others => '-');
458
    read_dec_s             <= false;
459
    branch_taken_s         <= false;
460
    clear_f1_s             <= false;
461
    cpl_f1_s               <= false;
462
    clear_mb_s             <= false;
463
    set_mb_s               <= false;
464
    add_inc_pc_s           <= false;
465
    assert_psen_s          <= false;
466
    alu_write_accu_o       <= false;
467
    alu_write_shadow_o     <= false;
468
    alu_write_temp_reg_o   <= false;
469 27 arniml
    alu_p06_temp_reg_o     <= false;
470
    alu_p60_temp_reg_o     <= false;
471 4 arniml
    alu_read_alu_o         <= false;
472
    bus_write_bus_o        <= false;
473
    bus_bidir_bus_o        <= false;
474
    dm_write_dmem_addr_o   <= false;
475
    dm_write_dmem_s        <= false;
476
    dm_read_dmem_o         <= false;
477
    pm_write_pcl_o         <= false;
478
    pm_read_pcl_o          <= false;
479
    pm_write_pch_o         <= false;
480
    pm_read_pch_o          <= false;
481
    pm_addr_type_o         <= PM_PC;
482
    psw_read_psw_o         <= false;
483
    psw_read_sp_o          <= false;
484
    psw_write_psw_o        <= false;
485
    psw_write_sp_o         <= false;
486
    alu_op_o               <= ALU_NOP;
487
    alu_use_carry_o        <= false;
488 27 arniml
    alu_da_high_o          <= false;
489 38 arniml
    alu_accu_low_o         <= false;
490 4 arniml
    clk_assert_prog_o      <= false;
491
    clk_assert_rd_o        <= false;
492
    clk_assert_wr_o        <= false;
493
    cnd_branch_cond_o      <= COND_ON_BIT;
494
    cnd_compute_take_o     <= false;
495
    cnd_comp_value_o       <= opc_opcode_s(7 downto 5);
496
    dm_addr_type_o         <= DM_REG;
497
    tim_read_timer_o       <= false;
498
    tim_write_timer_o      <= false;
499
    tim_start_t_o          <= false;
500
    tim_start_cnt_o        <= false;
501
    tim_stop_tcnt_o        <= false;
502
    p1_write_p1_o          <= false;
503
    p1_read_p1_o           <= false;
504
    p1_read_reg_o          <= false;
505
    p2_write_p2_o          <= false;
506
    p2_write_exp_o         <= false;
507
    p2_read_p2_o           <= false;
508
    p2_read_reg_o          <= false;
509 21 arniml
    p2_read_exp_o          <= false;
510
    p2_output_exp_o        <= false;
511 4 arniml
    psw_special_data_o     <= '0';
512
    psw_inc_stackp_o       <= false;
513
    psw_dec_stackp_o       <= false;
514
    psw_write_carry_o      <= false;
515
    psw_write_aux_carry_o  <= false;
516
    psw_write_f0_o         <= false;
517
    psw_write_bs_o         <= false;
518
    jtf_executed_s         <= false;
519
    en_tcnti_s             <= false;
520
    dis_tcnti_s            <= false;
521
    en_i_s                 <= false;
522
    dis_i_s                <= false;
523
    retr_executed_s        <= false;
524
    int_executed_s         <= false;
525
    add_write_pmem_addr_s  <= false;
526
    ent0_clk_s             <= false;
527
    add_read_bus_s         <= false;
528
 
529 120 arniml
    -- the Program Memory Bank Flag is held low when interrupts are in progress
530
    -- according to the MCS-48 User's Manual
531
    if int_in_progress_s then
532
      mb_v := '0';
533
    else
534
      mb_v := mb_q;
535
    end if;
536
 
537 4 arniml
    -- prepare potential register indirect address mode
538
    if not clk_second_cycle_i and clk_mstate_i = MSTATE2 then
539
      data_s               <= (others => '0');
540
      if opc_opcode_s(3) = '1' then
541
        data_s(2 downto 0) <= opc_opcode_s(2 downto 0);
542
      else
543
        data_s(2 downto 0) <= "00" & opc_opcode_s(0);
544
      end if;
545
 
546
      read_dec_s           <= true;
547
      dm_write_dmem_addr_o <= true;
548
      dm_addr_type_o       <= DM_REG;
549
    end if;
550
 
551
    case opc_mnemonic_s is
552
 
553
      -- Mnemonic ADD ---------------------------------------------------------
554
      when MN_ADD =>
555
        case clk_mstate_i is
556
          -- read RAM once for indirect address mode
557
          when MSTATE3 =>
558 92 arniml
            if not enable_quartus_bugfix_c or
559
               opc_opcode_s(3) = '0' then
560
              address_indirect_3_f;
561
            end if;
562 4 arniml
 
563
          -- store data from RAM to Temp Reg
564
          when MSTATE4 =>
565
            and_or_xor_add_4_f;
566
 
567
          -- perform ADD and store in Accumulator
568
          when MSTATE5 =>
569
            and_or_xor_add_5_f(alu_op => ALU_ADD);
570
 
571
            if opc_opcode_s(4) = '1' then
572 27 arniml
              alu_use_carry_o     <= true;
573 4 arniml
            end if;
574
 
575 27 arniml
            psw_special_data_o    <= alu_carry_i;
576
            psw_write_carry_o     <= true;
577
            psw_write_aux_carry_o <= true;
578 4 arniml
 
579
          when others =>
580
            null;
581
 
582
        end case;
583
 
584
      -- Mnemonic ADD_A_DATA --------------------------------------------------
585
      when MN_ADD_A_DATA =>
586 27 arniml
        assert_psen_s               <= true;
587 4 arniml
 
588
        if clk_second_cycle_i then
589
          case clk_mstate_i is
590
            -- write Temp Reg when contents of Program Memory is on bus
591
            when MSTATE1 =>
592 27 arniml
              alu_write_temp_reg_o  <= true;
593 4 arniml
 
594
            -- perform ADD and store in Accumulator
595
            when MSTATE3 =>
596
              and_or_xor_add_5_f(alu_op => ALU_ADD);
597
 
598
              if opc_opcode_s(4) = '1' then
599 27 arniml
                alu_use_carry_o     <= true;
600 4 arniml
              end if;
601
 
602 27 arniml
              psw_special_data_o    <= alu_carry_i;
603
              psw_write_carry_o     <= true;
604
              psw_write_aux_carry_o <= true;
605 4 arniml
 
606
            when others =>
607
              null;
608
 
609
          end case;
610
 
611
        end if;
612
 
613
      -- Mnemonic ANL ---------------------------------------------------------
614
      when MN_ANL =>
615
        case clk_mstate_i is
616
          -- read RAM once for indirect address mode
617
          when MSTATE3 =>
618 92 arniml
            if not enable_quartus_bugfix_c or
619
               opc_opcode_s(3) = '0' then
620
              address_indirect_3_f;
621
            end if;
622 4 arniml
 
623
          -- store data from RAM to Temp Reg
624
          when MSTATE4 =>
625
            and_or_xor_add_4_f;
626
 
627
          -- perform AND and store in Accumulator
628
          when MSTATE5 =>
629
            and_or_xor_add_5_f(alu_op => ALU_AND);
630
 
631
          when others =>
632
            null;
633
 
634
        end case;
635
 
636
      -- Mnemonic ANL_A_DATA --------------------------------------------------
637
      when MN_ANL_A_DATA =>
638
        assert_psen_s              <= true;
639
 
640
        if clk_second_cycle_i then
641
          case clk_mstate_i is
642
            -- write Temp Reg when contents of Program Memory is on bus
643
            when MSTATE1 =>
644
              alu_write_temp_reg_o <= true;
645
 
646
            -- perform AND and store in Accumulator
647
            when MSTATE3 =>
648
              and_or_xor_add_5_f(alu_op => ALU_AND);
649
 
650
            when others =>
651
              null;
652
 
653
          end case;
654
 
655
        end if;
656
 
657
      -- Mnemonic ANL_EXT -----------------------------------------------------
658
      when MN_ANL_EXT =>
659
        assert_psen_s            <= true;
660
 
661
        if not clk_second_cycle_i then
662
          -- read port to Temp Reg
663
          if clk_mstate_i = MSTATE5 then
664
            if opc_opcode_s(1 downto 0) = "00" then
665
              add_read_bus_s     <= true;
666
            elsif opc_opcode_s(1) = '0' then
667
              p1_read_p1_o       <= true;
668
              p1_read_reg_o      <= true;
669
            else
670
              p2_read_p2_o       <= true;
671
              p2_read_reg_o      <= true;
672
            end if;
673
 
674
            alu_write_temp_reg_o <= true;
675
          end if;
676
 
677
        else
678
          case clk_mstate_i is
679
            -- write shadow Accumulator when contents of Program Memory is
680
            -- on bus
681
            when MSTATE1 =>
682
              alu_write_shadow_o <= true;
683
 
684
            -- loop shadow Accumulator through ALU to prevent update from
685
            -- real Accumulator
686
            when MSTATE2 =>
687
              alu_read_alu_o     <= true;
688
              alu_write_shadow_o <= true;
689
 
690
            -- write result of AND operation back to port
691
            when MSTATE3 =>
692
              alu_op_o           <= ALU_AND;
693
              alu_read_alu_o     <= true;
694
 
695
              if opc_opcode_s(1 downto 0) = "00" then
696
                bus_write_bus_o  <= true;
697
              elsif opc_opcode_s(1) = '0' then
698
                p1_write_p1_o    <= true;
699
              else
700
                p2_write_p2_o    <= true;
701
              end if;
702
 
703
            when others =>
704
              null;
705
 
706
          end case;
707
 
708
        end if;
709
 
710
      -- Mnemonic CALL --------------------------------------------------------
711
      when MN_CALL =>
712
        assert_psen_s              <= true;
713
 
714
        if not clk_second_cycle_i then
715
          case clk_mstate_i is
716
            -- read Stack Pointer and address Data Memory for low byte
717
            -- also increment Program Counter to point to next instruction
718
            when MSTATE3 =>
719
              psw_read_sp_o        <= true;
720
              dm_write_dmem_addr_o <= true;
721
              dm_addr_type_o       <= DM_STACK;
722
 
723
              -- only increment PC if this is not an injected CALL
724
              -- injected CALLS are not located in Program Memory,
725
              -- the PC points already to the instruction to be executed
726
              -- after the interrupt
727
              if not int_pending_s then
728
                add_inc_pc_s       <= true;
729
              end if;
730
 
731
            -- store Program Counter low byte on stack
732
            when MSTATE4 =>
733
              pm_read_pcl_o        <= true;
734
              dm_write_dmem_s      <= true;
735
 
736
            -- store Program Counter high byte and PSW on stack
737
            -- increment Stack pointer
738
            when MSTATE5 =>
739
              psw_read_psw_o       <= true;
740
              pm_read_pch_o        <= true;
741
              dm_write_dmem_addr_o <= true;
742
              dm_addr_type_o       <= DM_STACK_HIGH;
743
              dm_write_dmem_s      <= true;
744
              psw_inc_stackp_o     <= true;
745
 
746
            when others =>
747
              null;
748
 
749
          end case;
750
 
751
        else
752
          case clk_mstate_i is
753
            -- store address in Program Counter low byte
754
            when MSTATE1 =>
755
              pm_write_pcl_o       <= true;
756
              branch_taken_s       <= true;
757
              if int_pending_s then
758
                -- apply low part of vector address manually
759
                data_s             <= (others => '0');
760
                data_s(1 downto 0) <= "11";
761
                if tim_int_s then
762
                  data_s(2)        <= '1';
763
                end if;
764
                read_dec_s         <= true;
765
              end if;
766
 
767
            when MSTATE2 =>
768
              pm_write_pch_o       <= true;
769
              read_dec_s           <= true;
770
              if not int_pending_s then
771
                -- store high part of target address in Program Counter
772 120 arniml
                data_s             <= "0000" & mb_v & opc_opcode_s(7 downto 5);
773 4 arniml
              else
774
                -- apply high part of vector address manually
775
                data_s             <= (others => '0');
776
                int_executed_s     <= true;
777
              end if;
778
 
779
            when others =>
780
              null;
781
 
782
          end case;
783
 
784
        end if;
785
 
786
      -- Mnemonic CLR_A -------------------------------------------------------
787
      when MN_CLR_A =>
788
        -- write CLR output of ALU to Accumulator
789
        if clk_mstate_i = MSTATE3 then
790
          alu_op_o         <= ALU_CLR;
791
          alu_read_alu_o   <= true;
792
          alu_write_accu_o <= true;
793
        end if;
794
 
795
      -- Mnemonic CLR_C -------------------------------------------------------
796
      when MN_CLR_C =>
797
        -- store 0 to Carry
798
        if clk_mstate_i = MSTATE3 then
799
          psw_special_data_o <= '0';
800
          psw_write_carry_o  <= true;
801
        end if;
802
 
803
      -- Mnemonic CLR_F -------------------------------------------------------
804
      when MN_CLR_F =>
805
        -- store 0 to selected flag
806
        if clk_mstate_i = MSTATE3 then
807
          if opc_opcode_s(5) = '0' then
808
            psw_special_data_o <= '0';
809
            psw_write_f0_o     <= true;
810
          else
811
            clear_f1_s         <= true;
812
          end if;
813
 
814
        end if;
815
 
816
      -- Mnemonic CPL_A -------------------------------------------------------
817
      when MN_CPL_A =>
818
        -- write CPL output of ALU to Accumulator
819
        if clk_mstate_i = MSTATE3 then
820
          alu_op_o         <= ALU_CPL;
821
          alu_read_alu_o   <= true;
822
          alu_write_accu_o <= true;
823
        end if;
824
 
825
      -- Mnemnonic CPL_C ------------------------------------------------------
826
      when MN_CPL_C =>
827
        -- write inverse of Carry to PSW
828
        if clk_mstate_i = MSTATE3 then
829
          psw_special_data_o <= not psw_carry_i;
830
          psw_write_carry_o  <= true;
831
        end if;
832
 
833
      -- Mnemonic CPL_F -------------------------------------------------------
834
      when MN_CPL_f =>
835
        -- write inverse of selected flag back to flag
836
        if clk_mstate_i = MSTATE3 then
837
          if opc_opcode_s(5) = '0' then
838
            psw_special_data_o <= not psw_f0_i;
839
            psw_write_f0_o     <= true;
840
          else
841
            cpl_f1_s           <= true;
842
          end if;
843
 
844
        end if;
845
 
846 27 arniml
      -- Mnemonic DA ----------------------------------------------------------
847
      when MN_DA =>
848
        alu_op_o                 <= ALU_ADD;
849
 
850
        case clk_mstate_i is
851
          -- Step 1: Preload Temp Reg with 0x06
852
          when MSTATE3 =>
853
            alu_p06_temp_reg_o   <= true;
854
 
855
          -- Step 2: Check Auxiliary Carry and overflow on low nibble
856
          --         Add 0x06 to shadow Accumulator if one is true
857
          when MSTATE4 =>
858
            if psw_aux_carry_i = '1' or alu_da_overflow_i then
859
              alu_read_alu_o     <= true;
860
              alu_write_shadow_o <= true;
861
            end if;
862
 
863
            -- preload Temp Reg with 0x60
864
            alu_p60_temp_reg_o  <= true;
865
 
866
          -- Step 3: Check overflow on high nibble
867
          --         Add 0x60 to shadow Accumulator if true and store result
868
          --         in Accumulator and PSW (only Carry)
869
          when MSTATE5 =>
870
            alu_da_high_o        <= true;
871
 
872
            if alu_da_overflow_i then
873
              psw_special_data_o <= alu_carry_i;
874
            else
875
              alu_op_o           <= ALU_NOP;
876
              psw_special_data_o <= '0';
877
            end if;
878
            alu_read_alu_o       <= true;
879
            alu_write_accu_o     <= true;
880
            psw_write_carry_o    <= true;
881
 
882
          when others =>
883
            null;
884
 
885
        end case;
886
 
887 4 arniml
      -- Mnemonic DEC ---------------------------------------------------------
888
      when MN_DEC =>
889
        case clk_mstate_i is
890
          when MSTATE4 =>
891
            -- DEC Rr: store data from RAM to shadow Accumulator
892
            if opc_opcode_s(6) = '1' then
893
              dm_read_dmem_o         <= true;
894
              alu_write_shadow_o     <= true;
895
            end if;
896
 
897
          when MSTATE5 =>
898
            alu_op_o                 <= ALU_DEC;
899
            alu_read_alu_o           <= true;
900
 
901
            if opc_opcode_s(6) = '0' then
902
              -- write DEC of Accumulator to Accumulator
903
              alu_write_accu_o       <= true;
904
            else
905
              -- store DEC of shadow Accumulator back to dmem
906
              dm_write_dmem_s        <= true;
907
            end if;
908
 
909
          when others =>
910
            null;
911
 
912
        end case;
913
 
914
      -- Mnemonic DIS_EN_I ----------------------------------------------------
915
      when MN_DIS_EN_I =>
916
        if clk_mstate_i = MSTATE3 then
917
          if opc_opcode_s(4) = '1' then
918
            dis_i_s <= true;
919
          else
920
            en_i_s  <= true;
921
          end if;
922
        end if;
923
 
924
      -- Mnemonic DIS_EN_TCNTI ------------------------------------------------
925
      when MN_DIS_EN_TCNTI =>
926
        if clk_mstate_i = MSTATE3 then
927
          if opc_opcode_s(4) = '1' then
928
            dis_tcnti_s <= true;
929
          else
930
            en_tcnti_s  <= true;
931
          end if;
932
        end if;
933
 
934
      -- Mnemonic DJNZ --------------------------------------------------------
935
      when MN_DJNZ =>
936
        assert_psen_s              <= true;
937
 
938
        if not clk_second_cycle_i then
939
          case clk_mstate_i is
940
            -- store data from RAM to shadow Accumulator
941
            when MSTATE4 =>
942
              dm_read_dmem_o         <= true;
943
              alu_write_shadow_o     <= true;
944
 
945
            -- write DEC result of shadow Accumulator back to dmem and
946
            -- conditional branch logic
947
            when MSTATE5 =>
948
              alu_op_o               <= ALU_DEC;
949
              alu_read_alu_o         <= true;
950
              dm_write_dmem_s        <= true;
951
 
952
              cnd_compute_take_o     <= true;
953
              cnd_branch_cond_o      <= COND_Z;
954
              cnd_comp_value_o(0)    <= '0';
955
 
956
            when others =>
957
              null;
958
 
959
          end case;
960
 
961
        else
962
          -- store address in Program Counter low byte if branch has to
963
          -- be taken
964 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
965
            cond_jump_c2_m1_f;
966
          end if;
967 4 arniml
 
968
        end if;
969
 
970
      -- Mnemonic ENT0_CLK ----------------------------------------------------
971
      when MN_ENT0_CLK =>
972
        if clk_mstate_i = MSTATE3 then
973
          ent0_clk_s <= true;
974
        end if;
975
 
976
      -- Mnemonic IN ----------------------------------------------------------
977
      when MN_IN =>
978
        -- read Port and store in Accumulator
979
        if clk_second_cycle_i and clk_mstate_i = MSTATE2 then
980
          alu_write_accu_o <= true;
981
 
982
          if opc_opcode_s(1) = '0' then
983
            p1_read_p1_o   <= true;
984
          else
985
            p2_read_p2_o   <= true;
986
          end if;
987
        end if;
988
 
989
      -- Mnemonic INS ---------------------------------------------------------
990
      when MN_INS =>
991 143 arniml
        clk_assert_rd_o  <= true;
992
 
993 4 arniml
        -- read BUS and store in Accumulator
994
        if clk_second_cycle_i and clk_mstate_i = MSTATE2 then
995
          alu_write_accu_o <= true;
996
 
997
          add_read_bus_s   <= true;
998
        end if;
999
 
1000
      -- Mnemonic INC ---------------------------------------------------------
1001
      when MN_INC =>
1002
        case clk_mstate_i is
1003
          -- read RAM once for indirect address mode
1004
          when MSTATE3 =>
1005 92 arniml
            if not enable_quartus_bugfix_c or
1006
               opc_opcode_s(3) = '0' then
1007
              address_indirect_3_f;
1008
            end if;
1009 4 arniml
 
1010
          when MSTATE4 =>
1011
            -- INC Rr; INC @ Rr: store data from RAM to shadow Accumulator
1012
            if opc_opcode_s(3 downto 2) /= "01" then
1013
              dm_read_dmem_o         <= true;
1014
              alu_write_shadow_o     <= true;
1015
            end if;
1016
 
1017
          when MSTATE5 =>
1018
            alu_op_o                 <= ALU_INC;
1019
            alu_read_alu_o           <= true;
1020
 
1021
            if opc_opcode_s(3 downto 2) = "01" then
1022
              -- write INC output of ALU to Accumulator
1023
              alu_write_accu_o       <= true;
1024
            else
1025
              -- store INC of shadow Accumulator back to dmem
1026
              dm_write_dmem_s        <= true;
1027
            end if;
1028
 
1029
          when others =>
1030
            null;
1031
 
1032
        end case;
1033
 
1034
      -- Mnemonic JBB ---------------------------------------------------------
1035
      when MN_JBB =>
1036
        assert_psen_s          <= true;
1037
        cnd_branch_cond_o      <= COND_ON_BIT;
1038
 
1039
        if not clk_second_cycle_i then
1040
          -- read Accumulator and start branch calculation
1041
          if clk_mstate_i = MSTATE3 then
1042
            alu_read_alu_o     <= true;
1043
            cnd_compute_take_o <= true;
1044
            -- cnd_comp_value_o is ok by default assignment
1045
          end if;
1046
 
1047
        else
1048
          -- store address in Program Counter low byte if branch has to
1049
          -- be taken
1050 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1051
            cond_jump_c2_m1_f;
1052
          end if;
1053 4 arniml
 
1054
        end if;
1055
 
1056
      -- Mnemonic JC ----------------------------------------------------------
1057
      when MN_JC =>
1058
        assert_psen_s           <= true;
1059
        cnd_branch_cond_o       <= COND_C;
1060
 
1061
        if not clk_second_cycle_i then
1062
          -- start branch calculation
1063
          if clk_mstate_i = MSTATE3 then
1064
            cnd_compute_take_o  <= true;
1065
            cnd_comp_value_o(0) <= opc_opcode_s(4);
1066
          end if;
1067
 
1068
        else
1069
          -- store address in Program Counter low byte if branch has to
1070
          -- be taken
1071 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1072
            cond_jump_c2_m1_f;
1073
          end if;
1074 4 arniml
 
1075
        end if;
1076
 
1077
      -- Mnemonic JF ----------------------------------------------------------
1078
      when MN_JF =>
1079
        assert_psen_s           <= true;
1080
 
1081
        if not clk_second_cycle_i then
1082
          -- start branch calculation
1083
          if clk_mstate_i = MSTATE3 then
1084
            cnd_compute_take_o  <= true;
1085
            if opc_opcode_s(7) = '1' then
1086
              -- JF0
1087
              cnd_branch_cond_o <= COND_F0;
1088
            else
1089
              -- JF1
1090
              cnd_branch_cond_o <= COND_F1;
1091
            end if;
1092
 
1093
          end if;
1094
 
1095
        else
1096
          -- store address in Program Counter low byte if branch has to
1097
          -- be taken
1098 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1099
            cond_jump_c2_m1_f;
1100
          end if;
1101 4 arniml
 
1102
        end if;
1103
 
1104
 
1105
      -- Mnemonic JMP ---------------------------------------------------------
1106
      when MN_JMP =>
1107
        assert_psen_s        <= true;
1108
 
1109
        if clk_second_cycle_i then
1110
          case clk_mstate_i is
1111
            -- store address in Program Counter low byte
1112
            when MSTATE1 =>
1113
              pm_write_pcl_o <= true;
1114
              branch_taken_s <= true;
1115
 
1116
            -- store high part of target address in Program Counter
1117
            when MSTATE2 =>
1118 120 arniml
              data_s         <= "0000" & mb_v & opc_opcode_s(7 downto 5);
1119 4 arniml
              read_dec_s     <= true;
1120
              pm_write_pch_o <= true;
1121
 
1122
            when others =>
1123
              null;
1124
 
1125
          end case;
1126
 
1127
        end if;
1128
 
1129
      -- Mnemonic JMPP --------------------------------------------------------
1130
      when MN_JMPP =>
1131
        assert_psen_s    <= true;
1132
 
1133
        if not clk_second_cycle_i then
1134
          -- write Accumulator to Program Memory address
1135
          -- (skip page offset update from Program Counter)
1136
          if clk_mstate_i = MSTATE3 then
1137
            alu_read_alu_o <= true;
1138
            pm_addr_type_o <= PM_PAGE;
1139
          end if;
1140
 
1141
        else
1142
          if clk_mstate_i = MSTATE1 then
1143
            -- store address in Program Counter low byte
1144
            pm_write_pcl_o <= true;
1145
            branch_taken_s <= true;
1146
          end if;
1147
 
1148
        end if;
1149
 
1150
      -- Mnemonic JNI ---------------------------------------------------------
1151
      when MN_JNI =>
1152
        assert_psen_s          <= true;
1153
        cnd_branch_cond_o      <= COND_INT;
1154
 
1155
        if not clk_second_cycle_i then
1156
          -- start branch calculation
1157
          if clk_mstate_i = MSTATE3 then
1158
            cnd_compute_take_o <= true;
1159
          end if;
1160
 
1161
        else
1162
          -- store address in Program Counter low byte if branch has to
1163
          -- be taken
1164 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1165
            cond_jump_c2_m1_f;
1166
          end if;
1167 4 arniml
 
1168
        end if;
1169
 
1170
      -- Mnemonic JT ----------------------------------------------------------
1171
      when MN_JT =>
1172
        assert_psen_s           <= true;
1173
        if opc_opcode_s(6) = '0' then
1174
          cnd_branch_cond_o     <= COND_T0;
1175
        else
1176
          cnd_branch_cond_o     <= COND_T1;
1177
        end if;
1178
 
1179
        if not clk_second_cycle_i then
1180
          -- start branch calculation
1181
          if clk_mstate_i = MSTATE3 then
1182
            cnd_compute_take_o  <= true;
1183
            cnd_comp_value_o(0) <= opc_opcode_s(4);
1184
          end if;
1185
 
1186
        else
1187
          -- store address in Program Counter low byte if branch has to
1188
          -- be taken
1189 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1190
            cond_jump_c2_m1_f;
1191
          end if;
1192 4 arniml
 
1193
        end if;
1194
 
1195
      -- Mnemonic JTF ---------------------------------------------------------
1196
      when MN_JTF =>
1197
        assert_psen_s          <= true;
1198
        cnd_branch_cond_o      <= COND_TF;
1199
 
1200
        if not clk_second_cycle_i then
1201
          -- start branch calculation
1202
          if clk_mstate_i = MSTATE3 then
1203
            cnd_compute_take_o <= true;
1204
            jtf_executed_s     <= true;
1205
          end if;
1206
 
1207
        else
1208
          -- store address in Program Counter low byte if branch has to
1209
          -- be taken
1210 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1211
            cond_jump_c2_m1_f;
1212
          end if;
1213 4 arniml
 
1214
        end if;
1215
 
1216
      -- Mnemonic JZ ----------------------------------------------------------
1217
      when MN_JZ =>
1218
        assert_psen_s           <= true;
1219
        cnd_branch_cond_o       <= COND_Z;
1220
 
1221
        if not clk_second_cycle_i then
1222
          -- read Accumulator and start branch calculation
1223
          if clk_mstate_i = MSTATE3 then
1224
            alu_read_alu_o      <= true;
1225
            cnd_compute_take_o  <= true;
1226
            cnd_comp_value_o(0) <= opc_opcode_s(6);
1227
          end if;
1228
 
1229
        else
1230
          -- store address in Program Counter low byte if branch has to
1231
          -- be taken
1232 92 arniml
          if clk_mstate_i = MSTATE1 and cnd_take_branch_i then
1233
            cond_jump_c2_m1_f;
1234
          end if;
1235 4 arniml
 
1236
        end if;
1237
 
1238
      -- Mnemonic MOV_A_DATA --------------------------------------------------
1239
      when MN_MOV_A_DATA =>
1240
        assert_psen_s      <= true;
1241
 
1242
        -- Write Accumulator when contents of Program Memory is on bus
1243
        -- during machine state 1 of second cycle.
1244
        if clk_second_cycle_i and clk_mstate_i = MSTATE1 then
1245
          alu_write_accu_o <= true;
1246
        end if;
1247
 
1248
      -- Mnemonic MOV_A_RR ----------------------------------------------------
1249
      when MN_MOV_A_RR =>
1250
        case clk_mstate_i is
1251
          -- read RAM once for indirect address mode
1252
          when MSTATE3 =>
1253 92 arniml
            if not enable_quartus_bugfix_c or
1254
               opc_opcode_s(3) = '0' then
1255
              address_indirect_3_f;
1256
            end if;
1257 4 arniml
 
1258
          -- read data from RAM and store in Accumulator
1259
          when MSTATE4 =>
1260
            and_or_xor_add_4_f;
1261
            alu_write_accu_o <= true;
1262
 
1263
          when others =>
1264
            null;
1265
 
1266
        end case;
1267
 
1268
      -- Mnemonic MOV_A_PSW ---------------------------------------------------
1269
      when MN_MOV_A_PSW =>
1270
        if clk_mstate_i = MSTATE3 then
1271
          psw_read_psw_o   <= true;
1272
          psw_read_sp_o    <= true;
1273
          alu_write_accu_o <= true;
1274
        end if;
1275
 
1276
      -- Mnemoniv MOV_PSW_A ---------------------------------------------------
1277
      when MN_MOV_PSW_A =>
1278
        if clk_mstate_i = MSTATE3 then
1279
          alu_read_alu_o  <= true;
1280
          psw_write_psw_o <= true;
1281
          psw_write_sp_o  <= true;
1282
        end if;
1283
 
1284
      -- Mnemonic MOV_RR ------------------------------------------------------
1285
      when MN_MOV_RR =>
1286
        case clk_mstate_i is
1287
          -- read RAM once for indirect address mode
1288
          when MSTATE3 =>
1289 92 arniml
            if not enable_quartus_bugfix_c or
1290
               opc_opcode_s(3) = '0' then
1291
              address_indirect_3_f;
1292
            end if;
1293 4 arniml
 
1294
          -- write Accumulator to dmem
1295
          when MSTATE5 =>
1296
            alu_read_alu_o       <= true;
1297
            dm_write_dmem_s      <= true;
1298
 
1299
          when others =>
1300
            null;
1301
 
1302
        end case;
1303
 
1304
      -- Mnemonic MOV_RR_DATA -------------------------------------------------
1305
      when MN_MOV_RR_DATA =>
1306
        assert_psen_s     <= true;
1307
 
1308
        -- read RAM once for indirect address mode
1309
        if not clk_second_cycle_i and clk_mstate_i = MSTATE3 then
1310 92 arniml
          if not enable_quartus_bugfix_c or
1311
             opc_opcode_s(3) = '0' then
1312
            address_indirect_3_f;
1313
          end if;
1314 4 arniml
        end if;
1315
 
1316
        -- Write Data Memory when contents of Program Memory is on bus
1317
        -- during machine state 1 of second cycle.
1318
        if clk_second_cycle_i and clk_mstate_i = MSTATE1 then
1319
          dm_write_dmem_s <= true;
1320
        end if;
1321
 
1322
      -- Mnemonic MOV_T -------------------------------------------------------
1323
      when MN_MOV_T =>
1324
        if clk_mstate_i = MSTATE3 then
1325
          if opc_opcode_s(5) = '1' then
1326
            alu_read_alu_o    <= true;  -- MOV T, A
1327
            tim_write_timer_o <= true;
1328
          else
1329
            tim_read_timer_o  <= true;  -- MOV A, T
1330
            alu_write_accu_o  <= true;
1331
          end if;
1332
        end if;
1333
 
1334 21 arniml
      -- Mnemonic OUTD_PP_A ---------------------------------------------------
1335
      when MN_OUTD_PP_A =>
1336
        clk_assert_prog_o     <= true;
1337
 
1338
        if not clk_second_cycle_i then
1339
          case clk_mstate_i is
1340
            -- propagate expander port number to Port 2
1341
            when MSTATE3 =>
1342
 
1343
              data_s(7 downto 4)     <= (others => '0');
1344
              data_s(1 downto 0)     <= opc_opcode_s(1 downto 0);
1345
              -- decide which 8243 command to use
1346
              case opc_opcode_s(7 downto 4) is
1347
                when "1001" =>
1348
                  data_s(3 downto 2) <= "11";  -- ANLD command
1349
                when "1000" =>
1350
                  data_s(3 downto 2) <= "10";  -- ORLD command
1351
                when "0011" =>
1352
                  data_s(3 downto 2) <= "01";  -- MOVD command
1353
                when others =>
1354
                  null;
1355
              end case;
1356
 
1357
              read_dec_s      <= true;
1358
              p2_write_exp_o  <= true;
1359
 
1360
            -- output expander port number on Port 2 while active edge of PROG
1361
            -- write Accumulator to expander port
1362
            when MSTATE4 =>
1363
              p2_output_exp_o <= true;
1364
 
1365
              alu_read_alu_o  <= true;
1366
              p2_write_exp_o  <= true;
1367
 
1368
            when MSTATE5 =>
1369
              p2_output_exp_o <= true;
1370
 
1371
            when others =>
1372
              null;
1373
 
1374
          end case;
1375
 
1376
        else
1377
          -- hold expander port until inactive edge of PROG 
1378
          if clk_mstate_i = MSTATE1 or clk_mstate_i = MSTATE2 then
1379
            p2_output_exp_o   <= true;
1380
          end if;
1381
 
1382
        end if;
1383
 
1384
      -- Mnemonic MOVD_A_PP ---------------------------------------------------
1385
      when MN_MOVD_A_PP =>
1386
        clk_assert_prog_o            <= true;
1387
 
1388
        if not clk_second_cycle_i then
1389
          case clk_mstate_i is
1390
            -- propagate expander port number to Port 2
1391
            when MSTATE3 =>
1392
              data_s                 <= "0000" &
1393
                                        "00"   &  -- 8243 command: read
1394
                                        opc_opcode_s(1 downto 0);
1395
              read_dec_s             <= true;
1396
              p2_write_exp_o         <= true;
1397
 
1398
            -- output expander port number on Port 2 while active edge of PROG
1399
            -- write 1's to expander port to set lower nibble of Port 2 to input
1400
            when MSTATE4 =>
1401
              p2_output_exp_o        <= true;
1402
 
1403
              data_s(nibble_t'range) <= (others => '1');
1404
              read_dec_s             <= true;
1405
              p2_write_exp_o         <= true;
1406
 
1407
            when MSTATE5 =>
1408
              p2_output_exp_o        <= true;
1409
 
1410
            when others =>
1411
              null;
1412
 
1413
          end case;
1414
 
1415
        else
1416
          case clk_mstate_i is
1417
            -- hold expander port until inactive edge of PROG
1418
            when MSTATE1 =>
1419
              p2_output_exp_o  <= true;
1420
 
1421
            -- hold expander port until inactive edge of PROG
1422
            -- write Accumulator with nibble of expander port
1423
            when MSTATE2 =>
1424 101 arniml
              p2_read_p2_o     <= true;
1425 21 arniml
              p2_output_exp_o  <= true;
1426
              p2_read_exp_o    <= true;
1427
              alu_write_accu_o <= true;
1428
 
1429
            when others =>
1430
              null;
1431
 
1432
          end case;
1433
 
1434
        end if;
1435
 
1436 4 arniml
      -- Mnemonic MOVP --------------------------------------------------------
1437
      when MN_MOVP =>
1438
        assert_psen_s        <= true;
1439
 
1440
        if not clk_second_cycle_i then
1441
          -- write Accumulator to Program Memory address
1442
          -- (skip page offset update from Program Counter)
1443
          if clk_mstate_i = MSTATE3 then
1444
            alu_read_alu_o   <= true;
1445
            if opc_opcode_s(6) = '0' then
1446
              pm_addr_type_o <= PM_PAGE;
1447
            else
1448
              pm_addr_type_o <= PM_PAGE3;
1449
            end if;
1450
          end if;
1451
 
1452
        else
1453
          if clk_mstate_i = MSTATE1 then
1454
            -- store data from Program Memory in Accumulator
1455
            alu_write_accu_o <= true;
1456
            -- trick & treat to prevent additional PC increment
1457
            -- our branch target is the previously incremented PC!
1458
            branch_taken_s   <= true;
1459
          end if;
1460
 
1461
        end if;
1462
 
1463
      -- Mnemonic MOVX --------------------------------------------------------
1464
      when MN_MOVX =>
1465
        bus_bidir_bus_o        <= true;
1466
 
1467
        if opc_opcode_s(4) = '0' then
1468
          clk_assert_rd_o      <= true;
1469
        else
1470
          clk_assert_wr_o      <= true;
1471
        end if;
1472
 
1473
        if not clk_second_cycle_i then
1474 78 arniml
          case clk_mstate_i is
1475
            -- read dmem and put contents on BUS as external address
1476
            when MSTATE3 =>
1477
              dm_read_dmem_o     <= true;
1478
              bus_write_bus_o    <= true;
1479 4 arniml
 
1480 78 arniml
            -- store contents of Accumulator to BUS
1481
            when MSTATE5 =>
1482
              if opc_opcode_s(4) = '1' then
1483
                alu_read_alu_o   <= true;
1484
                bus_write_bus_o  <= true;
1485
              end if;
1486
 
1487
            when others =>
1488
              null;
1489
          end case;
1490
 
1491 4 arniml
        else
1492 178 arniml
          if clk_mstate_i = MSTATE2 then
1493 4 arniml
            if opc_opcode_s(4) = '0' then
1494
              -- store contents of BUS in Accumulator
1495
              add_read_bus_s   <= true;
1496
              alu_write_accu_o <= true;
1497
            else
1498
              -- store contents of Accumulator to BUS
1499 178 arniml
              -- to this to keep bus in output direction
1500 4 arniml
              alu_read_alu_o   <= true;
1501
              bus_write_bus_o  <= true;
1502
            end if;
1503
          end if;
1504
 
1505
        end if;
1506
 
1507
      -- Mnemonic NOP ---------------------------------------------------------
1508
      when MN_NOP =>
1509
        -- nothing to do
1510
 
1511
      -- Mnemonic ORL ---------------------------------------------------------
1512
      when MN_ORL =>
1513
        case clk_mstate_i is
1514
          -- read RAM once for indirect address mode
1515
          when MSTATE3 =>
1516 92 arniml
            if not enable_quartus_bugfix_c or
1517
               opc_opcode_s(3) = '0' then
1518
              address_indirect_3_f;
1519
            end if;
1520 4 arniml
 
1521
          -- store data from RAM to Temp Reg
1522
          when MSTATE4 =>
1523
            and_or_xor_add_4_f;
1524
 
1525
          -- perform OR and store in Accumulator
1526
          when MSTATE5 =>
1527
            and_or_xor_add_5_f(alu_op => ALU_OR);
1528
 
1529
          when others =>
1530
            null;
1531
 
1532
        end case;
1533
 
1534
      -- Mnemonic ORL_A_DATA --------------------------------------------------
1535
      when MN_ORL_A_DATA =>
1536
        assert_psen_s              <= true;
1537
 
1538
        if clk_second_cycle_i then
1539
          case clk_mstate_i is
1540
            -- write Temp Reg when contents of Program Memory is on bus
1541
            when MSTATE1 =>
1542
              alu_write_temp_reg_o <= true;
1543
 
1544
            -- perform OR and store in Accumulator
1545
            when MSTATE3 =>
1546
              and_or_xor_add_5_f(alu_op => ALU_OR);
1547
 
1548
            when others =>
1549
              null;
1550
 
1551
          end case;
1552
 
1553
        end if;
1554
 
1555
      -- Mnemonic ORL_EXT -----------------------------------------------------
1556
      when MN_ORL_EXT =>
1557
        assert_psen_s            <= true;
1558
 
1559
        if not clk_second_cycle_i then
1560
          -- read port to Temp Reg
1561
          if clk_mstate_i = MSTATE5 then
1562
            if opc_opcode_s(1 downto 0) = "00" then
1563
              add_read_bus_s     <= true;
1564
            elsif opc_opcode_s(1) = '0' then
1565
              p1_read_p1_o       <= true;
1566
              p1_read_reg_o      <= true;
1567
            else
1568
              p2_read_p2_o       <= true;
1569
              p2_read_reg_o      <= true;
1570
            end if;
1571
 
1572
            alu_write_temp_reg_o <= true;
1573
          end if;
1574
 
1575
        else
1576
          case clk_mstate_i is
1577
            -- write shadow Accumulator when contents of Program Memory is
1578
            -- on bus
1579
            when MSTATE1 =>
1580
              alu_write_shadow_o <= true;
1581
 
1582
            -- loop shadow Accumulator through ALU to prevent update from
1583
            -- real Accumulator
1584
            when MSTATE2 =>
1585
              alu_read_alu_o     <= true;
1586
              alu_write_shadow_o <= true;
1587
 
1588
            -- write result of OR operation back to port
1589
            when MSTATE3 =>
1590
              alu_op_o           <= ALU_OR;
1591
              alu_read_alu_o     <= true;
1592
 
1593
              if opc_opcode_s(1 downto 0) = "00" then
1594
                bus_write_bus_o  <= true;
1595
              elsif opc_opcode_s(1) = '0' then
1596
                p1_write_p1_o    <= true;
1597
              else
1598
                p2_write_p2_o    <= true;
1599
              end if;
1600
 
1601
            when others =>
1602
              null;
1603
 
1604
          end case;
1605
 
1606
        end if;
1607
 
1608
      -- Mnemonic OUTL_EXT ----------------------------------------------------
1609
      when MN_OUTL_EXT =>
1610 143 arniml
        if opc_opcode_s(4) = '0' then
1611
          clk_assert_wr_o <= true;
1612
        end if;
1613
 
1614 4 arniml
        -- read Accumulator and store in Port/BUS output register
1615 143 arniml
        if not clk_second_cycle_i and clk_mstate_i = MSTATE4 then
1616 4 arniml
          alu_read_alu_o  <= true;
1617
 
1618
          if opc_opcode_s(4) = '1' then
1619
            if opc_opcode_s(1) = '0' then
1620
              p1_write_p1_o <= true;
1621
            else
1622
              p2_write_p2_o <= true;
1623
            end if;
1624
 
1625
          else
1626
            bus_write_bus_o <= true;
1627
 
1628
          end if;
1629
 
1630
        end if;
1631
 
1632
      -- Mnemonic RET ---------------------------------------------------------
1633
      when MN_RET =>
1634
        if not clk_second_cycle_i then
1635
          case clk_mstate_i is
1636
            -- decrement Stack Pointer
1637
            when MSTATE3 =>
1638
              psw_dec_stackp_o     <= true;
1639
 
1640
            -- read Stack Pointer and address Data Memory for low byte
1641
            when MSTATE4 =>
1642
              psw_read_sp_o        <= true;
1643
              dm_write_dmem_addr_o <= true;
1644
              dm_addr_type_o       <= DM_STACK;
1645
 
1646
            -- read Data Memory and store to Program Counter low
1647
            -- prepare address to Data memory for high byte
1648
            when MSTATE5 =>
1649
              dm_read_dmem_o       <= true;
1650
              pm_write_pcl_o       <= true;
1651
              dm_write_dmem_addr_o <= true;
1652
              dm_addr_type_o       <= DM_STACK_HIGH;
1653
 
1654
            when others =>
1655
              null;
1656
 
1657
          end case;
1658
 
1659
        else
1660
          case clk_mstate_i is
1661
            -- read Data Memory and store to Program Counter high and PSW
1662
            when MSTATE1 =>
1663
              dm_read_dmem_o         <= true;
1664
              pm_write_pch_o         <= true;
1665
              if opc_opcode_s(4) = '1' then
1666
                psw_write_psw_o      <= true;
1667
                retr_executed_s      <= true;
1668
              end if;
1669
 
1670
            when MSTATE2 =>
1671
              add_write_pmem_addr_s  <= true;
1672
 
1673
            when others =>
1674
              null;
1675
 
1676
          end case;
1677
 
1678
        end if;
1679
 
1680
      -- Mnemonic RL ----------------------------------------------------------
1681
      when MN_RL =>
1682
        if clk_mstate_i = MSTATE3 then
1683
          alu_op_o             <= ALU_RL;
1684
          alu_read_alu_o       <= true;
1685
          alu_write_accu_o     <= true;
1686
 
1687
          if opc_opcode_s(4) = '1' then
1688
            psw_special_data_o <= alu_carry_i;
1689
            psw_write_carry_o  <= true;
1690
            alu_use_carry_o    <= true;
1691
          end if;
1692
        end if;
1693
 
1694
      -- Mnemonic RR ----------------------------------------------------------
1695
      when MN_RR =>
1696
        if clk_mstate_i = MSTATE3 then
1697
          alu_op_o             <= ALU_RR;
1698
          alu_read_alu_o       <= true;
1699
          alu_write_accu_o     <= true;
1700
 
1701
          if opc_opcode_s(4) = '0' then
1702
            psw_special_data_o <= alu_carry_i;
1703
            psw_write_carry_o  <= true;
1704
            alu_use_carry_o    <= true;
1705
          end if;
1706
        end if;
1707
 
1708
      -- Mnemonic SEL_MB ------------------------------------------------------
1709
      when MN_SEL_MB =>
1710
        if clk_mstate_i = MSTATE3 then
1711
          if opc_opcode_s(4) = '1' then
1712
            set_mb_s   <= true;
1713
          else
1714
            clear_mb_s <= true;
1715
          end if;
1716
        end if;
1717
 
1718
      -- Mnemonic SEL_RB ------------------------------------------------------
1719
      when MN_SEL_RB =>
1720
        if clk_mstate_i = MSTATE3 then
1721
          psw_special_data_o <= opc_opcode_s(4);
1722
          psw_write_bs_o     <= true;
1723
        end if;
1724
 
1725
      -- Mnemonic STOP_TCNT ---------------------------------------------------
1726
      when MN_STOP_TCNT =>
1727
        if clk_mstate_i = MSTATE3 then
1728
          tim_stop_tcnt_o <= true;
1729
        end if;
1730
 
1731
      -- Mnemonic STRT --------------------------------------------------------
1732
      when MN_STRT =>
1733
        if clk_mstate_i = MSTATE3 then
1734
          if opc_opcode_s(4) = '1' then
1735
            tim_start_t_o   <= true;
1736
          else
1737
            tim_start_cnt_o <= true;
1738
          end if;
1739
        end if;
1740
 
1741
      -- Mnemonic SWAP --------------------------------------------------------
1742
      when MN_SWAP =>
1743
        alu_op_o           <= ALU_SWAP;
1744
 
1745
        if clk_mstate_i = MSTATE3 then
1746
          alu_read_alu_o   <= true;
1747
          alu_write_accu_o <= true;
1748
        end if;
1749
 
1750
      -- Mnemonic XCH ---------------------------------------------------------
1751
      when MN_XCH =>
1752
        case clk_mstate_i is
1753
          -- read RAM once for indirect address mode
1754
          when MSTATE3 =>
1755 92 arniml
            if not enable_quartus_bugfix_c or
1756
               opc_opcode_s(3) = '0' then
1757
              address_indirect_3_f;
1758
            end if;
1759 4 arniml
 
1760 38 arniml
          -- store data from RAM in Accumulator and Temp Reg
1761 4 arniml
          -- Accumulator is already shadowed!
1762
          when MSTATE4 =>
1763 38 arniml
            dm_read_dmem_o       <= true;
1764
            alu_write_accu_o     <= true;
1765
            alu_write_temp_reg_o <= true;
1766
            if opc_opcode_s(4) = '1' then
1767
              -- XCHD
1768
              -- only write lower nibble of Accumulator
1769
              alu_accu_low_o     <= true;
1770
            end if;
1771 4 arniml
 
1772
          -- store data from shadow (previous) Accumulator to dmem
1773
          when MSTATE5 =>
1774 38 arniml
            dm_write_dmem_s      <= true;
1775
            alu_read_alu_o       <= true;
1776
            if opc_opcode_s(4) = '1' then
1777
              -- XCHD
1778
              -- concatenate shadow Accumulator and Temp Reg
1779
              alu_op_o           <= ALU_CONCAT;
1780
            end if;
1781 4 arniml
 
1782
          when others =>
1783
            null;
1784
 
1785
        end case;
1786
 
1787
      -- Mnemonic XRL ---------------------------------------------------------
1788
      when MN_XRL =>
1789
        case clk_mstate_i is
1790
          -- read RAM once for indirect address mode
1791
          when MSTATE3 =>
1792 92 arniml
            if not enable_quartus_bugfix_c or
1793
               opc_opcode_s(3) = '0' then
1794
              address_indirect_3_f;
1795
            end if;
1796 4 arniml
 
1797
          -- store data from RAM to Temp Reg
1798
          when MSTATE4 =>
1799
            and_or_xor_add_4_f;
1800
 
1801
          -- perform XOR and store in Accumulator
1802
          when MSTATE5 =>
1803
            and_or_xor_add_5_f(alu_op => ALU_XOR);
1804
 
1805
          when others =>
1806
            null;
1807
 
1808
        end case;
1809
 
1810
      -- Mnemonic XRL_A_DATA --------------------------------------------------
1811
      when MN_XRL_A_DATA =>
1812
        assert_psen_s              <= true;
1813
 
1814
        if clk_second_cycle_i then
1815
          case clk_mstate_i is
1816
            -- write Temp Reg when contents of Program Memory is on bus
1817
            when MSTATE1 =>
1818
              alu_write_temp_reg_o <= true;
1819
 
1820
            -- perform XOR and store in Accumulator
1821
            when MSTATE3 =>
1822
              and_or_xor_add_5_f(alu_op => ALU_XOR);
1823
 
1824
            when others =>
1825
              null;
1826
 
1827
          end case;
1828
 
1829
        end if;
1830
 
1831
      -- Unimplemented mnemonic -----------------------------------------------
1832
      when others =>
1833
        -- this will behave like a NOP
1834
 
1835
        -- pragma translate_off
1836
        assert false
1837
          report "Mnemonic not yet implemented."
1838
          severity warning;
1839
        -- pragma translate_on
1840
 
1841
    end case;
1842
 
1843
  end process decode;
1844
  --
1845
  -----------------------------------------------------------------------------
1846
 
1847
 
1848
  -----------------------------------------------------------------------------
1849
  -- Process regs
1850
  --
1851
  -- Purpose:
1852
  --   Implements the various registes.
1853
  --
1854
  regs: process (res_i, clk_i)
1855
  begin
1856
    if res_i = res_active_c then
1857
      branch_taken_q <= false;
1858
      f1_q           <= '0';
1859
      mb_q           <= '0';
1860
      t0_dir_q       <= '0';
1861 38 arniml
      -- pragma translate_off
1862 64 arniml
      istrobe_res_q  <= '1';
1863
      istrobe_q      <= '0';
1864 60 arniml
      injected_int_q <= '0';
1865 38 arniml
      -- pragma translate_on
1866 4 arniml
 
1867
    elsif clk_i'event and clk_i = clk_active_c then
1868
      if en_clk_i then
1869
 
1870
        -- branch taken flag
1871
        if branch_taken_s then
1872
          branch_taken_q <= true;
1873
        elsif clk_mstate_i = MSTATE5 then
1874
          -- release flag when new instruction starts
1875
          branch_taken_q <= false;
1876
        end if;
1877
 
1878
        -- Flag 1
1879
        if clear_f1_s then
1880
          f1_q         <= '0';
1881
        elsif cpl_f1_s then
1882
          f1_q         <= not f1_q;
1883
        end if;
1884
 
1885
        -- Memory Bank select
1886
        if clear_mb_s then
1887
          mb_q         <= '0';
1888
        elsif set_mb_s then
1889
          mb_q         <= '1';
1890
        end if;
1891
 
1892
        -- T0 direction selection
1893
        if ent0_clk_s then
1894
          t0_dir_q     <= '1';
1895
        end if;
1896
 
1897 60 arniml
        -- pragma translate_off
1898
        -- Marker for injected instruction ------------------------------------
1899
        if opc_inj_int_s then
1900
          injected_int_q <= '1';
1901
        elsif clk_mstate_i = MSTATE5 and last_cycle_s then
1902
          injected_int_q <= '0';
1903
        end if;
1904 64 arniml
 
1905
        -- Remove istrobe after reset suppression -----------------------------
1906
        if clk_mstate_i = MSTATE5 and last_cycle_s then
1907
          istrobe_res_q  <= '0';
1908
        end if;
1909 60 arniml
        -- pragma translate_on
1910
 
1911 38 arniml
      end if;
1912
 
1913 64 arniml
      -- pragma translate_off
1914
      -- Instruction Strobe ---------------------------------------------------
1915
      if clk_mstate_i = MSTATE5 and last_cycle_s and
1916
         injected_int_q = '0' then
1917
        if istrobe_res_q = '0' then
1918
          istrobe_q <= '1';
1919
        end if;
1920
      else
1921
        istrobe_q   <= '0';
1922
      end if;
1923
      -- pragma translate_on
1924
 
1925 4 arniml
    end if;
1926
 
1927
  end process regs;
1928
  --
1929
  -----------------------------------------------------------------------------
1930
 
1931 53 arniml
  -- pragma translate_off
1932
  -- assign to global signal for testbench
1933 64 arniml
  tb_istrobe_s <= istrobe_q;
1934 53 arniml
  -- pragma translate_on
1935 4 arniml
 
1936 53 arniml
 
1937 4 arniml
  -----------------------------------------------------------------------------
1938
  -- Output Mapping.
1939
  -----------------------------------------------------------------------------
1940
  clk_multi_cycle_o    <= opc_multi_cycle_s;
1941
  cnd_f1_o             <= f1_q;
1942
  cnd_tf_o             <= tf_s;
1943
  data_o               <=   data_s
1944
                          when read_dec_s else
1945
                            (others => bus_idle_level_c);
1946
  dm_write_dmem_o      <= dm_write_dmem_s      and en_clk_i;
1947
  pm_inc_pc_o          <= pm_inc_pc_s          or add_inc_pc_s;
1948
  pm_write_pmem_addr_o <= pm_write_pmem_addr_s or add_write_pmem_addr_s;
1949
  t0_dir_o             <= t0_dir_q;
1950
  bus_read_bus_o       <= bus_read_bus_s       or add_read_bus_s;
1951
 
1952
end rtl;
1953
 
1954
 
1955
-------------------------------------------------------------------------------
1956
-- File History:
1957
--
1958
-- $Log: not supported by cvs2svn $
1959 188 arniml
-- Revision 1.19  2005/06/11 10:08:43  arniml
1960
-- introduce prefix 't48_' for all packages, entities and configurations
1961
--
1962 179 arniml
-- Revision 1.18  2005/06/09 22:18:28  arniml
1963
-- Move latching of BUS to MSTATE2
1964
--   -> sample BUS at the end of RD'
1965
--
1966 178 arniml
-- Revision 1.17  2005/05/09 22:26:08  arniml
1967
-- remove obsolete output stack_high_o
1968
--
1969 171 arniml
-- Revision 1.16  2004/10/25 19:39:24  arniml
1970
-- Fix bug report:
1971
-- "RD' and WR' not asserted for INS A, BUS and OUTL BUS, A"
1972
-- rd is asserted for INS A, BUS
1973
-- wr is asserted for OUTL BUS, A
1974
-- P1, P2 and BUS are written in first instruction cycle
1975
--
1976 143 arniml
-- Revision 1.15  2004/09/12 00:35:44  arniml
1977
-- Fix bug report:
1978
-- "PSENn Timing"
1979
-- PSEN is now only asserted for the second cycle if explicitely
1980
-- requested by assert_psen_s.
1981
-- The previous implementation asserted PSEN together with RD or WR.
1982
--
1983 134 arniml
-- Revision 1.14  2004/06/30 21:18:28  arniml
1984
-- Fix bug report:
1985
-- "Program Memory bank can be switched during interrupt"
1986
-- int module emits int_in_progress signal that is used inside the decoder
1987
-- to hold mb low for JMP and CALL during interrupts
1988
--
1989 120 arniml
-- Revision 1.13  2004/05/20 21:51:40  arniml
1990
-- clean-up use of ea_i
1991
--
1992 106 arniml
-- Revision 1.12  2004/05/17 14:40:09  arniml
1993
-- assert p2_read_p2_o when expander port is read
1994
--
1995 101 arniml
-- Revision 1.11  2004/05/16 15:33:39  arniml
1996
-- work around bug in Quartus II 4.0
1997
--
1998 92 arniml
-- Revision 1.10  2004/04/25 16:22:03  arniml
1999
-- adjust external timing of BUS
2000
--
2001 78 arniml
-- Revision 1.9  2004/04/24 11:22:55  arniml
2002
-- removed superfluous signal from sensitivity list
2003
--
2004 72 arniml
-- Revision 1.8  2004/04/18 18:57:43  arniml
2005
-- + enhance instruction strobe generation
2006
-- + rework address output under EA=1 conditions
2007
--
2008 64 arniml
-- Revision 1.7  2004/04/15 22:06:05  arniml
2009
-- + add marker for injected calls
2010
-- + suppress intstruction strobes for injected calls
2011
--
2012 60 arniml
-- Revision 1.6  2004/04/14 20:53:33  arniml
2013
-- make istrobe visible through testbench package
2014
--
2015 53 arniml
-- Revision 1.5  2004/04/07 22:09:03  arniml
2016
-- remove unused signals
2017
--
2018 45 arniml
-- Revision 1.4  2004/04/04 14:18:53  arniml
2019
-- add measures to implement XCHD
2020
--
2021 38 arniml
-- Revision 1.3  2004/03/28 21:15:48  arniml
2022
-- implemented mnemonic DA
2023
--
2024 27 arniml
-- Revision 1.2  2004/03/28 13:06:32  arniml
2025
-- implement mnemonics:
2026
--    + MOVD_A_PP
2027
--    + OUTD_PP_A -> ANLD PP, A; MOVD PP, A; ORLD PP, A
2028
--
2029 21 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
2030
-- initial check-in
2031 27 arniml
--
2032 4 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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