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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [rtl/] [vhdl/] [decoder.vhd] - Blame information for rev 179

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

powered by: WebSVN 2.1.0

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