Altera_Forum
Honored Contributor
13 years agoI cant work this out!
This is to adjust volume of incoming audio samples by just multiplying by a constant value (SW). I wanted to be able to control the volume value with the switches on the DE2 but i get no sound at all. The switches are connect in the top level as SW[15..0]
However, it works fine when i type a static binary value into the code eg.. sample_in * ("0000000000011111") Surely the switches are just doing the same thing. I'm confused!!--amp.vhd
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
entity volume is
port (
-- data
sample_in: in std_logic_vector(15 downto 0);
sample_out: out std_logic_vector(15 downto 0);
-- params
SW: in std_logic_vector(15 downto 0)
);
end entity volume;
architecture beh of volume is
signal signal_unnormalized: std_logic_vector(31 downto 0);
signal sample_reg: std_logic_vector(15 downto 0);
begin
signal_unnormalized <= sample_in * SW;
sample_out <= signal_unnormalized(31) & signal_unnormalized(22 downto 8);
sample_out<=sample reg;
end architecture beh;