From 0f1eb4330100306347961d4d98227a8146e88c71 Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 31 Jan 2019 18:54:17 +0100 Subject: [PATCH] [C64] SID: read back the last written value --- cores/c64/rtl/sid/sid_regs.vhd | 16 +++------------- cores/c64/rtl/sid8580/sid8580.sv | 4 +++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/cores/c64/rtl/sid/sid_regs.vhd b/cores/c64/rtl/sid/sid_regs.vhd index 1ff1ca5..c145cb8 100644 --- a/cores/c64/rtl/sid/sid_regs.vhd +++ b/cores/c64/rtl/sid/sid_regs.vhd @@ -98,6 +98,7 @@ architecture gideon of sid_regs is signal sust_rel : byte_array_t(0 to 15) := (others => (others => '0')); signal do_write : std_logic; signal wdata_d : std_logic_vector(7 downto 0); + signal last_write : std_logic_vector(7 downto 0); signal filt_en_i: std_logic_vector(15 downto 0) := (others => '0'); constant address_remap : byte_array_t(0 to 255) := ( @@ -159,6 +160,7 @@ begin wdata_d <= wdata; if do_write='0' and wren='1' then + last_write <= wdata_d; if address(3)='0' then -- Voice register case address(2 downto 0) is when "000" => freq_lo(to_integer(address(7 downto 4))) <= wdata_d; @@ -209,20 +211,8 @@ begin when "00011010" => rdata <= poty; when "00011011" => rdata <= osc3; when "00011100" => rdata <= env3; - when others => rdata <= (others => '0'); + when others => rdata <= last_write; end case; - if address(3) = '0' then - case address(2 downto 0) is - when "000" => rdata <= freq_lo(to_integer(address(7 downto 4))); - when "001" => rdata <= freq_hi(to_integer(address(7 downto 4))); - when "010" => rdata <= phase_lo(to_integer(address(7 downto 4))); - when "011" => rdata <= "0000" & phase_hi(to_integer(address(7 downto 4))); - when "100" => rdata <= control(to_integer(address(7 downto 4))); - when "101" => rdata <= att_dec(to_integer(address(7 downto 4))); - when "110" => rdata <= sust_rel(to_integer(address(7 downto 4))); - when others => null; - end case; - end if; if reset='1' then freq_lo <= (others => (others => '0')); diff --git a/cores/c64/rtl/sid8580/sid8580.sv b/cores/c64/rtl/sid8580/sid8580.sv index 8f27acf..6d3e3e3 100644 --- a/cores/c64/rtl/sid8580/sid8580.sv +++ b/cores/c64/rtl/sid8580/sid8580.sv @@ -150,13 +150,14 @@ assign data_out = do_buf; //assign unsigned_audio = unsigned_filt[18:1]; //assign audio_data = filtered_audio[18:3];// + 15'h4000;//{1'b0, unsigned_audio[17:1]}; +reg [7:0] last_wr; always @(*) begin case (addr) 5'h19: do_buf = pot_x; 5'h1a: do_buf = pot_y; 5'h1b: do_buf = Misc_Osc3_Random; 5'h1c: do_buf = Misc_Env3; - default: do_buf = 0; + default: do_buf = last_wr; endcase end @@ -192,6 +193,7 @@ always @(posedge clk) begin end else begin if (we) begin + last_wr <= data_in; case (addr) 5'h00: Voice_1_Freq_lo <= data_in; 5'h01: Voice_1_Freq_hi <= data_in;