OSDN Git Service

add dummy dma driver code
authorastoria-d@office <astoria-d@office>
Wed, 13 Apr 2016 10:52:00 +0000 (19:52 +0900)
committerastoria-d@office <astoria-d@office>
Wed, 13 Apr 2016 10:52:00 +0000 (19:52 +0900)
de1_nes/dummy-mos6502.vhd

index cd04f65..8a9357f 100644 (file)
@@ -48,11 +48,13 @@ begin
     use ieee.std_logic_arith.conv_std_logic_vector;\r
 \r
     variable init_step_cnt, plt_step_cnt, \r
-            nt_step_cnt, spr_step_cnt, enable_ppu_step_cnt : integer;\r
+            nt_step_cnt, spr_step_cnt, dma_step_cnt, enable_ppu_step_cnt : integer;\r
     variable init_done : std_logic;\r
     variable global_step_cnt : integer;\r
     variable cpu_cnt : integer;\r
     constant cpu_io_multi : integer := 3; --io happens every 4 cpu cycle.\r
+    variable i, j : integer;\r
+    variable ch : integer := 16#41# ;\r
 \r
 procedure io_out (ad: in integer; dt : in integer) is\r
 begin\r
@@ -349,7 +351,7 @@ end;
 \r
                     else\r
                         io_brk;\r
-                        if (nt_step_cnt > 53 * cpu_io_multi) then\r
+                        if (nt_step_cnt > 4 * cpu_io_multi) then\r
                             global_step_cnt := global_step_cnt + 1;\r
                         end if;\r
                     end if;\r
@@ -415,13 +417,53 @@ end;
 \r
                     else\r
                         io_brk;\r
-                        if (spr_step_cnt > 17 * cpu_io_multi) then\r
+                        if (spr_step_cnt > 4 * cpu_io_multi) then\r
                             global_step_cnt := global_step_cnt + 1;\r
                         end if;\r
                     end if;\r
                     spr_step_cnt := spr_step_cnt + 1;\r
 \r
                 elsif (global_step_cnt = 4) then\r
+                    --step3 = dma set.\r
+                    for i in 0 to 64 loop\r
+                        j := i * 4;\r
+                        if (ch = 16#5b#) then\r
+                            ch := 16#41#;\r
+                        else\r
+                            ch := 16#41# + i;\r
+                        end if;\r
+\r
+                        if (i < 64) then\r
+                            if    (dma_step_cnt = (0 + j) * cpu_io_multi) then\r
+                                io_out(16#0200# + dma_step_cnt, i);\r
+                            elsif (dma_step_cnt = (1 + j) * cpu_io_multi) then\r
+                                io_out(16#0201# + dma_step_cnt, ch);\r
+                            elsif (dma_step_cnt = (2 + j) * cpu_io_multi) then\r
+                                io_out(16#0202# + dma_step_cnt, 16#01#);\r
+                            elsif (dma_step_cnt = (3 + j) * cpu_io_multi) then\r
+                                io_out(16#0203# + dma_step_cnt, j);\r
+                            else\r
+                                io_brk;\r
+                                if (dma_step_cnt > 17 * cpu_io_multi) then\r
+                                    global_step_cnt := global_step_cnt + 1;\r
+                                end if;\r
+                            end if;\r
+                        else\r
+                            if    (dma_step_cnt = (0 + j) * cpu_io_multi) then\r
+                                --start dma\r
+                                io_out(16#4014#, 16#02#);\r
+                            else\r
+                                io_brk;\r
+                                if (dma_step_cnt > 17 * cpu_io_multi) then\r
+                                    global_step_cnt := global_step_cnt + 1;\r
+                                end if;\r
+                            end if;\r
+                        end if;\r
+                    end loop;\r
+                    \r
+                    dma_step_cnt := dma_step_cnt + 1;\r
+\r
+                elsif (global_step_cnt = 5) then\r
                     --final step = enable ppu.\r
                     if (enable_ppu_step_cnt = 0 * cpu_io_multi) then\r
                         --scroll reg set x.\r