OSDN Git Service

reset recovery bug fix. still more refactoring needed....
authorastoria-d@fc <astoria-d@fc>
Fri, 22 Jul 2016 11:41:20 +0000 (20:41 +0900)
committerastoria-d@fc <astoria-d@fc>
Fri, 22 Jul 2016 11:41:20 +0000 (20:41 +0900)
de1_nes/cpu/alu.vhd
de1_nes/cpu/decoder.vhd
de1_nes/cpu/mos6502.vhd
doc/mos6502-bus.xlsx

index 823ce1b..bb03b5d 100644 (file)
@@ -25,6 +25,7 @@ entity alu is
             indir_n         : in std_logic;
             indir_x_n       : in std_logic;
             indir_y_n       : in std_logic;
+            ba_out_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);
@@ -219,7 +220,7 @@ begin
                     pcl_inc_n, sp_oe_n, sp_pop_n, sp_push_n,
                     zp_n, zp_xy_n, abs_xy_n, pg_next_n, rel_calc_n,
                     int_d_bus(7), indir_n, indir_x_n, exec_cycle,
-                    indir_y_n
+                    indir_y_n, ba_out_n
                     )
     begin
     
@@ -244,21 +245,13 @@ begin
             a_sel <= ADDR_INC;
             addr1 <= bal;
             addr_back <= addr_out;
-
-            al_buf_we_n <= '0';
-            al_reg_in <= bal;
-            if (set_clk = '0') then
-                abl <= bal;
-            else
-                abl <= al_reg;
-            end if;
+            abl <= bal;
         else
             ---case push
             a_sel <= ADDR_DEC;
             addr1 <= bal;
             addr_back <= addr_out;
             abl <= bal;
-
         end if;
     elsif (zp_n = '0') then
         ea_carry <= '0';
@@ -471,18 +464,18 @@ begin
             tmp_buf_we_n <= '1';
             ea_carry <= '0';
         end if; -- if (exec_cycle = T2) then
+    elsif (ba_out_n = '0') then
+        abh <= bah;
+        abl <= bal;
     else
         al_buf_we_n <= '1';
         ah_buf_we_n <= '1';
         tmp_buf_we_n <= '1';
         ea_carry <= '0';
 
-        abl <= bal;
-        abh <= bah;
-
-        ----addr_back is always bal for jmp/jsr instruction....
-        -----TODO must check later if it's ok.
-        addr_back <= bal;
+        abl <= (others => 'Z');
+        abh <= (others => 'Z');
+        addr_back <= (others => 'Z');
     end if; --if (pcl_inc_n = '0') then
 
     end process;
index defe7b4..7d57f47 100644 (file)
@@ -47,6 +47,7 @@ entity decoder is
             indir_n         : out std_logic;
             indir_x_n       : out std_logic;
             indir_y_n       : out std_logic;
+            ba_out_n        : out std_logic;
             arith_en_n      : out std_logic;
             stat_dec_oe_n   : out std_logic;
             stat_bus_oe_n   : out std_logic;
@@ -277,7 +278,7 @@ begin
 
 end  procedure;
 
-procedure fetch_inst (inc_pcl : in std_logic) is
+procedure fetch_inst (wk_inc_pcl_n : in std_logic) is
 begin
     if instruction = conv_std_logic_vector(16#4c#, dsize) then
         --if prior cycle is jump instruction, 
@@ -295,7 +296,8 @@ begin
     ad_oe_n <= '0';
     pch_cmd <= "1101";
     inst_we_n <= '0';
-    pcl_inc_n <= inc_pcl;
+    pcl_inc_n <= wk_inc_pcl_n;
+    ba_out_n <= not wk_inc_pcl_n;
     r_nw <= '1';
 
     d_print(string'("fetch 1"));
@@ -304,7 +306,7 @@ end  procedure;
 ---T0 cycle routine 
 ---(along with the page boundary condition, the last 
 ---cycle is bypassed and slided to T0.)
-procedure t0_cycle(inc_pcl : in std_logic) is
+procedure t0_cycle(wk_inc_pcl_n : in std_logic) is
 begin
     disable_pins;
     if (nmi_n = '0' and nmi_handled_n = '1') then
@@ -312,7 +314,7 @@ begin
         fetch_inst('1');
         wk_next_cycle <= N1;
     else
-        fetch_inst(inc_pcl);
+        fetch_inst(wk_inc_pcl_n);
         wk_next_cycle <= T1;
     end if;
 end  procedure;
@@ -1115,6 +1117,7 @@ end  procedure;
                 pcl_cmd <= "1111";
                 pch_cmd <= "1111";
                 r_nw <= 'Z';
+                ba_out_n <= '1';
 
             elsif (exec_cycle = T0r) then
                 --cycle #1
@@ -2755,6 +2758,7 @@ end  procedure;
                 indir_n <= '1';
                 indir_x_n <= '1';
                 indir_y_n <= '1';
+                ba_out_n <= '1';
                 arith_en_n <= '1';
 
                 stat_dec_oe_n <= '0';
@@ -2853,6 +2857,7 @@ end  procedure;
                     n_vec_oe_n <= '0';
                     wk_next_cycle <= N5;
                 end if;
+                ba_out_n <= '0';
                 
             elsif exec_cycle = R5 or exec_cycle = N5 then
                 front_we(pcl_cmd, '1');
index af5ebae..8c27a7c 100644 (file)
@@ -79,6 +79,7 @@ component decoder
             indir_n         : out std_logic;
             indir_x_n       : out std_logic;
             indir_y_n       : out std_logic;
+            ba_out_n        : out std_logic;\r
             arith_en_n      : out std_logic;
             stat_dec_oe_n   : out std_logic;
             stat_bus_oe_n   : out std_logic;
@@ -114,6 +115,7 @@ component alu
             indir_n         : in std_logic;
             indir_x_n       : in std_logic;
             indir_y_n       : in std_logic;
+            ba_out_n        : in std_logic;\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);
@@ -274,6 +276,7 @@ end component;
     signal indir_n         : std_logic;
     signal indir_x_n       : std_logic;
     signal indir_y_n       : std_logic;
+    signal ba_out_n        : std_logic;\r
     signal arith_en_n      : std_logic;
                     
     signal alu_n : std_logic;
@@ -415,6 +418,7 @@ begin
                     indir_n,
                     indir_x_n,
                     indir_y_n,
+                    ba_out_n,\r
                     arith_en_n,
                     stat_dec_oe_n, 
                     stat_bus_oe_n, 
@@ -445,7 +449,8 @@ begin
                     rel_calc_n,
                     indir_n,
                     indir_x_n,
-                    indir_y_n,
+                    indir_y_n,\r
+                    ba_out_n,
                     arith_en_n,
                     instruction,
                     exec_cycle,
@@ -541,8 +546,8 @@ begin
     irq_l_buf : tri_state_buffer generic map (dsize)
             port map (i_vec_oe_n, irq_l, bal);
     irq_h_buf : tri_state_buffer generic map (dsize)
-            port map (i_vec_oe_n, irq_h, bah);
-
+            port map (i_vec_oe_n, irq_h, bah);\r
+\r
     reset_p : process (rst_n)
     begin
         if (rst_n = '0') then
index 4d238c5..659af33 100644 (file)
Binary files a/doc/mos6502-bus.xlsx and b/doc/mos6502-bus.xlsx differ