OSDN Git Service

fucking big survery still under working...
authorastoria-d@fc <astoria-d@fc>
Mon, 25 Jul 2016 00:46:33 +0000 (09:46 +0900)
committerastoria-d@fc <astoria-d@fc>
Mon, 25 Jul 2016 00:46:33 +0000 (09:46 +0900)
de1_nes/cpu/alu.vhd
de1_nes/cpu/cpu_registers.vhd
de1_nes/cpu/decoder.vhd
de1_nes/cpu/mos6502.vhd
doc/mos6502-bus.xlsx

index 69633ef..d854de3 100644 (file)
@@ -1,5 +1,5 @@
 ----------------------------
----- 6502 ALU implementation
+---- 6502 address calrucator
 ----------------------------
 library ieee;
 use ieee.std_logic_1164.all;
@@ -7,12 +7,18 @@ use ieee.std_logic_unsigned.all;
 use ieee.std_logic_arith.conv_std_logic_vector;
 use work.motonesfpga_common.all;
 
-entity alu is 
+entity address_calcurator is 
     generic (   dsize : integer := 8
             );
     port (  
             set_clk         : in std_logic;
             trig_clk        : in std_logic;
+
+            --instruction reg
+            instruction     : in std_logic_vector (dsize - 1 downto 0);
+            exec_cycle      : in std_logic_vector (5 downto 0);
+
+            --control line.
             pcl_inc_n       : in std_logic;
             sp_oe_n         : in std_logic;
             sp_push_n       : in std_logic;
@@ -25,28 +31,21 @@ entity alu is
             indir_n         : in std_logic;
             indir_x_n       : in std_logic;
             indir_y_n       : in std_logic;
-            arith_en_n      : in std_logic;
-            instruction     : in std_logic_vector (dsize - 1 downto 0);
-            exec_cycle      : in std_logic_vector (5 downto 0);
-            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);
-            acc_out         : in std_logic_vector (dsize - 1 downto 0);
+
+            --in/out buses.
             index_bus       : in std_logic_vector (dsize - 1 downto 0);
             bal             : in std_logic_vector (dsize - 1 downto 0);
             bah             : in std_logic_vector (dsize - 1 downto 0);
-            addr_back       : out std_logic_vector (dsize - 1 downto 0);
-            acc_in          : out std_logic_vector (dsize - 1 downto 0);
+            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);
+            addr_back_l     : out std_logic_vector (dsize - 1 downto 0);
+            addr_back_h     : out std_logic_vector (dsize - 1 downto 0);
             abl             : out std_logic_vector (dsize - 1 downto 0);
             abh             : out std_logic_vector (dsize - 1 downto 0);
-            ea_carry        : out std_logic;
-            carry_in        : in std_logic;
-            negative        : out std_logic;
-            zero            : out std_logic;
-            carry_out       : out std_logic;
-            overflow        : out std_logic
-    );
-end alu;
+            ea_carry        : out std_logic
+            );
+end address_calcurator;
 
-architecture rtl of alu is
+architecture rtl of address_calcurator is
 
 component d_flip_flop
     generic (
@@ -84,7 +83,7 @@ component tri_state_buffer
         );
 end component;
 
-component address_calculator
+component addr_alu
     generic (   dsize : integer := 8
             );
     port ( 
@@ -97,41 +96,12 @@ component address_calculator
     );
 end component;
 
-component alu_core
-    generic (   dsize : integer := 8
-            );
-    port ( 
-            sel         : in std_logic_vector (3 downto 0);
-            d1          : in std_logic_vector (dsize - 1 downto 0);
-            d2          : in std_logic_vector (dsize - 1 downto 0);
-            d_out       : out std_logic_vector (dsize - 1 downto 0);
-            carry_in    : in std_logic;
-            negative    : out std_logic;
-            zero        : out std_logic;
-            carry_out   : out std_logic;
-            overflow    : out std_logic
-    );
-end component;
 
 constant ADDR_ADC    : std_logic_vector (1 downto 0) := "00";
 constant ADDR_INC    : std_logic_vector (1 downto 0) := "01";
 constant ADDR_DEC    : std_logic_vector (1 downto 0) := "10";
 constant ADDR_SIGNED_ADD : std_logic_vector (1 downto 0) := "11";
 
-constant ALU_AND    : std_logic_vector (3 downto 0) := "0000";
-constant ALU_EOR    : std_logic_vector (3 downto 0) := "0001";
-constant ALU_OR     : std_logic_vector (3 downto 0) := "0010";
-constant ALU_BIT    : std_logic_vector (3 downto 0) := "0011";
-constant ALU_ADC    : std_logic_vector (3 downto 0) := "0100";
-constant ALU_SBC    : std_logic_vector (3 downto 0) := "0101";
-constant ALU_CMP    : std_logic_vector (3 downto 0) := "0110";
-constant ALU_ASL    : std_logic_vector (3 downto 0) := "0111";
-constant ALU_LSR    : std_logic_vector (3 downto 0) := "1000";
-constant ALU_ROL    : std_logic_vector (3 downto 0) := "1001";
-constant ALU_ROR    : std_logic_vector (3 downto 0) := "1010";
-constant ALU_INC    : std_logic_vector (3 downto 0) := "1011";
-constant ALU_DEC    : std_logic_vector (3 downto 0) := "1100";
-
 ---for indirect addressing.
 constant T0 : std_logic_vector (5 downto 0) := "000000";
 constant T1 : std_logic_vector (5 downto 0) := "000001";
@@ -162,25 +132,6 @@ signal addr_c_in : std_logic;
 signal addr_c : std_logic;
 signal addr_c_reg : std_logic;
 
------------ signals for arithmatic ----------
-signal sel : std_logic_vector (3 downto 0);
-signal d1 : std_logic_vector (dsize - 1 downto 0);
-signal d2 : std_logic_vector (dsize - 1 downto 0);
-signal d_out : std_logic_vector (dsize - 1 downto 0);
-signal alu_out : std_logic_vector (dsize - 1 downto 0);
-
-signal n : std_logic;
-signal z : std_logic;
-signal c : std_logic;
-signal v : std_logic;
-
-signal arith_buf_we_n : std_logic;
-signal arith_buf_oe_n : std_logic;
-signal arith_reg_in : std_logic_vector (dsize - 1 downto 0);
-signal arith_reg : std_logic_vector (dsize - 1 downto 0);
-signal arith_reg_out : std_logic_vector (dsize - 1 downto 0);
-signal d_oe_n : std_logic;
-
 begin
     ----------------------------------------
      -- address calucurator instances ----
@@ -192,26 +143,13 @@ begin
     tmp_dff : d_flip_flop generic map (dsize) 
             port map(trig_clk, '1', '1', tmp_buf_we_n, tmp_reg_in, tmp_reg);
 
-    addr_calc_inst : address_calculator generic map (dsize)
+    addr_calc_inst : addr_alu generic map (dsize)
             port map (a_sel, addr1, addr2, addr_out, addr_c_in, addr_c);
 
     ea_carry_dff_bit : d_flip_flop_bit 
             port map(trig_clk, '1', '1', 
                     '0', addr_c, addr_c_reg);
 
-    ----------------------------------------
-     -- arithmatic operation instances ----
-    ----------------------------------------
-    arith_dff : d_flip_flop generic map (dsize) 
-            port map(trig_clk, '1', '1', arith_buf_we_n, arith_reg_in, arith_reg);
-    arith_buf : tri_state_buffer generic map (dsize)
-            port map (arith_buf_oe_n, arith_reg, arith_reg_out);
-
-    alu_inst : alu_core generic map (dsize)
-            port map (sel, d1, d2, alu_out, carry_in, n, z, c, v);
-    alu_buf : tri_state_buffer generic map (dsize)
-            port map (d_oe_n, alu_out, d_out);
-
     -------------------------------
     ----- address calcuration -----
     -------------------------------
@@ -227,10 +165,11 @@ begin
         ea_carry <= '0';
         a_sel <= ADDR_INC;
         addr1 <= bal;
-        addr_back <= addr_out;
+        addr_back_l <= addr_out;
 
         abl <= bal;
         abh <= bah + addr_c;
+        addr_back_h <= addr_out;
 
     elsif (sp_oe_n = '0') then
         --stack operation...
@@ -243,13 +182,13 @@ begin
             --case pop
             a_sel <= ADDR_INC;
             addr1 <= bal;
-            addr_back <= addr_out;
+            addr_back_l <= addr_out;
             abl <= bal;
         else
             ---case push
             a_sel <= ADDR_DEC;
             addr1 <= bal;
-            addr_back <= addr_out;
+            addr_back_l <= addr_out;
             abl <= bal;
         end if;
     elsif (zp_n = '0') then
