Revision 1400
Added by markw over 1 year ago
atari_chips/pokeyv2/mixer.vhdl | ||
---|---|---|
POST_DIVIDE : IN STD_LOGIC_VECTOR(7 downto 0);
|
||
FANCY_ENABLE : IN STD_LOGIC;
|
||
GTIA_EN : IN STD_LOGIC_VECTOR(3 downto 0);
|
||
ADC_EN : IN STD_LOGIC_VECTOR(3 downto 0);
|
||
|
||
CH0 : IN UNSIGNED(15 downto 0); --pokey0
|
||
CH1 : IN UNSIGNED(15 downto 0); --pokey1
|
||
... | ... | |
CH8 : IN UNSIGNED(15 downto 0); --psg0
|
||
CH9 : IN UNSIGNED(15 downto 0); --psg1
|
||
CHA : IN UNSIGNED(15 downto 0); --gtia0
|
||
CHB : IN UNSIGNED(15 downto 0); --adc
|
||
|
||
AUDIO_0_UNSIGNED : out unsigned(15 downto 0);
|
||
AUDIO_1_UNSIGNED : out unsigned(15 downto 0);
|
||
... | ... | |
constant state_sample_L : unsigned(3 downto 0) := "0010";
|
||
constant state_sid_L : unsigned(3 downto 0) := "0011";
|
||
constant state_psg_L : unsigned(3 downto 0) := "0100";
|
||
constant state_gtia_L : unsigned(3 downto 0) := "0101";
|
||
constant state_clear_L : unsigned(3 downto 0) := "0110";
|
||
constant state_pokeyA_R : unsigned(3 downto 0) := "0111";
|
||
constant state_pokeyB_R : unsigned(3 downto 0) := "1000";
|
||
constant state_sample_R : unsigned(3 downto 0) := "1001";
|
||
constant state_sid_R : unsigned(3 downto 0) := "1010";
|
||
constant state_psg_R : unsigned(3 downto 0) := "1011";
|
||
constant state_gtia_R : unsigned(3 downto 0) := "1100";
|
||
constant state_clear_R : unsigned(3 downto 0) := "1101";
|
||
constant state_adc_L : unsigned(3 downto 0) := "0101";
|
||
constant state_gtia_L : unsigned(3 downto 0) := "0110";
|
||
constant state_clear_L : unsigned(3 downto 0) := "0111";
|
||
constant state_pokeyA_R : unsigned(3 downto 0) := "1000";
|
||
constant state_pokeyB_R : unsigned(3 downto 0) := "1001";
|
||
constant state_sample_R : unsigned(3 downto 0) := "1010";
|
||
constant state_sid_R : unsigned(3 downto 0) := "1011";
|
||
constant state_psg_R : unsigned(3 downto 0) := "1100";
|
||
constant state_adc_R : unsigned(3 downto 0) := "1101";
|
||
constant state_gtia_R : unsigned(3 downto 0) := "1110";
|
||
constant state_clear_R : unsigned(3 downto 0) := "1111";
|
||
|
||
signal channelsel : std_logic_vector(3 downto 0);
|
||
|
||
... | ... | |
state_next <= state_psg_L;
|
||
when state_psg_L =>
|
||
channelsel <= x"8";
|
||
state_next <= state_adc_L;
|
||
when state_adc_L =>
|
||
channelsel <= x"b";
|
||
write_0 <= not(adc_en(0));
|
||
write_1 <= not(adc_en(0)) and leftOnRight;
|
||
write_2 <= not(adc_en(2));
|
||
write_3 <= not(adc_en(2)) and leftOnRight;
|
||
state_next <= state_gtia_L;
|
||
when state_gtia_L =>
|
||
channelsel <= x"a";
|
||
... | ... | |
when state_psg_R =>
|
||
channelsel <= x"9";
|
||
R := '1';
|
||
state_next <= state_adc_R;
|
||
when state_adc_R =>
|
||
channelsel <= x"b";
|
||
R := '1';
|
||
write_1 <= not(adc_en(1)) and not(leftOnRight);
|
||
write_3 <= not(adc_en(3)) and not(leftOnRight);
|
||
-- NEEDS DOING WITHOUT ADC GTIA mixed, since those plays on all channels!!
|
||
RIGHT_NEXT <= xor_reduce(std_logic_vector(saturated));
|
||
state_next <= state_gtia_R;
|
||
when state_gtia_R =>
|
||
channelsel <= x"b";
|
||
channelsel <= x"a";
|
||
R := '1';
|
||
write_1 <= not(gtia_en(1)) and not(leftOnRight);
|
||
write_3 <= not(gtia_en(3)) and not(leftOnRight);
|
||
-- NEEDS DOING WITHOUT GTIA mixed, since that plays on all channels!!
|
||
RIGHT_NEXT <= xor_reduce(std_logic_vector(saturated));
|
||
state_next <= state_clear_R;
|
||
when state_clear_R =>
|
||
clearAcc := '1';
|
||
... | ... | |
volume <= ch9;
|
||
when x"a" =>
|
||
volume <= cha;
|
||
when x"b" =>
|
||
volume <= chb;
|
||
when others =>
|
||
end case;
|
||
end process;
|
atari_chips/pokeyv2/pokeymax.vhd | ||
---|---|---|
signal PS2DAT : std_logic;
|
||
|
||
-- adc
|
||
signal count_reg : unsigned(7 downto 0);
|
||
signal count_next : unsigned(7 downto 0);
|
||
|
||
signal sum_reg : unsigned(7 downto 0);
|
||
signal sum_next : unsigned(7 downto 0);
|
||
|
||
... | ... | |
signal toggle_reg : std_logic_vector(255 downto 0);
|
||
signal toggle_next : std_logic_vector(255 downto 0);
|
||
|
||
signal decimate_reg : unsigned(3 downto 0);
|
||
signal decimate_next : unsigned(3 downto 0);
|
||
|
||
signal ADC_FILTERED1 : unsigned(15 downto 0);
|
||
signal ADC_FILTERED2 : unsigned(15 downto 0);
|
||
|
||
... | ... | |
DETECT_RIGHT => DETECT_RIGHT_REG,
|
||
FANCY_ENABLE => FANCY_ENABLE,
|
||
GTIA_EN => GTIA_ENABLE_REG,
|
||
ADC_EN => "1100",
|
||
|
||
CH0 => POKEY_AUDIO_0,
|
||
CH1 => POKEY_AUDIO_1,
|
||
... | ... | |
CHA(11) => SIO_RXD_SYNC,
|
||
CHA(10 downto 0) => (others=>'0'),
|
||
CHA(15) => GTIA_AUDIO,
|
||
CHB => ADC_FILTERED2,
|
||
|
||
AUDIO_0_UNSIGNED => AUDIO_0_UNSIGNED,
|
||
AUDIO_1_UNSIGNED => AUDIO_1_UNSIGNED,
|
||
... | ... | |
process(clk,reset_n)
|
||
begin
|
||
if (reset_n='0') then
|
||
count_reg <= (others=>'0');
|
||
toggle_reg <= (others=>'0');
|
||
sum_reg <= (others=>'0');
|
||
decimate_reg <= (others=>'0');
|
||
sample_reg <= (others=>'0');
|
||
elsif (clk'event and clk='1') then
|
||
count_reg <= count_next;
|
||
toggle_reg <= toggle_next;
|
||
sum_reg <= sum_next;
|
||
decimate_reg <= decimate_next;
|
||
sample_reg <= sample_next;
|
||
end if;
|
||
end process;
|
||
... | ... | |
tx_in(0) => toggle_reg(0),
|
||
tx_out(0) => ADC_TX_P
|
||
);
|
||
-- ADC_TX <= toggle_reg(0);
|
||
|
||
lvds_rx0: lvds_rx
|
||
port map(
|
||
... | ... | |
clock => CLK,
|
||
q(0) => toggle_next(0)
|
||
);
|
||
-- toggle_next(0) <= not(ext_in);
|
||
toggle_next(255 downto 1) <= toggle_reg(254 downto 0);
|
||
|
||
adcfilter : entity work.simple_low_pass_filter
|
||
... | ... | |
AUDIO_OUT => ADC_FILTERED2
|
||
);
|
||
|
||
process(count_reg,sum_reg,sample_reg,toggle_reg,decimate_reg)
|
||
process(sum_reg,sample_reg,toggle_reg)
|
||
begin
|
||
count_next <= count_reg;
|
||
sum_next <= sum_reg;
|
||
sample_next <= sample_reg;
|
||
decimate_next <= decimate_reg;
|
||
|
||
if (toggle_reg(255)='1' and toggle_reg(0)='0') then
|
||
sum_next <= sum_reg -1;
|
||
... | ... | |
end generate adc_off;
|
||
|
||
paddle_lvds_on : if paddle_lvds=1 generate
|
||
--PADDLE_ADJ <= PADDLE_P;
|
||
--PADDLE_P <= (others=>'0') when POTRESET='1' else (others=>'Z');
|
||
-- lvds
|
||
|
||
-- paddle_lvds_tx0: lvds_tx
|
||
-- port map(
|
||
-- tx_in(0) => toggle_reg(0),
|
||
-- tx_out(0) => PADDLE_P(0)
|
||
-- );
|
||
-- ADC_TX <= toggle_reg(0);
|
||
|
||
paddle_lvds_rx0: paddle_gpio
|
||
port map(
|
||
dout => PADDLE_ADJ,
|
Also available in: Unified diff
Mix ADC in