repo2/atari_chips/pokeyv2/PSG/mixer.vhdl @ 1476
1009 | markw | ---------------------------------------------------------------------------
|
|
-- (c) 2020 mark watson
|
|||
-- I am happy for anyone to use this for non-commercial use.
|
|||
-- If my vhdl files are used commercially or otherwise sold,
|
|||
-- please contact me for explicit permission at scrameta (gmail).
|
|||
-- This applies for source and binary form and derived works.
|
|||
---------------------------------------------------------------------------
|
|||
LIBRARY ieee;
|
|||
USE ieee.std_logic_1164.all;
|
|||
use ieee.numeric_std.all;
|
|||
1036 | markw | ENTITY PSG_mixer IS
|
|
1009 | markw | PORT
|
|
(
|
|||
CLK : IN STD_LOGIC;
|
|||
RESET_N : IN STD_LOGIC;
|
|||
ENABLE : IN STD_LOGIC;
|
|||
NOISE : IN STD_LOGIC;
|
|||
CHANNEL : IN STD_LOGIC;
|
|||
NOISE_OFF : IN STD_LOGIC;
|
|||
TONE_OFF : IN STD_LOGIC;
|
|||
BIT_OUT : OUT STD_LOGIC
|
|||
);
|
|||
1036 | markw | END PSG_mixer;
|
|
1009 | markw | ||
1036 | markw | ARCHITECTURE vhdl OF PSG_mixer IS
|
|
1009 | markw | signal bit_reg: std_logic;
|
|
signal bit_next: std_logic;
|
|||
1049 | markw | signal tone_reg: std_logic;
|
|
signal tone_next: std_logic;
|
|||
1009 | markw | BEGIN
|
|
-- register
|
|||
process(clk, reset_n)
|
|||
begin
|
|||
if (reset_n = '0') then
|
|||
bit_reg <= '0';
|
|||
1049 | markw | tone_reg <= '0';
|
|
1009 | markw | elsif (clk'event and clk='1') then
|
|
bit_reg <= bit_next;
|
|||
1049 | markw | tone_reg <= tone_next;
|
|
1009 | markw | end if;
|
|
end process;
|
|||
-- next state
|
|||
1052 | markw | process(tone_reg,bit_reg,enable,noise,channel,noise_off,tone_off)
|
|
1049 | markw | variable tone_comp : std_logic;
|
|
1009 | markw | begin
|
|
1049 | markw | tone_next <= tone_reg;
|
|
1050 | markw | bit_next <= bit_reg;
|
|
1009 | markw | ||
if (enable = '1') then
|
|||
1049 | markw | tone_comp := tone_reg xor channel;
|
|
tone_next <= tone_comp;
|
|||
1052 | markw | bit_next <= (noise or noise_off) and (tone_reg or tone_off);
|
|
1009 | markw | end if;
|
|
end process;
|
|||
-- output
|
|||
bit_out <= bit_reg;
|
|||
END vhdl;
|