@@ -303,7 +242,7 @@ begin
             ---addr1 is pch.`
             addr1 <= bah;
             ---rel val is on the d_bus.
-            addr_back <= addr_out;
+            addr_back_h <= addr_out;
             ea_carry <= '0'; 
 
             --keep the value in the cycle
@@ -318,7 +257,7 @@ begin
             addr1 <= bal;
             ---rel val is on the d_bus.
             addr2 <= int_d_bus;
-            addr_back <= addr_out;
+            addr_back_l <= addr_out;
             addr_c_in <= '0';
             ea_carry <= addr_c_reg;
 
@@ -474,14 +413,140 @@ begin
 
         ----addr_back is always bal for jmp/jsr instruction....
         -----TODO must check later if it's ok.
-        addr_back <= bal;
+        addr_back_l <= bal;
+        addr_back_h <= bah;
     end if; --if (pcl_inc_n = '0') then
 
     end process;
+end rtl;
 
     -------------------------------
-    ---- arithmatic operations-----
+    ---- ALU -----
     -------------------------------
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_unsigned.all;
+use ieee.std_logic_arith.conv_std_logic_vector;
+use work.motonesfpga_common.all;
+
+entity alu is 
+    generic (   dsize : integer := 8
+            );
+    port (  
+            set_clk         : in std_logic;
+            trig_clk        : in std_logic;
+            instruction     : in std_logic_vector (dsize - 1 downto 0);
+            exec_cycle      : in std_logic_vector (5 downto 0);
+            arith_en_n      : in std_logic;
+            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);
+            acc_in          : out std_logic_vector (dsize - 1 downto 0);
+            acc_out         : in std_logic_vector (dsize - 1 downto 0);
+            index_bus       : in std_logic_vector (dsize - 1 downto 0);
+            carry_in        : in std_logic;
+            negative        : out std_logic;
+            zero            : out std_logic;
+            carry_out       : out std_logic;
+            overflow        : out std_logic
+    );
+end alu;
+
+architecture rtl of alu is
+
+component alu_core
+    generic (   dsize : integer := 8
+            );
+    port ( 
+            sel         : in std_logic_vector (3 downto 0);
+            d1          : in std_logic_vector (dsize - 1 downto 0);
+            d2          : in std_logic_vector (dsize - 1 downto 0);
+            d_out       : out std_logic_vector (dsize - 1 downto 0);
+            carry_in    : in std_logic;
+            negative    : out std_logic;
+            zero        : out std_logic;
+            carry_out   : out std_logic;
+            overflow    : out std_logic
+    );
+end component;
+
+component d_flip_flop
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            clk     : in std_logic;
+            res_n   : in std_logic;
+            set_n   : in std_logic;
+            we_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+component tri_state_buffer
+    generic (
+            dsize : integer := 8
+            );
+    port (  
+            oe_n    : in std_logic;
+            d       : in std_logic_vector (dsize - 1 downto 0);
+            q       : out std_logic_vector (dsize - 1 downto 0)
+        );
+end component;
+
+constant ALU_AND    : std_logic_vector (3 downto 0) := "0000";
+constant ALU_EOR    : std_logic_vector (3 downto 0) := "0001";
+constant ALU_OR     : std_logic_vector (3 downto 0) := "0010";
+constant ALU_BIT    : std_logic_vector (3 downto 0) := "0011";
+constant ALU_ADC    : std_logic_vector (3 downto 0) := "0100";
+constant ALU_SBC    : std_logic_vector (3 downto 0) := "0101";
+constant ALU_CMP    : std_logic_vector (3 downto 0) := "0110";
+constant ALU_ASL    : std_logic_vector (3 downto 0) := "0111";
+constant ALU_LSR    : std_logic_vector (3 downto 0) := "1000";
+constant ALU_ROL    : std_logic_vector (3 downto 0) := "1001";
+constant ALU_ROR    : std_logic_vector (3 downto 0) := "1010";
+constant ALU_INC    : std_logic_vector (3 downto 0) := "1011";
+constant ALU_DEC    : std_logic_vector (3 downto 0) := "1100";
+
+constant T0 : std_logic_vector (5 downto 0) := "000000";
+constant T1 : std_logic_vector (5 downto 0) := "000001";
+constant T2 : std_logic_vector (5 downto 0) := "000010";
+constant T3 : std_logic_vector (5 downto 0) := "000011";
+constant T4 : std_logic_vector (5 downto 0) := "000100";
+constant T5 : std_logic_vector (5 downto 0) := "000101";
+
+----------- signals for arithmatic ----------
+signal sel : std_logic_vector (3 downto 0);
+signal d1 : std_logic_vector (dsize - 1 downto 0);
+signal d2 : std_logic_vector (dsize - 1 downto 0);
+signal d_out : std_logic_vector (dsize - 1 downto 0);
+signal alu_out : std_logic_vector (dsize - 1 downto 0);
+
+signal n : std_logic;
+signal z : std_logic;
+signal c : std_logic;
+signal v : std_logic;
+
+signal arith_buf_we_n : std_logic;
+signal arith_buf_oe_n : std_logic;
+signal arith_reg_in : std_logic_vector (dsize - 1 downto 0);
+signal arith_reg : std_logic_vector (dsize - 1 downto 0);
+signal arith_reg_out : std_logic_vector (dsize - 1 downto 0);
+signal d_oe_n : std_logic;
+
+begin
+    ----------------------------------------
+     -- arithmatic operation instances ----
+    ----------------------------------------
+    arith_dff : d_flip_flop generic map (dsize) 
+            port map(trig_clk, '1', '1', arith_buf_we_n, arith_reg_in, arith_reg);
+    arith_buf : tri_state_buffer generic map (dsize)
+            port map (arith_buf_oe_n, arith_reg, arith_reg_out);
+
+    alu_inst : alu_core generic map (dsize)
+            port map (sel, d1, d2, alu_out, carry_in, n, z, c, v);
+    alu_buf : tri_state_buffer generic map (dsize)
+            port map (d_oe_n, alu_out, d_out);
+
     alu_arith_p : process (
                     arith_en_n,
                     instruction, exec_cycle, int_d_bus, acc_out, 
@@ -766,7 +831,7 @@ library ieee;
 use ieee.std_logic_1164.all;
 use ieee.std_logic_unsigned.all;
 
-entity address_calculator is 
+entity addr_alu is 
     generic (   dsize : integer := 8
             );
     port ( 
@@ -777,9 +842,9 @@ entity address_calculator is
             carry_in    : in std_logic;
             carry_out   : out std_logic
     );
-end address_calculator;
+end addr_alu;
 
-architecture rtl of address_calculator is
+architecture rtl of addr_alu is
 
 constant ADDR_ADC    : std_logic_vector (1 downto 0) := "00";
 constant ADDR_INC    : std_logic_vector (1 downto 0) := "01";
index 6d25f14..80fef8f 100644 (file)
@@ -119,64 +119,6 @@ begin
                     port map(ext_oe_n, int_dbus, ext_dbus);
 end rtl;
 
-------------------------------------------
------ input data latch register
-------------------------------------------
-
-library ieee;
-use ieee.std_logic_1164.all;
-
-entity input_data_latch is 
-    generic (
-            dsize : integer := 8
-            );
-    port (  
-    signal dbg_idl_val     : out std_logic_vector (7 downto 0);
-    
-            clk         : in std_logic;
-            oe_n        : in std_logic;
-            we_n        : in std_logic;
-            int_dbus    : in std_logic_vector (dsize - 1 downto 0);
-            alu_bus     : out std_logic_vector (dsize - 1 downto 0)
-        );
-end input_data_latch;
-
-architecture rtl of input_data_latch is
-
-component d_flip_flop
-    generic (
-            dsize : integer := 8
-            );
-    port (  
-            clk     : in std_logic;
-            res_n   : in std_logic;
-            set_n   : in std_logic;
-            we_n    : in std_logic;
-            d       : in std_logic_vector (dsize - 1 downto 0);
-            q       : out std_logic_vector (dsize - 1 downto 0)
-        );
-end component;
-
-component tri_state_buffer
-    generic (
-            dsize : integer := 8
-            );
-    port (  
-            oe_n    : in std_logic;
-            d       : in std_logic_vector (dsize - 1 downto 0);
-            q       : out std_logic_vector (dsize - 1 downto 0)
-        );
-end component;
-
-signal latch_buf : std_logic_vector (dsize - 1 downto 0);
-
-begin
-    latch_inst : d_flip_flop generic map (dsize) 
-                    port map(clk, '1', '1', we_n, int_dbus, latch_buf);
-    iput_data_tsb : tri_state_buffer generic map (dsize) 
-                    port map(oe_n, latch_buf, alu_bus);
-
-end rtl;
 
 ----------------------------------------
 --- status register component
index eef4d94..f8f76bc 100644 (file)
@@ -7,9 +7,7 @@ use work.motonesfpga_common.all;
 entity decoder is 
     generic (dsize : integer := 8);
     port (  
---    signal dbg_ea_carry     : out std_logic;
-    
-    
+            --input lines.
             set_clk         : in std_logic;
             trig_clk        : in std_logic;
             res_n           : in std_logic;
@@ -19,27 +17,31 @@ entity decoder is
             instruction     : in std_logic_vector (dsize - 1 downto 0);
             exec_cycle      : in std_logic_vector (5 downto 0);
             next_cycle      : out std_logic_vector (5 downto 0);
+            ea_carry        : in  std_logic;
             status_reg      : inout std_logic_vector (dsize - 1 downto 0);
+
+            --general control.
             inst_we_n       : out std_logic;
             ad_oe_n         : out std_logic;
             dbuf_int_oe_n   : out std_logic;
-            dl_al_we_n      : out std_logic;
-            dl_ah_we_n      : out std_logic;
-            dl_al_oe_n      : out std_logic;
-            dl_ah_oe_n      : out std_logic;
-            dl_dh_oe_n      : out std_logic;
-            pcl_inc_n       : out std_logic;
+            r_nw            : out std_logic;
+
+            ----control line for dual port registers.
+            idl_l_cmd       : out std_logic_vector(3 downto 0);
+            idl_h_cmd       : out std_logic_vector(3 downto 0);
             pcl_cmd         : out std_logic_vector(3 downto 0);
             pch_cmd         : out std_logic_vector(3 downto 0);
             sp_cmd          : out std_logic_vector(3 downto 0);
+            x_cmd           : out std_logic_vector(3 downto 0);
+            y_cmd           : out std_logic_vector(3 downto 0);
+            acc_cmd         : out std_logic_vector(3 downto 0);
+            
+            --addr calc control
+            pcl_inc_n       : out std_logic;
             sp_oe_n         : out std_logic;
             sp_push_n       : out std_logic;
             sp_pop_n        : out std_logic;
-            acc_cmd         : out std_logic_vector(3 downto 0);
-            x_cmd           : out std_logic_vector(3 downto 0);
-            y_cmd           : out std_logic_vector(3 downto 0);
             abs_xy_n        : out std_logic;
-            ea_carry        : in  std_logic;
             pg_next_n       : out std_logic;
             zp_n            : out std_logic;
             zp_xy_n         : out std_logic;
@@ -47,7 +49,8 @@ entity decoder is
             indir_n         : out std_logic;
             indir_x_n       : out std_logic;
             indir_y_n       : out std_logic;
-            arith_en_n      : out std_logic;
+
+            ---status register
             stat_dec_oe_n   : out std_logic;
             stat_bus_oe_n   : out std_logic;
             stat_set_flg_n  : out std_logic;
@@ -55,10 +58,15 @@ entity decoder is
             stat_bus_all_n  : out std_logic;
             stat_bus_nz_n   : out std_logic;
             stat_alu_we_n   : out std_logic;
+            
+            --ALU control
+            arith_en_n      : out std_logic;
+            
+            --reset vectors.
             r_vec_oe_n      : out std_logic;
             n_vec_oe_n      : out std_logic;
-            i_vec_oe_n      : out std_logic;
-            r_nw            : out std_logic
+            i_vec_oe_n      : out std_logic
+
             ;---for parameter check purpose!!!
             check_bit     : out std_logic_vector(1 to 5)
         );
@@ -135,12 +143,6 @@ constant st_C : integer := 0;
 ---for nmi handling
 signal nmi_handled_n : std_logic;
 
--- page boundary handling
-signal wk_next_cycle      : std_logic_vector (5 downto 0);
-signal wk_acc_cmd         : std_logic_vector(3 downto 0);
-signal wk_x_cmd           : std_logic_vector(3 downto 0);
-signal wk_y_cmd           : std_logic_vector(3 downto 0);
-signal wk_stat_alu_we_n   : std_logic;
 signal ea_carry_reg       : std_logic;
 
 begin
@@ -148,26 +150,6 @@ begin
     ea_carry_inst: d_flip_flop_bit 
             port map(trig_clk, '1', '1', '0', ea_carry, ea_carry_reg);
 
-    --acc,x,y next cycle is changed when it goes page across.
-    --The conditional branch instructions all have the form xxy10000
-    next_cycle <= wk_next_cycle;
-    acc_cmd <= wk_acc_cmd(3) & '1' & wk_acc_cmd(1) & '1'
-                    when ea_carry = '1' and 
-                         wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
-               wk_acc_cmd;
-
-    x_cmd <= wk_x_cmd(3) & '1' & wk_x_cmd(1 downto 0)
-                when ea_carry = '1' and 
-                         wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
-             wk_x_cmd;
-    y_cmd <= wk_y_cmd(3) & '1' & wk_y_cmd(1 downto 0)
-                when ea_carry = '1' and 
-                         wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
-             wk_y_cmd;
-    stat_alu_we_n <= '1' when ea_carry = '1' and 
-                         wk_next_cycle = T0 and instruction(4 downto 0) = "10000" else
-                     wk_stat_alu_we_n;
-
     main_p : process (set_clk, res_n, nmi_n)
 
 -------------------------------------------------------------
@@ -239,18 +221,19 @@ begin
 
     --disable the last opration pins.
     dbuf_int_oe_n <= '1';
-    dl_al_we_n <= '1';
-    dl_ah_we_n <= '1';
-    dl_ah_oe_n <= '1';
-    dl_dh_oe_n <= '1';
+
+    idl_l_cmd <= "1111";
+    idl_h_cmd <= "1111";
+    pcl_cmd   <= "1111";
+    pch_cmd   <= "1111";
     sp_cmd <= "1111";
+    acc_cmd <= "1111";
+    x_cmd <= "1111";
+    y_cmd <= "1111";
+
     sp_oe_n <= '1';
     sp_push_n <= '1';
     sp_pop_n <= '1';
-    wk_acc_cmd <= "1111";
-    wk_x_cmd <= "1111";
-    wk_y_cmd <= "1111";
-
     abs_xy_n <= '1';
     pg_next_n <= '1';
     zp_n <= '1';
@@ -267,7 +250,7 @@ begin
     stat_flg <= '1';
     stat_bus_all_n <= '1';
     stat_bus_nz_n <= '1';
-    wk_stat_alu_we_n <= '1';
+    stat_alu_we_n <= '1';
 
     r_vec_oe_n <= '1';
     n_vec_oe_n <= '1';
@@ -282,12 +265,12 @@ begin
         --fetch opcode from where the latch is pointing to.
 
         --latch > al.
-        dl_al_oe_n <= '0';
+        idl_l_cmd <= "1110";
         pcl_cmd <= "1110";
     else
         --fetch opcode and pcl increment.
         pcl_cmd <= "1100";
-        dl_al_oe_n <= '1';
+        --dl_al_oe_n <= '1';
     end if;
 
     ad_oe_n <= '0';
@@ -308,10 +291,10 @@ begin
     if (nmi_n = '0' and nmi_handled_n = '1') then
         --start nmi handling...
         --fetch_inst('1');
-        wk_next_cycle <= N1;
+        next_cycle <= N1;
     else
         fetch_inst;
-        wk_next_cycle <= T1;
+        next_cycle <= T1;
     end if;
 end  procedure;
 
@@ -319,7 +302,7 @@ end  procedure;
 procedure single_inst is
 begin
     fetch_stop;
-    wk_next_cycle <= T0;
+    next_cycle <= T0;
 end  procedure;
 
 procedure fetch_imm is
@@ -329,7 +312,7 @@ begin
     --send data from data bus buffer.
     --receiver is instruction dependent.
     dbuf_int_oe_n <= '0';
-    wk_next_cycle <= T0;
+    next_cycle <= T0;
 end  procedure;
 
 procedure set_nz_from_bus is
@@ -341,7 +324,7 @@ end  procedure;
 procedure set_zc_from_alu is
 begin
     --status register n/z bit update.
-    wk_stat_alu_we_n <= '0';
+    stat_alu_we_n <= '0';
     stat_dec_oe_n <= '1';
     status_reg <= "00000011";
 end  procedure;
@@ -349,7 +332,7 @@ end  procedure;
 procedure set_nz_from_alu is
 begin
     --status register n/z/c bit update.
-    wk_stat_alu_we_n <= '0';
+    stat_alu_we_n <= '0';
     stat_dec_oe_n <= '1';
     status_reg <= "10000010";
 end  procedure;
@@ -357,7 +340,7 @@ end  procedure;
 procedure set_nzc_from_alu is
 begin
     --status register n/z/c bit update.
-    wk_stat_alu_we_n <= '0';
+    stat_alu_we_n <= '0';
     stat_dec_oe_n <= '1';
     status_reg <= "10000011";
 end  procedure;
@@ -365,14 +348,14 @@ end  procedure;
 procedure set_nvz_from_alu is
 begin
     --status register n/z/v bit update.
-    wk_stat_alu_we_n <= '0';
+    stat_alu_we_n <= '0';
     stat_dec_oe_n <= '1';
     status_reg <= "11000010";
 end  procedure;
 
 procedure set_nvzc_from_alu is
 begin
-    wk_stat_alu_we_n <= '0';
+    stat_alu_we_n <= '0';
     stat_dec_oe_n <= '1';
     status_reg <= "11000011";
 end  procedure;
@@ -407,43 +390,43 @@ begin
     fetch_next;
     --latch abs low data.
     dbuf_int_oe_n <= '0';
-    dl_al_we_n <= '0';
-    wk_next_cycle <= T2;
+    --dl_al_we_n <= '0';
+    next_cycle <= T2;
 end  procedure;
 
 procedure abs_fetch_high is
 begin
     d_print("abs (xy) 3");
-    dl_al_we_n <= '1';
+    --dl_al_we_n <= '1';
 
     --latch abs hi data.
     fetch_next;
     dbuf_int_oe_n <= '0';
-    dl_ah_we_n <= '0';
-    wk_next_cycle <= T3;
+    --dl_ah_we_n <= '0';
+    next_cycle <= T3;
 end  procedure;
 
 procedure abs_latch_out is
 begin
     --d_print("abs 4");
-    dl_ah_we_n <= '1';
+    --dl_ah_we_n <= '1';
     fetch_stop;
 
     --latch > al/ah.
-    dl_al_oe_n <= '0';
-    dl_ah_oe_n <= '0';
+    --dl_al_oe_n <= '0';
+    --dl_ah_oe_n <= '0';
 end  procedure;
 
 procedure ea_x_out is
 begin
     -----calucurate and output effective addr
-    back_oe(wk_x_cmd, '0');
+    back_oe(x_cmd, '0');
     abs_xy_n <= '0';
 end  procedure;
 
 procedure ea_y_out is
 begin
-    back_oe(wk_y_cmd, '0');
+    back_oe(y_cmd, '0');
     abs_xy_n <= '0';
 end  procedure;
 
@@ -456,12 +439,12 @@ begin
     elsif exec_cycle = T2 then
         fetch_stop;
         dbuf_int_oe_n <= '0';
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --calc zp.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -474,18 +457,18 @@ begin
     elsif exec_cycle = T3 then
         abs_latch_out;
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
 procedure a2_page_next is
 begin
     --close open gate if page boundary crossed.
-    back_we(wk_acc_cmd, '1');
-    front_we(wk_acc_cmd, '1');
-    front_we(wk_x_cmd, '1');
-    front_we(wk_y_cmd, '1');
-    wk_stat_alu_we_n <= '1';
+    back_we(acc_cmd, '1');
+    front_we(acc_cmd, '1');
+    front_we(x_cmd, '1');
+    front_we(y_cmd, '1');
+    stat_alu_we_n <= '1';
 end  procedure;
 
 procedure a2_abs_xy (is_x : in boolean) is
@@ -505,7 +488,7 @@ begin
         end if;
         dbuf_int_oe_n <= '0';
 
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
         d_print("absx step 1");
     elsif (exec_cycle = T0 and ea_carry_reg = '1') then
         --case page boundary crossed.
@@ -513,7 +496,7 @@ begin
         d_print("absx 5 (page boudary crossed.)");
         --next page.
         pg_next_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -525,21 +508,21 @@ begin
         fetch_stop;
         --output BAL only
         dbuf_int_oe_n <= '0';
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --calc zp.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
     elsif exec_cycle = T3 then
         --t3 zp, xy 
         zp_xy_n <= '0';
         if (is_x = true) then
-            back_oe(wk_x_cmd, '0');
+            back_oe(x_cmd, '0');
         else
-            back_oe(wk_y_cmd, '0');
+            back_oe(y_cmd, '0');
         end if;
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -548,40 +531,40 @@ begin
     if exec_cycle = T1 then
         fetch_low;
         --get IAL
-        dl_al_we_n <= '0';
+        --dl_al_we_n <= '0';
 
     elsif exec_cycle = T2 then
         fetch_stop;
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         ---address is 00:IAL
         --output BAL @IAL
         indir_y_n <= '0';
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
 
     elsif exec_cycle = T3 then
         indir_y_n <= '0';
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         --output BAH @IAL+1
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
 
     elsif exec_cycle = T4 then
-        dl_al_oe_n <= '1';
+        --dl_al_oe_n <= '1';
         dbuf_int_oe_n <= '1';
 
         --add index y.
         pg_next_n <= '1';
-        back_oe(wk_y_cmd, '0');
+        back_oe(y_cmd, '0');
         indir_y_n <= '0';
         dbuf_int_oe_n <= '0';
 
         if (ea_carry = '1') then
-            wk_next_cycle <= T5;
+            next_cycle <= T5;
         else
-            wk_next_cycle <= T0;
+            next_cycle <= T0;
         end if;
     elsif (exec_cycle = T5) then
         --case page boundary crossed.
@@ -589,7 +572,7 @@ begin
         d_print("(indir), y (page boudary crossed.)");
         --next page.
         pg_next_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -598,38 +581,38 @@ begin
     if exec_cycle = T1 then
         fetch_low;
         --get IAL
-        dl_al_we_n <= '0';
+        --dl_al_we_n <= '0';
 
     elsif exec_cycle = T2 then
         fetch_stop;
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         ---address is 00:IAL
         --output BAL @IAL, but cycle #2 is discarded
         indir_x_n <= '0';
-        dl_al_oe_n <= '0';
-        wk_next_cycle <= T3;
+        --dl_al_oe_n <= '0';
+        next_cycle <= T3;
 
     elsif exec_cycle = T3 then
         indir_x_n <= '0';
-        dl_al_oe_n <= '1';
+        --dl_al_oe_n <= '1';
 
         --output BAH @IAL+x
         dbuf_int_oe_n <= '0';
-        back_oe(wk_x_cmd, '0');
-        wk_next_cycle <= T4;
+        back_oe(x_cmd, '0');
+        next_cycle <= T4;
 
     elsif exec_cycle = T4 then
         indir_x_n <= '0';
 
         --output BAH @IAL+x+1
         dbuf_int_oe_n <= '0';
-        back_oe(wk_x_cmd, '0');
+        back_oe(x_cmd, '0');
 
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
     elsif (exec_cycle = T5) then
         indir_x_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -642,13 +625,13 @@ begin
     elsif exec_cycle = T2 then
         fetch_stop;
         dbuf_int_oe_n <= '1';
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --calc zp.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -659,26 +642,26 @@ begin
     elsif exec_cycle = T2 then
         fetch_stop;
         dbuf_int_oe_n <= '1';
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --calc zp.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
     elsif exec_cycle = T3 then
         --calc zp + index.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         zp_xy_n <= '0';
         if (is_x = true) then
-            back_oe(wk_x_cmd, '0');
+            back_oe(x_cmd, '0');
         else
-            back_oe(wk_y_cmd, '0');
+            back_oe(y_cmd, '0');
         end if;
 
         --write data
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -692,7 +675,7 @@ begin
         abs_latch_out;
         dbuf_int_oe_n <= '1';
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -712,7 +695,7 @@ begin
         else
             ea_y_out;
         end if;
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
     elsif exec_cycle = T4 then
         if (ea_carry_reg = '1') then
             pg_next_n <= '0';
@@ -726,7 +709,7 @@ begin
             ea_y_out;
         end if;
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -736,39 +719,39 @@ begin
     if exec_cycle = T1 then
         fetch_low;
         --get IAL
-        dl_al_we_n <= '0';
+        --dl_al_we_n <= '0';
 
     elsif exec_cycle = T2 then
         fetch_stop;
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         ---address is 00:IAL
         --output BAL @IAL
         indir_y_n <= '0';
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
 
     elsif exec_cycle = T3 then
         indir_y_n <= '0';
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         --output BAH @IAL+1
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
 
     elsif exec_cycle = T4 then
-        dl_al_oe_n <= '1';
+        --dl_al_oe_n <= '1';
         dbuf_int_oe_n <= '1';
 
         --add index y.
         pg_next_n <= '1';
-        back_oe(wk_y_cmd, '0');
+        back_oe(y_cmd, '0');
         indir_y_n <= '0';
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
 
     elsif exec_cycle = T5 then
         --page handling.
-        back_oe(wk_y_cmd, '1');
+        back_oe(y_cmd, '1');
         indir_y_n <= '0';
         
         --ea_carry reg is suspicious. timing is not garanteed...
@@ -778,7 +761,7 @@ begin
             pg_next_n <= '1';
         end if;
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -787,40 +770,40 @@ begin
     if exec_cycle = T1 then
         fetch_low;
         --get IAL
-        dl_al_we_n <= '0';
+        --dl_al_we_n <= '0';
 
     elsif exec_cycle = T2 then
         fetch_stop;
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         ---address is 00:IAL
         --output BAL @IAL, but cycle #2 is discarded
         indir_x_n <= '0';
-        dl_al_oe_n <= '0';
-        wk_next_cycle <= T3;
+        --dl_al_oe_n <= '0';
+        next_cycle <= T3;
 
     elsif exec_cycle = T3 then
         indir_x_n <= '0';
-        dl_al_oe_n <= '1';
+        --dl_al_oe_n <= '1';
 
         --output BAH @IAL+x
         dbuf_int_oe_n <= '0';
-        back_oe(wk_x_cmd, '0');
-        wk_next_cycle <= T4;
+        back_oe(x_cmd, '0');
+        next_cycle <= T4;
 
     elsif exec_cycle = T4 then
         indir_x_n <= '0';
 
         --output BAH @IAL+x+1
         dbuf_int_oe_n <= '0';
-        back_oe(wk_x_cmd, '0');
+        back_oe(x_cmd, '0');
 
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
     elsif (exec_cycle = T5) then
         indir_x_n <= '0';
         dbuf_int_oe_n <= '1';
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -832,29 +815,29 @@ begin
         fetch_low;
     elsif exec_cycle = T2 then
         fetch_stop;
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --t2 cycle read and,
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         --keep data in the alu reg.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
     elsif exec_cycle = T3 then
         --t3 fix alu internal register.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         arith_en_n <= '0';
         dbuf_int_oe_n <= '1';
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
     elsif exec_cycle = T4 then
         --t5 cycle writes modified value.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         r_nw <= '0';
         arith_en_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -865,45 +848,45 @@ begin
     elsif exec_cycle = T2 then
         fetch_stop;
         dbuf_int_oe_n <= '1';
-        dl_al_we_n <= '1';
+        --dl_al_we_n <= '1';
 
         --t2 cycle read bal only.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
     elsif exec_cycle = T3 then
         --t3 cycle read bal + x
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         zp_xy_n <= '0';
-        back_oe(wk_x_cmd, '0');
+        back_oe(x_cmd, '0');
 
         --keep data in the alu reg.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '0';
 
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
     elsif exec_cycle = T4 then
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         zp_xy_n <= '0';
-        back_oe(wk_x_cmd, '0');
+        back_oe(x_cmd, '0');
 
         --fix alu internal register.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '1';
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
     elsif exec_cycle = T5 then
         dbuf_int_oe_n <= '1';
 
         --t5 cycle writes modified value.
-        dl_al_oe_n <= '0';
+        --dl_al_oe_n <= '0';
         zp_n <= '0';
         zp_xy_n <= '0';
-        back_oe(wk_x_cmd, '0');
+        back_oe(x_cmd, '0');
         r_nw <= '0';
         arith_en_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -920,21 +903,21 @@ begin
         --keep data in the alu reg.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
     elsif exec_cycle = T4 then
         abs_latch_out;
 
         --fix alu internal register.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '1';
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
     elsif exec_cycle = T5 then
         dbuf_int_oe_n <= '1';
 
         --t5 cycle writes modified value.
         r_nw <= '0';
         arith_en_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -950,7 +933,7 @@ begin
         abs_latch_out;
         ea_x_out;
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T4;
+        next_cycle <= T4;
 
     elsif exec_cycle = T4 then
         abs_latch_out;
@@ -964,19 +947,19 @@ begin
         --keep data in the alu reg.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T5;
+        next_cycle <= T5;
 
     elsif exec_cycle = T5 then
         --fix alu internal register.
         arith_en_n <= '0';
         dbuf_int_oe_n <= '1';
-        wk_next_cycle <= T6;
+        next_cycle <= T6;
 
     elsif exec_cycle = T6 then
         --t5 cycle writes modified value.
         r_nw <= '0';
         arith_en_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
 
     end if;
 end  procedure;
@@ -987,14 +970,14 @@ procedure a51_push is
 begin
     if exec_cycle = T1 then
         fetch_stop;
-        wk_next_cycle <= T2;
+        next_cycle <= T2;
     elsif exec_cycle = T2 then
         back_oe(sp_cmd, '0');
         back_we(sp_cmd, '0');
         sp_push_n <= '0';
         sp_oe_n <= '0';
         r_nw <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end procedure;
 
@@ -1003,7 +986,7 @@ procedure a52_pull is
 begin
     if exec_cycle = T1 then
         fetch_stop;
-        wk_next_cycle <= T2;
+        next_cycle <= T2;
 
     elsif exec_cycle = T2 then
         --stack decrement first.
@@ -1011,7 +994,7 @@ begin
         back_we(sp_cmd, '0');
         sp_pop_n <= '0';
         sp_oe_n <= '0';
-        wk_next_cycle <= T3;
+        next_cycle <= T3;
 
     elsif exec_cycle = T3 then
         sp_pop_n <= '1';
@@ -1021,7 +1004,7 @@ begin
         back_oe(sp_cmd, '0');
         sp_oe_n <= '0';
         dbuf_int_oe_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end procedure;
 
@@ -1037,27 +1020,27 @@ begin
 
             --latch rel value.
             dbuf_int_oe_n <= '0';
-            dl_ah_we_n <= '0';
-            wk_next_cycle <= T2;
+            --dl_ah_we_n <= '0';
+            next_cycle <= T2;
         else
             d_print("no branch");
-            wk_next_cycle <= T0;
+            next_cycle <= T0;
         end if;
     elsif exec_cycle = T2 then
         d_print("rel ea");
         fetch_stop;
         dbuf_int_oe_n <= '1';
-        dl_ah_we_n <= '1';
+        --dl_ah_we_n <= '1';
 
         --calc relative addr.
         rel_calc_n <= '0';
         pg_next_n <= '1';
-        dl_dh_oe_n <= '0';
+        --dl_dh_oe_n <= '0';
         back_oe(pcl_cmd, '0');
         back_oe(pch_cmd, '0');
         back_we(pcl_cmd, '0');
 
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     elsif (exec_cycle = T0 and ea_carry = '1') then
         d_print("page crossed.");
         --page crossed. adh calc.
@@ -1065,11 +1048,11 @@ begin
         back_oe(pcl_cmd, '0');
         back_oe(pch_cmd, '0');
         back_we(pch_cmd, '0');
-        dl_dh_oe_n <= '0';
+        --dl_dh_oe_n <= '0';
 
         rel_calc_n <= '0';
         pg_next_n <= '0';
-        wk_next_cycle <= T0;
+        next_cycle <= T0;
     end if;
 end  procedure;
 
@@ -1088,12 +1071,12 @@ end  procedure;
             stat_flg <= '1';
             stat_bus_all_n <= '1';
             stat_bus_nz_n <= '1';
-            wk_stat_alu_we_n <= '1';
+            stat_alu_we_n <= '1';
 
             --pc l/h is reset vector.
             pcl_cmd <= "1110";
             pch_cmd <= "1110";
-            wk_next_cycle <= R0;
+            next_cycle <= R0;
 
         elsif (rising_edge(set_clk)) then
             d_print(string'("-"));
@@ -1108,7 +1091,7 @@ end  procedure;
                 disable_pins;
                 inst_we_n <= '1';
                 ad_oe_n <= '1';
-                dl_al_oe_n <= '1';
+                --dl_al_oe_n <= '1';
                 pcl_inc_n <= '1';
                 pcl_cmd <= "1111";
                 pch_cmd <= "1111";
@@ -1130,7 +1113,7 @@ end  procedure;
                     d_print("decode and execute inst: " 
                             & conv_hex8(conv_integer(instruction)));
                     --disable pin for jmp instruction 
-                    dl_al_oe_n <= '1';
+                    --dl_al_oe_n <= '1';
                     back_we(pcl_cmd, '1');
                     front_we(pch_cmd, '1');
 
@@ -1148,8 +1131,8 @@ end  procedure;
                     --asl acc mode.
                     d_print("asl");
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    front_we(acc_cmd, '0');
                     set_nzc_from_alu;
                     single_inst;
 
@@ -1176,8 +1159,8 @@ end  procedure;
                 elsif instruction = conv_std_logic_vector(16#ca#, dsize) then
                     d_print("dex");
                     arith_en_n <= '0';
-                    back_oe(wk_x_cmd, '0');
-                    front_we(wk_x_cmd, '0');
+                    back_oe(x_cmd, '0');
+                    front_we(x_cmd, '0');
                     --set nz bit.
                     set_nz_from_bus;
                     single_inst;
@@ -1185,8 +1168,8 @@ end  procedure;
                 elsif instruction = conv_std_logic_vector(16#88#, dsize) then
                     d_print("dey");
                     arith_en_n <= '0';
-                    back_oe(wk_y_cmd, '0');
-                    front_we(wk_y_cmd, '0');
+                    back_oe(y_cmd, '0');
+                    front_we(y_cmd, '0');
                     --set nz bit.
                     set_nz_from_bus;
                     single_inst;
@@ -1194,8 +1177,8 @@ end  procedure;
                 elsif instruction = conv_std_logic_vector(16#e8#, dsize) then
                     d_print("inx");
                     arith_en_n <= '0';
-                    back_oe(wk_x_cmd, '0');
-                    front_we(wk_x_cmd, '0');
+                    back_oe(x_cmd, '0');
+                    front_we(x_cmd, '0');
                     --set nz bit.
                     set_nz_from_bus;
                     single_inst;
@@ -1203,8 +1186,8 @@ end  procedure;
                 elsif instruction = conv_std_logic_vector(16#c8#, dsize) then
                     d_print("iny");
                     arith_en_n <= '0';
-                    back_oe(wk_y_cmd, '0');
-                    front_we(wk_y_cmd, '0');
+                    back_oe(y_cmd, '0');
+                    front_we(y_cmd, '0');
                     set_nz_from_bus;
                     single_inst;
 
@@ -1212,8 +1195,8 @@ end  procedure;
                     --lsr acc mode
                     d_print("lsr");
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    front_we(acc_cmd, '0');
                     set_zc_from_alu;
                     single_inst;
 
@@ -1225,8 +1208,8 @@ end  procedure;
                     --rol acc
                     d_print("rol");
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    front_we(acc_cmd, '0');
                     set_nzc_from_alu;
                     single_inst;
 
@@ -1234,8 +1217,8 @@ end  procedure;
                     --ror acc
                     d_print("ror");
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    front_we(acc_cmd, '0');
                     set_nzc_from_alu;
                     single_inst;
 
@@ -1258,43 +1241,43 @@ end  procedure;
                     d_print("tax");
                     set_nz_from_bus;
                     single_inst;
-                    front_oe(wk_acc_cmd, '0');
-                    front_we(wk_x_cmd, '0');
+                    front_oe(acc_cmd, '0');
+                    front_we(x_cmd, '0');
 
                 elsif instruction = conv_std_logic_vector(16#a8#, dsize) then
                     d_print("tay");
                     set_nz_from_bus;
                     single_inst;
-                    front_oe(wk_acc_cmd, '0');
-                    front_we(wk_y_cmd, '0');
+                    front_oe(acc_cmd, '0');
+                    front_we(y_cmd, '0');
 
                 elsif instruction = conv_std_logic_vector(16#ba#, dsize) then
                     d_print("tsx");
                     set_nz_from_bus;
                     single_inst;
                     front_oe(sp_cmd, '0');
-                    front_we(wk_x_cmd, '0');
+                    front_we(x_cmd, '0');
 
                 elsif instruction = conv_std_logic_vector(16#8a#, dsize) then
                     d_print("txa");
                     set_nz_from_bus;
                     single_inst;
-                    front_oe(wk_x_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    front_oe(x_cmd, '0');
+                    front_we(acc_cmd, '0');
 
                 elsif instruction = conv_std_logic_vector(16#9a#, dsize) then
                     d_print("txs");
                     set_nz_from_bus;
                     single_inst;
-                    front_oe(wk_x_cmd, '0');
+                    front_oe(x_cmd, '0');
                     front_we(sp_cmd, '0');
 
                 elsif instruction = conv_std_logic_vector(16#98#, dsize) then
                     d_print("tya");
                     set_nz_from_bus;
                     single_inst;
-                    front_oe(wk_y_cmd, '0');
-                    front_we(wk_acc_cmd, '0');
+                    front_oe(y_cmd, '0');
+                    front_we(acc_cmd, '0');
 
 
 
@@ -1306,8 +1289,8 @@ end  procedure;
                     d_print("adc");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    back_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    back_we(acc_cmd, '0');
                     set_nvzc_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#65#, dsize) then
@@ -1316,8 +1299,8 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1327,8 +1310,8 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1338,8 +1321,8 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1349,8 +1332,8 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1360,8 +1343,8 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1371,8 +1354,8 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1382,8 +1365,8 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1392,8 +1375,8 @@ end  procedure;
                     d_print("and");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    back_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    back_we(acc_cmd, '0');
                     set_nz_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#25#, dsize) then
@@ -1402,8 +1385,8 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1413,8 +1396,8 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1424,8 +1407,8 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1435,8 +1418,8 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1446,8 +1429,8 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1457,8 +1440,8 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1468,8 +1451,8 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1479,7 +1462,7 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nvz_from_alu;
                     end if;
 
@@ -1489,7 +1472,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nvz_from_alu;
                     end if;
 
@@ -1498,7 +1481,7 @@ end  procedure;
                     d_print("cmp");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
                     set_nzc_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#c5#, dsize) then
@@ -1507,7 +1490,7 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1517,7 +1500,7 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1527,7 +1510,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1537,7 +1520,7 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1547,7 +1530,7 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1557,7 +1540,7 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1567,7 +1550,7 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1576,7 +1559,7 @@ end  procedure;
                     d_print("cpx");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_x_cmd, '0');
+                    back_oe(x_cmd, '0');
                     set_nzc_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#e4#, dsize) then
@@ -1585,7 +1568,7 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_x_cmd, '0');
+                        back_oe(x_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1595,7 +1578,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_x_cmd, '0');
+                        back_oe(x_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1604,7 +1587,7 @@ end  procedure;
                     d_print("cpy");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_y_cmd, '0');
+                    back_oe(y_cmd, '0');
                     set_nzc_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#c4#, dsize) then
@@ -1613,7 +1596,7 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_y_cmd, '0');
+                        back_oe(y_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1623,7 +1606,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_y_cmd, '0');
+                        back_oe(y_cmd, '0');
                         set_nzc_from_alu;
                     end if;
 
@@ -1632,8 +1615,8 @@ end  procedure;
                     d_print("eor");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    back_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    back_we(acc_cmd, '0');
                     set_nz_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#45#, dsize) then
@@ -1642,8 +1625,8 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1653,8 +1636,8 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1664,8 +1647,8 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1675,8 +1658,8 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1686,8 +1669,8 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1697,8 +1680,8 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1708,8 +1691,8 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1717,7 +1700,7 @@ end  procedure;
                     --imm
                     d_print("lda");
                     fetch_imm;
-                    front_we(wk_acc_cmd, '0');
+                    front_we(acc_cmd, '0');
                     set_nz_from_bus;
 
                 elsif instruction  = conv_std_logic_vector(16#a5#, dsize) then
@@ -1725,7 +1708,7 @@ end  procedure;
                     d_print("lda");
                     a2_zp;
                     if exec_cycle = T2 then
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1734,7 +1717,7 @@ end  procedure;
                     d_print("lda");
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1744,7 +1727,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         set_nz_from_bus;
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#bd#, dsize) then
@@ -1753,7 +1736,7 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         --lda.
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1763,7 +1746,7 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         --lda.
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1772,7 +1755,7 @@ end  procedure;
                     d_print("lda");
                     a2_indir_x;
                     if exec_cycle = T5 then
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1782,7 +1765,7 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         --lda.
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1791,14 +1774,14 @@ end  procedure;
                     d_print("ldx");
                     fetch_imm;
                     set_nz_from_bus;
-                    front_we(wk_x_cmd, '0');
+                    front_we(x_cmd, '0');
 
                 elsif instruction  = conv_std_logic_vector(16#a6#, dsize) then
                     --zp
                     d_print("ldx");
                     a2_zp;
                     if exec_cycle = T2 then
-                        front_we(wk_x_cmd, '0');
+                        front_we(x_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1807,7 +1790,7 @@ end  procedure;
                     d_print("ldx");
                     a2_zp_xy(false);
                     if exec_cycle = T3 then
-                        front_we(wk_x_cmd, '0');
+                        front_we(x_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1817,7 +1800,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         set_nz_from_bus;
-                        front_we(wk_x_cmd, '0');
+                        front_we(x_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#be#, dsize) then
@@ -1825,7 +1808,7 @@ end  procedure;
                     d_print("ldx");
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
-                        front_we(wk_x_cmd, '0');
+                        front_we(x_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1834,14 +1817,14 @@ end  procedure;
                     d_print("ldy");
                     fetch_imm;
                     set_nz_from_bus;
-                    front_we(wk_y_cmd, '0');
+                    front_we(y_cmd, '0');
 
                 elsif instruction  = conv_std_logic_vector(16#a4#, dsize) then
                     --zp
                     d_print("ldy");
                     a2_zp;
                     if exec_cycle = T2 then
-                        front_we(wk_y_cmd, '0');
+                        front_we(y_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1850,7 +1833,7 @@ end  procedure;
                     d_print("ldy");
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
-                        front_we(wk_y_cmd, '0');
+                        front_we(y_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -1860,7 +1843,7 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         set_nz_from_bus;
-                        front_we(wk_y_cmd, '0');
+                        front_we(y_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#bc#, dsize) then
@@ -1869,7 +1852,7 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         set_nz_from_bus;
-                        front_we(wk_y_cmd, '0');
+                        front_we(y_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#09#, dsize) then
@@ -1877,8 +1860,8 @@ end  procedure;
                     d_print("ora");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    back_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    back_we(acc_cmd, '0');
                     set_nz_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#05#, dsize) then
@@ -1887,8 +1870,8 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1898,8 +1881,8 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1909,8 +1892,8 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1920,8 +1903,8 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1931,8 +1914,8 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1942,8 +1925,8 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1953,8 +1936,8 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nz_from_alu;
                     end if;
 
@@ -1963,8 +1946,8 @@ end  procedure;
                     d_print("sbc");
                     fetch_imm;
                     arith_en_n <= '0';
-                    back_oe(wk_acc_cmd, '0');
-                    back_we(wk_acc_cmd, '0');
+                    back_oe(acc_cmd, '0');
+                    back_we(acc_cmd, '0');
                     set_nvzc_from_alu;
 
                 elsif instruction  = conv_std_logic_vector(16#e5#, dsize) then
@@ -1973,8 +1956,8 @@ end  procedure;
                     a2_zp;
                     if exec_cycle = T2 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1984,8 +1967,8 @@ end  procedure;
                     a2_zp_xy(true);
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -1995,8 +1978,8 @@ end  procedure;
                     a2_abs;
                     if exec_cycle = T3 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -2006,8 +1989,8 @@ end  procedure;
                     a2_abs_xy(true);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -2017,8 +2000,8 @@ end  procedure;
                     a2_abs_xy(false);
                     if exec_cycle = T3 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -2028,8 +2011,8 @@ end  procedure;
                     a2_indir_x;
                     if exec_cycle = T5 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -2039,8 +2022,8 @@ end  procedure;
                     a2_indir_y;
                     if exec_cycle = T4 or exec_cycle = T0 then
                         arith_en_n <= '0';
-                        back_oe(wk_acc_cmd, '0');
-                        back_we(wk_acc_cmd, '0');
+                        back_oe(acc_cmd, '0');
+                        back_we(acc_cmd, '0');
                         set_nvzc_from_alu;
                     end if;
 
@@ -2054,7 +2037,7 @@ end  procedure;
                     d_print("sta");
                     a3_zp;
                     if exec_cycle = T2 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#95#, dsize) then
@@ -2062,7 +2045,7 @@ end  procedure;
                     d_print("sta");
                     a3_zp_xy(true);
                     if exec_cycle = T2 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#8d#, dsize) then
@@ -2070,7 +2053,7 @@ end  procedure;
                     d_print("sta");
                     a3_abs;
                     if exec_cycle = T3 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#9d#, dsize) then
@@ -2078,7 +2061,7 @@ end  procedure;
                     d_print("sta");
                     a3_abs_xy (true);
                     if exec_cycle = T4 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#99#, dsize) then
@@ -2086,7 +2069,7 @@ end  procedure;
                     d_print("sta");
                     a3_abs_xy (false);
                     if exec_cycle = T4 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#81#, dsize) then
@@ -2094,7 +2077,7 @@ end  procedure;
                     d_print("sta");
                     a3_indir_x;
                     if exec_cycle = T5 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#91#, dsize) then
@@ -2102,7 +2085,7 @@ end  procedure;
                     d_print("sta");
                     a3_indir_y;
                     if exec_cycle = T5 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#86#, dsize) then
@@ -2110,7 +2093,7 @@ end  procedure;
                     d_print("stx");
                     a3_zp;
                     if exec_cycle = T2 then
-                        front_oe(wk_x_cmd, '0');
+                        front_oe(x_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#96#, dsize) then
@@ -2118,7 +2101,7 @@ end  procedure;
                     d_print("stx");
                     a3_zp_xy(false);
                     if exec_cycle = T2 then
-                        front_oe(wk_x_cmd, '0');
+                        front_oe(x_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#8e#, dsize) then
@@ -2126,7 +2109,7 @@ end  procedure;
                     d_print("stx");
                     a3_abs;
                     if exec_cycle = T3 then
-                        front_oe(wk_x_cmd, '0');
+                        front_oe(x_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#84#, dsize) then
@@ -2134,7 +2117,7 @@ end  procedure;
                     d_print("sty");
                     a3_zp;
                     if exec_cycle = T2 then
-                        front_oe(wk_y_cmd, '0');
+                        front_oe(y_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#94#, dsize) then
@@ -2142,7 +2125,7 @@ end  procedure;
                     d_print("sty");
                     a3_zp_xy(true);
                     if exec_cycle = T2 then
-                        front_oe(wk_y_cmd, '0');
+                        front_oe(y_cmd, '0');
                     end if;
 
                 elsif instruction  = conv_std_logic_vector(16#8c#, dsize) then
@@ -2150,7 +2133,7 @@ end  procedure;
                     d_print("sty");
                     a3_abs;
                     if exec_cycle = T3 then
-                        front_oe(wk_y_cmd, '0');
+                        front_oe(y_cmd, '0');
                     end if;
 
 
@@ -2366,7 +2349,7 @@ end  procedure;
                     d_print("pha");
                     a51_push;
                     if exec_cycle = T2 then
-                        front_oe(wk_acc_cmd, '0');
+                        front_oe(acc_cmd, '0');
                     end if;
 
                 elsif instruction = conv_std_logic_vector(16#28#, dsize) then
@@ -2381,7 +2364,7 @@ end  procedure;
                     d_print("pla");
                     a52_pull;
                     if exec_cycle = T3 then
-                        front_we(wk_acc_cmd, '0');
+                        front_we(acc_cmd, '0');
                         set_nz_from_bus;
                     end if;
 
@@ -2396,13 +2379,13 @@ end  procedure;
                         fetch_next;
                         dbuf_int_oe_n <= '0';
                         --latch adl
-                        dl_al_we_n <= '0';
-                        wk_next_cycle <= T2;
+                        --dl_al_we_n <= '0';
+                        next_cycle <= T2;
                     elsif exec_cycle = T2 then
                         d_print("jsr 3");
                         fetch_stop;
                         dbuf_int_oe_n <= '1';
-                        dl_al_we_n <= '1';
+                        --dl_al_we_n <= '1';
 
                        --push return addr high into stack.
                         sp_push_n <= '0';
@@ -2411,7 +2394,7 @@ end  procedure;
                         back_oe(sp_cmd, '0');
                         back_we(sp_cmd, '0');
                         r_nw <= '0';
-                        wk_next_cycle <= T3;
+                        next_cycle <= T3;
                     elsif exec_cycle = T3 then
                         d_print("jsr 4");
                         front_oe(pch_cmd, '1');
@@ -2424,7 +2407,7 @@ end  procedure;
                         back_we(sp_cmd, '0');
                         r_nw <= '0';
 
-                        wk_next_cycle <= T4;
+                        next_cycle <= T4;
                     elsif exec_cycle = T4 then
                         d_print("jsr 5");
                         sp_push_n <= '1';
@@ -2438,27 +2421,27 @@ end  procedure;
                         back_oe(pch_cmd, '0');
                         back_oe(pcl_cmd, '0');
                         dbuf_int_oe_n <= '0';
-                        dl_ah_we_n <= '0';
+                        --dl_ah_we_n <= '0';
 
-                        wk_next_cycle <= T5;
+                        next_cycle <= T5;
                     elsif exec_cycle = T5 then
                         d_print("jsr 6");
 
                         back_oe(pch_cmd, '1');
                         back_oe(pcl_cmd, '1');
                         dbuf_int_oe_n <= '1';
-                        dl_ah_we_n <= '1';
+                        --dl_ah_we_n <= '1';
 
                         --load/output  pch
                         ad_oe_n <= '1';
-                        dl_dh_oe_n <= '0';
+                        --dl_dh_oe_n <= '0';
                         front_we(pch_cmd, '0');
 
                         --load pcl.
-                        dl_al_oe_n <= '0';
+                        --dl_al_oe_n <= '0';
                         back_we(pcl_cmd, '0');
 
-                        wk_next_cycle <= T0;
+                        next_cycle <= T0;
                     end if; --if exec_cycle = T1 then
 
                 -- A.5.4 break
@@ -2478,7 +2461,7 @@ end  procedure;
                         sp_pop_n <= '0';
                         sp_oe_n <= '0';
 
-                        wk_next_cycle <= T2;
+                        next_cycle <= T2;
                     elsif exec_cycle = T2 then
                         d_print("rti 3");
 
@@ -2493,7 +2476,7 @@ end  procedure;
                         dbuf_int_oe_n <= '0';
                         stat_bus_all_n <= '0';
 
-                        wk_next_cycle <= T3;
+                        next_cycle <= T3;
                     elsif exec_cycle = T3 then
                         d_print("rti 4");
                         stat_bus_all_n <= '1';
@@ -2508,7 +2491,7 @@ end  procedure;
                         dbuf_int_oe_n <= '0';
                         front_we(pcl_cmd, '0');
 
-                        wk_next_cycle <= T4;
+                        next_cycle <= T4;
                     elsif exec_cycle = T4 then
                         d_print("rti 5");
                         --stack decrement stop.
@@ -2523,7 +2506,7 @@ end  procedure;
                         dbuf_int_oe_n <= '0';
                         front_we(pch_cmd, '0');
 
-                        wk_next_cycle <= T5;
+                        next_cycle <= T5;
                     elsif exec_cycle = T5 then
                         d_print("rti 6");
                         back_oe(sp_cmd, '1');
@@ -2533,7 +2516,7 @@ end  procedure;
                         front_we(pch_cmd, '1');
 
                         --increment pc.
-                        wk_next_cycle <= T0;
+                        next_cycle <= T0;
                     end if; --if exec_cycle = T1 then
 
                 ----------------------------------------
@@ -2548,22 +2531,22 @@ end  procedure;
 
                         --latch abs low data.
                         dbuf_int_oe_n <= '0';
-                        dl_al_we_n <= '0';
-                        wk_next_cycle <= T2;
+                        --dl_al_we_n <= '0';
+                        next_cycle <= T2;
                     elsif exec_cycle = T2 then
                         d_print("jmp 3");
-                        dl_al_we_n <= '1';
+                        --dl_al_we_n <= '1';
 
                         --fetch abs hi
                         fetch_next;
 
                         --latch  in dlh
                         dbuf_int_oe_n <= '0';
-                        dl_ah_we_n <= '0';
+                        --dl_ah_we_n <= '0';
                         ---load pch.
                         front_we(pch_cmd, '0');
 
-                        wk_next_cycle <= T0;
+                        next_cycle <= T0;
                     end if;
 
                 elsif instruction = conv_std_logic_vector(16#6c#, dsize) then
@@ -2575,40 +2558,40 @@ end  procedure;
 
                         --latch abs low data.
                         dbuf_int_oe_n <= '0';
-                        dl_al_we_n <= '0';
-                        wk_next_cycle <= T2;
+                        --dl_al_we_n <= '0';
+                        next_cycle <= T2;
                     elsif exec_cycle = T2 then
                         d_print("jmp 3");
-                        dl_al_we_n <= '1';
+                        --dl_al_we_n <= '1';
 
                         --fetch abs hi
                         fetch_next;
 
                         --latch  in dlh
                         dbuf_int_oe_n <= '0';
-                        dl_ah_we_n <= '0';
-                        wk_next_cycle <= T3;
+                        --dl_ah_we_n <= '0';
+                        next_cycle <= T3;
 
                     elsif exec_cycle = T3 then
                         fetch_stop;
-                        dl_ah_we_n <= '1';
+                        --dl_ah_we_n <= '1';
 
                         --IAH/IAL > ADL
-                        dl_ah_oe_n <= '0';
-                        dl_al_oe_n <= '0';
+                        --dl_ah_oe_n <= '0';
+                        --dl_al_oe_n <= '0';
                         front_we(pcl_cmd, '0');
-                        wk_next_cycle <= T4;
+                        next_cycle <= T4;
 
                     elsif exec_cycle = T4 then
-                        dl_ah_oe_n <= '0';
-                        dl_al_oe_n <= '0';
+                        --dl_ah_oe_n <= '0';
+                        --dl_al_oe_n <= '0';
                         front_we(pcl_cmd, '1');
 
                         --IAH/IAL+1 > ADH
                         front_we(pch_cmd, '0');
                         indir_n <= '0';
 
-                        wk_next_cycle <= T0;
+                        next_cycle <= T0;
 
                     end if;
 
@@ -2627,7 +2610,7 @@ end  procedure;
                         sp_pop_n <= '0';
                         sp_oe_n <= '0';
 
-                        wk_next_cycle <= T2;
+                        next_cycle <= T2;
                     elsif exec_cycle = T2 then
                         d_print("rts 3");
 
@@ -2641,7 +2624,7 @@ end  procedure;
                         dbuf_int_oe_n <= '0';
                         front_we(pcl_cmd, '0');
 
-                        wk_next_cycle <= T3;
+                        next_cycle <= T3;
                     elsif exec_cycle = T3 then
                         d_print("rts 4");
                         --stack decrement stop.
@@ -2656,7 +2639,7 @@ end  procedure;
                         dbuf_int_oe_n <= '0';
                         front_we(pch_cmd, '0');
 
-                        wk_next_cycle <= T4;
+                        next_cycle <= T4;
                     elsif exec_cycle = T4 then
                         d_print("rts 5");
                         back_oe(sp_cmd, '1');
@@ -2666,13 +2649,13 @@ end  procedure;
                         front_we(pch_cmd, '1');
                         --empty cycle.
                         --complying h/w manual...
-                        wk_next_cycle <= T5;
+                        next_cycle <= T5;
                     elsif exec_cycle = T5 then
                         d_print("rts 6");
 
                         --increment pc.
                         fetch_next;
-                        wk_next_cycle <= T0;
+                        next_cycle <= T0;
                     end if; --if exec_cycle = T1 then
 
                 ----------------------------------------
@@ -2725,11 +2708,11 @@ end  procedure;
                 inst_we_n <= '1';
                 ad_oe_n <= '1';
                 dbuf_int_oe_n <= '1';
-                dl_al_we_n <= '1';
-                dl_ah_we_n <= '1';
-                dl_al_oe_n <= '1';
-                dl_ah_oe_n <= '1';
-                dl_dh_oe_n <= '1';
+                --dl_al_we_n <= '1';
+                --dl_ah_we_n <= '1';
+                --dl_al_oe_n <= '1';
+                --dl_ah_oe_n <= '1';
+                --dl_dh_oe_n <= '1';
                 pcl_inc_n <= '1';
                 pcl_cmd <= "1111";
                 pch_cmd <= "1111";
@@ -2737,9 +2720,9 @@ end  procedure;
                 sp_oe_n <= '1';
                 sp_push_n <= '1';
                 sp_pop_n <= '1';
-                wk_acc_cmd <= "1111";
-                wk_x_cmd <= "1111";
-                wk_y_cmd <= "1111";
+                acc_cmd <= "1111";
+                x_cmd <= "1111";
+                y_cmd <= "1111";
 
                 abs_xy_n <= '1';
                 pg_next_n <= '1';
@@ -2757,7 +2740,7 @@ end  procedure;
                 stat_flg <= '1';
                 stat_bus_all_n <= '1';
                 stat_bus_nz_n <= '1';
-                wk_stat_alu_we_n <= '1';
+                stat_alu_we_n <= '1';
 
                 r_vec_oe_n <= '1';
                 n_vec_oe_n <= '1';
@@ -2765,12 +2748,12 @@ end  procedure;
                 nmi_handled_n <= '1';
                 r_nw <= '1';
 
-                wk_next_cycle <= R1;
+                next_cycle <= R1;
             elsif exec_cycle = R1 or exec_cycle = N1 then
                 pcl_cmd <= "1111";
                 pcl_inc_n <= '1';
                 inst_we_n <= '1';
-                dl_al_oe_n <= '1';
+                --dl_al_oe_n <= '1';
 
                 --push pch.
                 d_print("R1");
@@ -2784,9 +2767,9 @@ end  procedure;
                 r_nw <= '0';
 
                 if exec_cycle = R1 then
-                    wk_next_cycle <= R2;
+                    next_cycle <= R2;
                 elsif exec_cycle = N1 then
-                    wk_next_cycle <= N2;
+                    next_cycle <= N2;
                 end if;
 
             elsif exec_cycle = R2 or exec_cycle = N2 then
@@ -2801,9 +2784,9 @@ end  procedure;
                 r_nw <= '0';
 
                 if exec_cycle = R2 then
-                    wk_next_cycle <= R3;
+                    next_cycle <= R3;
                 elsif exec_cycle = N2 then
-                    wk_next_cycle <= N3;
+                    next_cycle <= N3;
                 end if;
 
             elsif exec_cycle = R3 or exec_cycle = N3 then
@@ -2818,9 +2801,9 @@ end  procedure;
                 r_nw <= '0';
 
                 if exec_cycle = R3 then
-                    wk_next_cycle <= R4;
+                    next_cycle <= R4;
                 elsif exec_cycle = N3 then
-                    wk_next_cycle <= N4;
+                    next_cycle <= N4;
                 end if;
 
             elsif exec_cycle = R4 or exec_cycle = N4 then
@@ -2835,17 +2818,17 @@ end  procedure;
                 r_nw <= '1';
                 dbuf_int_oe_n <= '0';
                 front_we(pcl_cmd, '0');
-                dl_al_oe_n <= '1';
-                dl_ah_oe_n <= '1';
+                --dl_al_oe_n <= '1';
+                --dl_ah_oe_n <= '1';
 
                 if exec_cycle = R4 then
                     r_vec_oe_n <= '0';
                     n_vec_oe_n <= '1';
-                    wk_next_cycle <= R5;
+                    next_cycle <= R5;
                 elsif exec_cycle = N4 then
                     r_vec_oe_n <= '1';
                     n_vec_oe_n <= '0';
-                    wk_next_cycle <= N5;
+                    next_cycle <= N5;
                 end if;
                 
             elsif exec_cycle = R5 or exec_cycle = N5 then
@@ -2861,7 +2844,7 @@ end  procedure;
                     nmi_handled_n <= '0';
                 end if;
                 --start execute cycle.
-                wk_next_cycle <= T0;
+                next_cycle <= T0;
 
             end if; --if rdy = '0' then
 
index 100047e..0899c42 100644 (file)
@@ -39,9 +39,8 @@ architecture rtl of mos6502 is
     ----------------------------------------------
 component decoder
     generic (dsize : integer := 8);
-    port (  \r
-    --signal dbg_ea_carry     : out std_logic;\r
-\r
+    port (\r
+            --input lines.\r
             set_clk         : in std_logic;
             trig_clk        : in std_logic;
             res_n           : in std_logic;
@@ -51,27 +50,31 @@ component decoder
             instruction     : in std_logic_vector (dsize - 1 downto 0);
             exec_cycle      : in std_logic_vector (5 downto 0);
             next_cycle      : out std_logic_vector (5 downto 0);
+            ea_carry        : in  std_logic;\r
             status_reg      : inout std_logic_vector (dsize - 1 downto 0);
+\r
+            --general control.\r
             inst_we_n       : out std_logic;
             ad_oe_n         : out std_logic;
             dbuf_int_oe_n   : out std_logic;
-            dl_al_we_n      : out std_logic;
-            dl_ah_we_n      : out std_logic;
-            dl_al_oe_n      : out std_logic;
-            dl_ah_oe_n      : out std_logic;
-            dl_dh_oe_n      : out std_logic;
+            r_nw            : out std_logic;\r
+\r
+            ----control line for dual port registers.\r
+            idl_l_cmd       : out std_logic_vector(3 downto 0);\r
+            idl_h_cmd       : out std_logic_vector(3 downto 0);\r
+            pcl_cmd         : out std_logic_vector(3 downto 0);\r
+            pch_cmd         : out std_logic_vector(3 downto 0);\r
+            sp_cmd          : out std_logic_vector(3 downto 0);\r
+            x_cmd           : out std_logic_vector(3 downto 0);\r
+            y_cmd           : out std_logic_vector(3 downto 0);\r
+            acc_cmd         : out std_logic_vector(3 downto 0);\r
+            \r
+            --addr calc control\r
             pcl_inc_n       : out std_logic;
-            pcl_cmd         : out std_logic_vector(3 downto 0);
-            pch_cmd         : out std_logic_vector(3 downto 0);
-            sp_cmd          : out std_logic_vector(3 downto 0);
             sp_oe_n         : out std_logic;
             sp_push_n       : out std_logic;
             sp_pop_n        : out std_logic;
-            acc_cmd         : out std_logic_vector(3 downto 0);
-            x_cmd           : out std_logic_vector(3 downto 0);
-            y_cmd           : out std_logic_vector(3 downto 0);
             abs_xy_n        : out std_logic;
-            ea_carry        : in  std_logic;
             pg_next_n       : out std_logic;
             zp_n            : out std_logic;
             zp_xy_n         : out std_logic;
@@ -79,22 +82,66 @@ component decoder
             indir_n         : out std_logic;
             indir_x_n       : out std_logic;
             indir_y_n       : out std_logic;
-            arith_en_n      : out std_logic;
+\r
+            ---status register\r
             stat_dec_oe_n   : out std_logic;
             stat_bus_oe_n   : out std_logic;
             stat_set_flg_n  : out std_logic;
             stat_flg        : out std_logic;
             stat_bus_all_n  : out std_logic;
             stat_bus_nz_n   : out std_logic;
-            stat_alu_we_n   : out std_logic;
+            stat_alu_we_n   : out std_logic;\r
+            \r
+            --ALU control\r
+            arith_en_n      : out std_logic;\r
+            \r
+            --reset vectors.
             r_vec_oe_n      : out std_logic;
             n_vec_oe_n      : out std_logic;
-            i_vec_oe_n      : out std_logic;
-            r_nw            : out std_logic
+            i_vec_oe_n      : out std_logic\r
+\r
             ;---for parameter check purpose!!!
             check_bit     : out std_logic_vector(1 to 5)
         );
 end component;
+\r
+component address_calcurator\r
+    generic (   dsize : integer := 8\r
+            );\r
+    port (  \r
+            set_clk         : in std_logic;\r
+            trig_clk        : in std_logic;\r
+\r
+            --instruction reg\r
+            instruction     : in std_logic_vector (dsize - 1 downto 0);\r
+            exec_cycle      : in std_logic_vector (5 downto 0);\r
+\r
+            --control line.\r
+            pcl_inc_n       : in std_logic;\r
+            sp_oe_n         : in std_logic;\r
+            sp_push_n       : in std_logic;\r
+            sp_pop_n        : in std_logic;\r
+            abs_xy_n        : in std_logic;\r
+            pg_next_n       : in std_logic;\r
+            zp_n            : in std_logic;\r
+            zp_xy_n         : in std_logic;\r
+            rel_calc_n      : in std_logic;\r
+            indir_n         : in std_logic;\r
+            indir_x_n       : in std_logic;\r
+            indir_y_n       : in std_logic;\r
+\r
+            --in/out buses.\r
+            index_bus       : in std_logic_vector (dsize - 1 downto 0);\r
+            bal             : in std_logic_vector (dsize - 1 downto 0);\r
+            bah             : in std_logic_vector (dsize - 1 downto 0);\r
+            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);\r
+            addr_back_l     : out std_logic_vector (dsize - 1 downto 0);\r
+            addr_back_h     : out std_logic_vector (dsize - 1 downto 0);\r
+            abl             : out std_logic_vector (dsize - 1 downto 0);\r
+            abh             : out std_logic_vector (dsize - 1 downto 0);\r
+            ea_carry        : out std_logic\r
+    );\r
+end component;\r
 
 component alu
     generic (   dsize : integer := 8
@@ -102,31 +149,13 @@ component alu
     port (  \r
             set_clk         : in std_logic;\r
             trig_clk        : in std_logic;\r
-            pcl_inc_n       : in std_logic;
-            sp_oe_n         : in std_logic;
-            sp_push_n       : in std_logic;
-            sp_pop_n        : in std_logic;
-            abs_xy_n        : in std_logic;
-            pg_next_n       : in std_logic;
-            zp_n            : in std_logic;
-            zp_xy_n         : in std_logic;
-            rel_calc_n      : in std_logic;
-            indir_n         : in std_logic;
-            indir_x_n       : in std_logic;
-            indir_y_n       : in std_logic;
+            instruction     : in std_logic_vector (dsize - 1 downto 0);\r
+            exec_cycle      : in std_logic_vector (5 downto 0);\r
             arith_en_n      : in std_logic;
-            instruction     : in std_logic_vector (dsize - 1 downto 0);
-            exec_cycle      : in std_logic_vector (5 downto 0);
-            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);
+            int_d_bus       : inout std_logic_vector (dsize - 1 downto 0);\r
+            acc_in          : out std_logic_vector (dsize - 1 downto 0);\r
             acc_out         : in std_logic_vector (dsize - 1 downto 0);
-            index_bus       : in std_logic_vector (dsize - 1 downto 0);
-            bal             : in std_logic_vector (dsize - 1 downto 0);
-            bah             : in std_logic_vector (dsize - 1 downto 0);
-            addr_back       : out std_logic_vector (dsize - 1 downto 0);
-            acc_in          : out std_logic_vector (dsize - 1 downto 0);
-            abl             : out std_logic_vector (dsize - 1 downto 0);
-            abh             : out std_logic_vector (dsize - 1 downto 0);
-            ea_carry        : out std_logic;
+            index_bus       : in std_logic_vector (dsize - 1 downto 0);\r
             carry_in        : in std_logic;
             negative        : out std_logic;
             zero            : out std_logic;
@@ -181,22 +210,6 @@ component data_bus_buffer
         );
 end component;
 
-component input_data_latch
-    generic (
-            dsize : integer := 8
-            );
-    port (  \r
-    signal dbg_idl_val     : out std_logic_vector (7 downto 0);\r
-    \r
-    
-            clk         : in std_logic;
-            oe_n        : in std_logic;
-            we_n        : in std_logic;
-            int_dbus    : in std_logic_vector (dsize - 1 downto 0);
-            alu_bus     : out std_logic_vector (dsize - 1 downto 0)
-        );
-end component;
-
 component tri_state_buffer
     generic (
             dsize : integer := 8
@@ -241,8 +254,8 @@ end component;
     ----------------------------------------------
     ------------ signal declareration ------------
     ----------------------------------------------
-    signal set_clk : std_logic;
-    signal trigger_clk : std_logic;
+    signal set_clk  : std_logic;
+    signal trig_clk : std_logic;
 
     signal exec_cycle : std_logic_vector(5 downto 0);
     signal next_cycle : std_logic_vector(5 downto 0);
@@ -251,93 +264,90 @@ end component;
     -------------------------------
     -------- control lines --------
     -------------------------------
-    signal inst_we_n : std_logic;
-    signal inst_rst_n : std_logic;
-    signal ad_oe_n : std_logic;
-
-    signal dbuf_r_nw : std_logic;
-    signal dbuf_int_oe_n : std_logic;
-
-    signal dl_al_we_n : std_logic;
-    signal dl_ah_we_n : std_logic;
-    signal dl_al_oe_n : std_logic;
-    signal dl_ah_oe_n : std_logic;
-    signal dl_dh_oe_n : std_logic;
-
-    signal pcl_inc_n : std_logic;
-    signal abs_xy_n        : std_logic;
-    signal ea_carry        : std_logic;
-    signal pg_next_n       : std_logic;
-    signal zp_n            : std_logic;
-    signal zp_xy_n         : std_logic;
-    signal rel_calc_n      : std_logic;
-    signal indir_n         : std_logic;
-    signal indir_x_n       : std_logic;
-    signal indir_y_n       : std_logic;
-    signal arith_en_n      : std_logic;
-                    
-    signal alu_n : std_logic;
-    signal alu_z : std_logic;
-    signal alu_c : std_logic;
-    signal alu_v : std_logic;
-    signal stat_c : std_logic;
+    signal inst_we_n        : std_logic;
+    signal inst_rst_n       : std_logic;
+    signal ad_oe_n          : std_logic;
+
+    signal dbuf_r_nw        : std_logic;
+    signal dbuf_int_oe_n    : std_logic;
+
+    signal pcl_inc_n        : std_logic;
+    signal abs_xy_n         : std_logic;
+    signal ea_carry         : std_logic;
+    signal pg_next_n        : std_logic;
+    signal zp_n             : std_logic;
+    signal zp_xy_n          : std_logic;
+    signal rel_calc_n       : std_logic;
+    signal indir_n          : std_logic;
+    signal indir_x_n        : std_logic;
+    signal indir_y_n        : std_logic;
+    signal sp_oe_n          : std_logic;\r
+    signal sp_push_n        : std_logic;\r
+    signal sp_pop_n         : std_logic;\r
+\r
+    signal arith_en_n       : std_logic;                    
+    signal stat_c           : std_logic;
+\r
+    signal negative        : std_logic;\r
+    signal zero            : std_logic;\r
+    signal carry_out       : std_logic;\r
+    signal overflow        : std_logic;\r
 
     ----control line for dual port registers.
-    signal pcl_cmd : std_logic_vector(3 downto 0);
-    signal pch_cmd : std_logic_vector(3 downto 0);
-    signal sp_cmd : std_logic_vector(3 downto 0);
-    signal acc_cmd : std_logic_vector(3 downto 0);
-    signal x_cmd : std_logic_vector(3 downto 0);
-    signal y_cmd : std_logic_vector(3 downto 0);
-    signal sp_oe_n : std_logic;
-    signal sp_push_n : std_logic;
-    signal sp_pop_n  : std_logic;
+    signal idl_l_cmd        : std_logic_vector(3 downto 0);\r
+    signal idl_h_cmd        : std_logic_vector(3 downto 0);\r
+    signal pcl_cmd          : std_logic_vector(3 downto 0);
+    signal pch_cmd          : std_logic_vector(3 downto 0);
+    signal sp_cmd           : std_logic_vector(3 downto 0);
+    signal acc_cmd          : std_logic_vector(3 downto 0);
+    signal x_cmd            : std_logic_vector(3 downto 0);
+    signal y_cmd            : std_logic_vector(3 downto 0);
 
     ---status register
-    signal stat_dec_oe_n : std_logic;
-    signal stat_bus_oe_n : std_logic;
-    signal stat_set_flg_n : std_logic;
-    signal stat_flg : std_logic;
-    signal stat_bus_all_n : std_logic;
-    signal stat_bus_nz_n : std_logic;
-    signal stat_alu_we_n : std_logic;
+    signal stat_dec_oe_n    : std_logic;
+    signal stat_bus_oe_n    : std_logic;
+    signal stat_set_flg_n   : std_logic;
+    signal stat_flg         : std_logic;
+    signal stat_bus_all_n   : std_logic;
+    signal stat_bus_nz_n    : std_logic;
+    signal stat_alu_we_n    : std_logic;
 
     -------------------------------
     ------------ buses ------------
     -------------------------------
-    signal instruction : std_logic_vector(dsize - 1 downto 0);
+    signal instruction  : std_logic_vector(dsize - 1 downto 0);
     
-    signal bah : std_logic_vector(dsize - 1 downto 0);
-    signal bal : std_logic_vector(dsize - 1 downto 0);
-    signal index_bus : std_logic_vector(dsize - 1 downto 0);
-    signal idl_h_out : std_logic_vector(dsize - 1 downto 0);
+    signal bah          : std_logic_vector(dsize - 1 downto 0);
+    signal bal          : std_logic_vector(dsize - 1 downto 0);
+    signal index_bus    : std_logic_vector(dsize - 1 downto 0);
 
-    signal acc_out : std_logic_vector(dsize - 1 downto 0);
-    signal acc_in : std_logic_vector(dsize - 1 downto 0);
-    signal addr_back : std_logic_vector(dsize - 1 downto 0);
+    signal acc_out      : std_logic_vector(dsize - 1 downto 0);
+    signal acc_in       : std_logic_vector(dsize - 1 downto 0);
+    signal addr_back_l  : std_logic_vector(dsize - 1 downto 0);\r
+    signal addr_back_h  : std_logic_vector(dsize - 1 downto 0);\r
 
     --not used bus.
-    signal null_bus : std_logic_vector(dsize - 1 downto 0);
+    signal null_bus     : std_logic_vector(dsize - 1 downto 0);
 
     --address bus
-    signal abh : std_logic_vector(dsize - 1 downto 0);
-    signal abl : std_logic_vector(dsize - 1 downto 0);
+    signal abh          : std_logic_vector(dsize - 1 downto 0);
+    signal abl          : std_logic_vector(dsize - 1 downto 0);
 
     ---internal data bus
-    signal int_d_bus : std_logic_vector(dsize - 1 downto 0);
+    signal int_d_bus    : std_logic_vector(dsize - 1 downto 0);
 
     ---reset vectors---
-    signal r_vec_oe_n : std_logic;
-    signal n_vec_oe_n : std_logic;
-    signal i_vec_oe_n : std_logic;
-    signal reset_l : std_logic_vector(dsize - 1 downto 0);
-    signal reset_h : std_logic_vector(dsize - 1 downto 0);
-    signal nmi_l : std_logic_vector(dsize - 1 downto 0);
-    signal nmi_h : std_logic_vector(dsize - 1 downto 0);
-    signal irq_l : std_logic_vector(dsize - 1 downto 0);
-    signal irq_h : std_logic_vector(dsize - 1 downto 0);
-
-    signal check_bit     : std_logic_vector(1 to 5);
+    signal r_vec_oe_n   : std_logic;
+    signal n_vec_oe_n   : std_logic;
+    signal i_vec_oe_n   : std_logic;
+    signal reset_l      : std_logic_vector(dsize - 1 downto 0);
+    signal reset_h      : std_logic_vector(dsize - 1 downto 0);
+    signal nmi_l        : std_logic_vector(dsize - 1 downto 0);
+    signal nmi_h        : std_logic_vector(dsize - 1 downto 0);
+    signal irq_l        : std_logic_vector(dsize - 1 downto 0);
+    signal irq_h        : std_logic_vector(dsize - 1 downto 0);
+
+    signal check_bit    : std_logic_vector(1 to 5);
 \r
 begin
 \r
@@ -355,7 +365,7 @@ begin
     phi1 <= input_clk;
     phi2 <= not input_clk;
     set_clk <= input_clk;
-    trigger_clk <= not input_clk;
+    trig_clk <= not input_clk;
 
     r_nw <= dbuf_r_nw;
     reset_l <= "11111100";
@@ -376,125 +386,153 @@ begin
 
     dec_inst : decoder generic map (dsize) 
             port map(\r
-    --dbg_ea_carry     ,\r
-            \r
-                    set_clk, 
-                    trigger_clk, 
-                    rst_n, 
-                    irq_n, 
-                    nmi_n, 
-                    rdy, 
-                    instruction, 
-                    exec_cycle,
-                    next_cycle,
-                    status_reg, 
-                    inst_we_n, 
-                    ad_oe_n, 
-                    dbuf_int_oe_n,
-                    dl_al_we_n,
-                    dl_ah_we_n,
-                    dl_al_oe_n,
-                    dl_ah_oe_n,
-                    dl_dh_oe_n,
-                    pcl_inc_n,
-                    pcl_cmd,
-                    pch_cmd,
-                    sp_cmd,
-                    sp_oe_n,
-                    sp_push_n,
-                    sp_pop_n,
-                    acc_cmd,
-                    x_cmd,
-                    y_cmd,
-                    abs_xy_n,
-                    ea_carry,
-                    pg_next_n,
-                    zp_n,
-                    zp_xy_n,
-                    rel_calc_n,
-                    indir_n,
-                    indir_x_n,
-                    indir_y_n,
-                    arith_en_n,
-                    stat_dec_oe_n, 
-                    stat_bus_oe_n, 
-                    stat_set_flg_n, 
-                    stat_flg, 
-                    stat_bus_all_n, 
-                    stat_bus_nz_n, 
-                    stat_alu_we_n, 
-                    r_vec_oe_n,
-                    n_vec_oe_n,
-                    i_vec_oe_n,
-                    dbuf_r_nw
+                    --input lines.\r
+                    set_clk         ,\r
+                    trig_clk        ,\r
+                    rst_n           ,\r
+                    irq_n           ,\r
+                    nmi_n           ,\r
+                    rdy             ,\r
+                    instruction     ,\r
+                    exec_cycle      ,\r
+                    next_cycle      ,\r
+                    ea_carry        ,\r
+                    status_reg      ,\r
+\r
+                    inst_we_n       ,\r
+                    ad_oe_n         ,\r
+                    dbuf_int_oe_n   ,\r
+                    dbuf_r_nw       ,\r
+\r
+                    idl_l_cmd       ,\r
+                    idl_h_cmd       ,\r
+                    pcl_cmd         ,\r
+                    pch_cmd         ,\r
+                    sp_cmd          ,\r
+                    x_cmd           ,\r
+                    y_cmd           ,\r
+                    acc_cmd         ,\r
+\r
+                    pcl_inc_n       ,\r
+                    sp_oe_n         ,\r
+                    sp_push_n       ,\r
+                    sp_pop_n        ,\r
+                    abs_xy_n        ,\r
+                    pg_next_n       ,\r
+                    zp_n            ,\r
+                    zp_xy_n         ,\r
+                    rel_calc_n      ,\r
+                    indir_n         ,\r
+                    indir_x_n       ,\r
+                    indir_y_n       ,\r
+\r
+                    stat_dec_oe_n   ,\r
+                    stat_bus_oe_n   ,\r
+                    stat_set_flg_n  ,\r
+                    stat_flg        ,\r
+                    stat_bus_all_n  ,\r
+                    stat_bus_nz_n   ,\r
+                    stat_alu_we_n   ,\r
+\r
+                    arith_en_n      ,\r
+\r
+                    r_vec_oe_n      ,\r
+                    n_vec_oe_n      ,\r
+                    i_vec_oe_n\r
+\r
                     , check_bit --check bit.
                     );
-
+\r
+    ad_calc_inst : address_calcurator generic map (dsize) \r
+            port map (\r
+            set_clk         ,\r
+            trig_clk        ,\r
+\r
+            instruction     ,\r
+            exec_cycle      ,\r
+\r
+            pcl_inc_n       ,\r
+            sp_oe_n         ,\r
+            sp_push_n       ,\r
+            sp_pop_n        ,\r
+            abs_xy_n        ,\r
+            pg_next_n       ,\r
+            zp_n            ,\r
+            zp_xy_n         ,\r
+            rel_calc_n      ,\r
+            indir_n         ,\r
+            indir_x_n       ,\r
+            indir_y_n       ,\r
+\r
+            index_bus       ,\r
+            bal             ,\r
+            bah             ,\r
+            int_d_bus       ,\r
+            addr_back_l     ,\r
+            addr_back_h     ,\r
+            abl             ,\r
+            abh             ,\r
+            ea_carry\r
+            );\r
+                    
     alu_inst : alu generic map (dsize) 
             port map (\r
-                    set_clk, \r
-                    trigger_clk, \r
-                    pcl_inc_n,
-                    sp_oe_n,
-                    sp_push_n,
-                    sp_pop_n,
-                    abs_xy_n,
-                    pg_next_n,
-                    zp_n,
-                    zp_xy_n,
-                    rel_calc_n,
-                    indir_n,
-                    indir_x_n,
-                    indir_y_n,\r
-                    arith_en_n,
-                    instruction,
-                    exec_cycle,
-                    int_d_bus,
-                    acc_out,
-                    index_bus,
-                    bal,
-                    bah,
-                    addr_back,
-                    acc_in,
-                    abl,
-                    abh,
-                    ea_carry,
-                    stat_c,
-                    alu_n,
-                    alu_z,
-                    alu_c,
-                    alu_v 
+            set_clk         ,\r
+            trig_clk        ,\r
+            instruction     ,\r
+            exec_cycle      ,\r
+            arith_en_n      ,\r
+            int_d_bus       ,\r
+            acc_in          ,\r
+            acc_out         ,\r
+            index_bus       ,\r
+            stat_c          ,\r
+            negative        ,\r
+            zero            ,\r
+            carry_out       ,\r
+            overflow
                     );
 
     --cpu execution cycle number
     exec_cycle_inst : d_flip_flop generic map (5) 
-            port map(trigger_clk, '1', '1', '0', 
+            port map(trig_clk, '1', '1', '0', 
                     next_cycle(4 downto 0), exec_cycle(4 downto 0));
 
-    --io data buffer
+    --io data gateway
     dbus_buf : data_bus_buffer generic map (dsize) 
             port map(dbuf_int_oe_n, dbuf_r_nw, int_d_bus, d_io);
+\r
+    -------- instruction register --------\r
+    ir : d_flip_flop generic map (dsize) \r
+            port map(trig_clk, inst_rst_n, '1', inst_we_n, d_io, instruction);\r
 
-    --address operand data buffer.
-    idl_l : input_data_latch generic map (dsize) 
-            port map(dbg_idl_l, trigger_clk, dl_al_oe_n, dl_al_we_n, int_d_bus, bal);
-    idl_h : input_data_latch generic map (dsize) 
-            port map(dbg_idl_h, trigger_clk, '0', dl_ah_we_n, int_d_bus, idl_h_out);
-    ---only DLH has b-bus side output.
-    idl_h_a_buf : tri_state_buffer generic map (dsize)
-            port map (dl_ah_oe_n, idl_h_out, bah);
-    idl_h_d_buf : tri_state_buffer generic map (dsize)
-            port map (dl_dh_oe_n, idl_h_out, int_d_bus);
-
-    -------- registers --------
-    ir : d_flip_flop generic map (dsize) 
-            port map(trigger_clk, inst_rst_n, '1', inst_we_n, d_io, instruction);
+    --input data buffer.
+    idl_l : dual_dff generic map (dsize) 
+            port map(dbg_idl_l, trig_clk, rst_n, '1', idl_l_cmd, int_d_bus, null_bus, bal);
+    idl_h : dual_dff generic map (dsize) 
+            port map(dbg_idl_h, trig_clk, rst_n, '1', idl_h_cmd, int_d_bus, null_bus, bah);
 
+    -------- program counter --------\r
     pcl_inst : dual_dff generic map (dsize) 
-            port map(dbg_pcl, set_clk, rst_n, '1', pcl_cmd, int_d_bus, addr_back, bal);
+            port map(dbg_pcl, set_clk, rst_n, '1', pcl_cmd, int_d_bus, addr_back_l, bal);
     pch_inst : dual_dff generic map (dsize) 
-            port map(dbg_pch, set_clk, rst_n, '1', pch_cmd, int_d_bus, addr_back, bah);
+            port map(dbg_pch, set_clk, rst_n, '1', pch_cmd, int_d_bus, addr_back_h, bah);
 
+\r
+    --addressing register\r
+    sp : dual_dff generic map (dsize) \r
+            port map(dbg_sp, set_clk, rst_n, '1', sp_cmd, int_d_bus, addr_back_l, bal);\r
+\r
+    x : dual_dff generic map (dsize) \r
+            port map(dbg_x, trig_clk, rst_n, '1', x_cmd, int_d_bus, null_bus, index_bus);\r
+    y : dual_dff generic map (dsize) \r
+            port map(dbg_y, trig_clk, rst_n, '1', y_cmd, int_d_bus, null_bus, index_bus);\r
+\r
+    --accumurator\r
+    acc : dual_dff generic map (dsize) \r
+            port map(dbg_acc, trig_clk, rst_n, '1', acc_cmd, int_d_bus, acc_in, acc_out);\r
+\r
+\r
     --status register
     status_register : processor_status generic map (dsize) 
             port map (\r
@@ -503,24 +541,12 @@ begin
     dbg_int_dbus,\r
 --    dbg_status_val,\r
     dbg_stat_we_n    ,\r
-                    trigger_clk, rst_n, 
+                    trig_clk, rst_n, 
                     stat_dec_oe_n, stat_bus_oe_n, 
                     stat_set_flg_n, stat_flg, stat_bus_all_n, stat_bus_nz_n, 
-                    stat_alu_we_n, alu_n, alu_v, alu_z, alu_c, stat_c,
+                    stat_alu_we_n, negative, overflow, zero, carry_out, stat_c,
                     status_reg, int_d_bus);
 
-
-    sp : dual_dff generic map (dsize) 
-            port map(dbg_sp, set_clk, rst_n, '1', sp_cmd, int_d_bus, addr_back, bal);
-
-    x : dual_dff generic map (dsize) 
-            port map(dbg_x, trigger_clk, rst_n, '1', x_cmd, int_d_bus, null_bus, index_bus);
-    y : dual_dff generic map (dsize) 
-            port map(dbg_y, trigger_clk, rst_n, '1', y_cmd, int_d_bus, null_bus, index_bus);
-
-    acc : dual_dff generic map (dsize) 
-            port map(dbg_acc, trigger_clk, rst_n, '1', acc_cmd, int_d_bus, acc_in, acc_out);
-
     --adh output is controlled by decoder.
     adh_buf : tri_state_buffer generic map (dsize)
             port map (ad_oe_n, abh, addr(asize - 1 downto dsize));
@@ -543,14 +569,6 @@ begin
     irq_h_buf : tri_state_buffer generic map (dsize)
             port map (i_vec_oe_n, irq_h, bah);\r
 \r
-    reset_p : process (rst_n)
-    begin
-        if (rst_n = '0') then
-
-        end if;
-    end process;
-
-
 ------------------------------------------------------------
 ------------------------ for debug... ----------------------
 ------------------------------------------------------------
index 9d032c7..e335b57 100644 (file)
Binary files a/doc/mos6502-bus.xlsx and b/doc/mos6502-bus.xlsx differ