From 4bb1c04caa5e322a866839155584f692aff7d67b Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Mon, 15 Apr 2019 14:40:14 +0200 Subject: [PATCH 1/3] use constant values for ioctl_index --- cores/c64/rtl/mist/c64_mist.vhd | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/cores/c64/rtl/mist/c64_mist.vhd b/cores/c64/rtl/mist/c64_mist.vhd index 5d978f3..001dcd5 100644 --- a/cores/c64/rtl/mist/c64_mist.vhd +++ b/cores/c64/rtl/mist/c64_mist.vhd @@ -207,6 +207,13 @@ component user_io generic(STRLEN : integer := 0 ); port ); end component user_io; +-- constants for ioctl_index +constant FILE_BOOT : std_logic_vector(7 downto 0) := x"00"; -- ROM files sent at boot time +constant FILE_PRG : std_logic_vector(7 downto 0) := x"02"; +constant FILE_TAP : std_logic_vector(7 downto 0) := x"42"; +constant FILE_CRT : std_logic_vector(7 downto 0) := x"82"; +constant FILE_ROM : std_logic_vector(7 downto 0) := x"03"; + component data_io port ( clk_sys : in std_logic; @@ -624,7 +631,7 @@ begin ioctl_dout => ioctl_data ); - cart_loading <= '1' when ioctl_download = '1' and ioctl_index = x"82" else '0'; + cart_loading <= '1' when ioctl_download = '1' and ioctl_index = FILE_CRT else '0'; cart : cartridge port map ( @@ -714,7 +721,7 @@ begin end if; if ioctl_wr='1' then - if ioctl_index = x"02" then--prg + if ioctl_index = FILE_PRG then if ioctl_addr = 0 then ioctl_load_addr(7 downto 0) <= ioctl_data; elsif(ioctl_addr = 1) then @@ -724,7 +731,7 @@ begin end if; end if; - if ioctl_index = x"82" then--CRT, e0(MAX) + if ioctl_index = FILE_CRT then -- e0(MAX) if ioctl_addr = 0 then ioctl_load_addr <= '0' & X"100000"; cart_blk_len <= (others => '0'); @@ -766,7 +773,7 @@ begin end if; end if; - if ioctl_index = x"42" then -- TAP + if ioctl_index = FILE_TAP then if ioctl_addr = 0 then ioctl_load_addr <= '0' & X"200000"; ioctl_ram_data <= ioctl_data; @@ -776,7 +783,7 @@ begin end if; - if old_download /= ioctl_download and ioctl_index = x"82" then + if old_download /= ioctl_download and ioctl_index = FILE_CRT then cart_attached <= old_download; erase_cram <= '1'; end if; @@ -804,9 +811,9 @@ begin end if; end process; - c64rom_wr <= ioctl_wr when (((ioctl_index = 0) and (ioctl_addr(14) = '0')) or (ioctl_index = 3)) and (ioctl_download = '1') else '0'; - c64rom_addr <= ioctl_addr(13 downto 0) when ioctl_index = 0 else '1' & ioctl_addr(12 downto 0); - c1541rom_wr <= ioctl_wr when (ioctl_index = 0) and (ioctl_addr(14) = '1') and (ioctl_download = '1') else '0'; + c64rom_wr <= ioctl_wr when (((ioctl_index = FILE_BOOT) and (ioctl_addr(14) = '0')) or (ioctl_index = FILE_ROM)) and (ioctl_download = '1') else '0'; + c64rom_addr <= ioctl_addr(13 downto 0) when ioctl_index = FILE_BOOT else '1' & ioctl_addr(12 downto 0); + c1541rom_wr <= ioctl_wr when (ioctl_index = FILE_BOOT) and (ioctl_addr(14) = '1') and (ioctl_download = '1') else '0'; process(clk_c64) begin @@ -941,7 +948,7 @@ begin reset_counter <= 1000000; reset_n <= '0'; elsif buttons(1)='1' or st_detach_cartdrige='1' or reset_key = '1' or reset_crt='1' or - (ioctl_download='1' and (ioctl_index = 3 or ioctl_index = x"82")) then -- kernal or crt + (ioctl_download='1' and (ioctl_index = FILE_ROM or ioctl_index = FILE_CRT)) then reset_counter <= 255; reset_n <= '0'; elsif ioctl_download ='1' then @@ -1214,8 +1221,8 @@ begin -- TAP playback controller cass_sense <= not tap_play; - tap_play_btn <= st_tap_play_btn; - + tap_play_btn <= st_tap_play_btn; + process(clk_c64, reset_n) begin if reset_n = '0' then @@ -1226,7 +1233,7 @@ begin tap_mem_ce <= '0'; elsif rising_edge(clk_c64) then tap_reset <= '0'; - if ioctl_download = '1' and ioctl_index = x"42" then + if ioctl_download = '1' and ioctl_index = FILE_TAP then tap_play <= '0'; tap_play_addr <= '0' & X"200000"; tap_last_addr <= ioctl_load_addr; From 45bf18ce12be128b791ab6d4de56006976163ddb Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Mon, 15 Apr 2019 14:40:43 +0200 Subject: [PATCH 2/3] use constant values for sdram adresses --- cores/c64/rtl/mist/c64_mist.vhd | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cores/c64/rtl/mist/c64_mist.vhd b/cores/c64/rtl/mist/c64_mist.vhd index 001dcd5..79272c7 100644 --- a/cores/c64/rtl/mist/c64_mist.vhd +++ b/cores/c64/rtl/mist/c64_mist.vhd @@ -549,6 +549,12 @@ end component cartridge; signal force_erase : std_logic; signal erase_to : std_logic_vector(4 downto 0) := (others => '0'); signal mem_ce : std_logic; + + -- sdram layout + constant C64_MEM_START : std_logic_vector(24 downto 0) := '0' & X"000000"; -- normal C64 RAM + constant CRT_MEM_START : std_logic_vector(24 downto 0) := '0' & X"100000"; -- cartdriges + constant TAP_MEM_START : std_logic_vector(24 downto 0) := '0' & X"200000"; -- .tap files + begin -- 1541/tape activity led @@ -733,7 +739,7 @@ begin if ioctl_index = FILE_CRT then -- e0(MAX) if ioctl_addr = 0 then - ioctl_load_addr <= '0' & X"100000"; + ioctl_load_addr <= CRT_MEM_START; cart_blk_len <= (others => '0'); cart_hdr_cnt <= (others => '0'); end if; @@ -775,7 +781,7 @@ begin if ioctl_index = FILE_TAP then if ioctl_addr = 0 then - ioctl_load_addr <= '0' & X"200000"; + ioctl_load_addr <= TAP_MEM_START; ioctl_ram_data <= ioctl_data; end if; ioctl_ram_wr <= '1'; @@ -1226,8 +1232,8 @@ begin process(clk_c64, reset_n) begin if reset_n = '0' then - tap_play_addr <= '0' & X"200000"; - tap_last_addr <= '0' & X"200000"; + tap_play_addr <= TAP_MEM_START; + tap_last_addr <= TAP_MEM_START; tap_play <= '0'; tap_reset <= '1'; tap_mem_ce <= '0'; @@ -1235,7 +1241,7 @@ begin tap_reset <= '0'; if ioctl_download = '1' and ioctl_index = FILE_TAP then tap_play <= '0'; - tap_play_addr <= '0' & X"200000"; + tap_play_addr <= TAP_MEM_START; tap_last_addr <= ioctl_load_addr; tap_reset <= '1'; if ioctl_addr = x"00000C" and ioctl_wr = '1' then From 97444c439ee435f26134d228134c2bbacd1e4369 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Mon, 15 Apr 2019 14:52:04 +0200 Subject: [PATCH 3/3] fix tab indentation --- cores/c64/rtl/mist/c64_mist.vhd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/c64/rtl/mist/c64_mist.vhd b/cores/c64/rtl/mist/c64_mist.vhd index 79272c7..51f8fe3 100644 --- a/cores/c64/rtl/mist/c64_mist.vhd +++ b/cores/c64/rtl/mist/c64_mist.vhd @@ -550,9 +550,9 @@ end component cartridge; signal erase_to : std_logic_vector(4 downto 0) := (others => '0'); signal mem_ce : std_logic; - -- sdram layout - constant C64_MEM_START : std_logic_vector(24 downto 0) := '0' & X"000000"; -- normal C64 RAM - constant CRT_MEM_START : std_logic_vector(24 downto 0) := '0' & X"100000"; -- cartdriges + -- sdram layout + constant C64_MEM_START : std_logic_vector(24 downto 0) := '0' & X"000000"; -- normal C64 RAM + constant CRT_MEM_START : std_logic_vector(24 downto 0) := '0' & X"100000"; -- cartdriges constant TAP_MEM_START : std_logic_vector(24 downto 0) := '0' & X"200000"; -- .tap files begin