Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

I 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; 

16 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I meant simply to look in the timing report to see if Quartus is reporting a Tpd path from every input pin to every output pin. It should since your design as posted should result in a totally combinatorial logic path. The thought is that somehow things didn't get connected in a higher up level which if they didn't would result in some pins not having such a path. However, since you've used the netlist viewer on the post map to verify that there are indeed all of the logic paths there is no need to look for a timing path.

    About the only thing left is that the switches are not hooked up on the board to the pins that you are specifying in the FPGA design. Verify with a scope or meter that when you change a particular switch setting that the pin in question really does toggle and go to the expected voltage level.

    Kevin Jennings

    --- Quote End ---

    The switches are definitely connected, i used them to control the on board LEDS.

    I've tried so many different things here!

    The only other thing i can think of is that maybe its some kind of syntax problem for example do i need to specify i want to use the binary value of 'SW' and multiply this. I'm guessing this is assumed though.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You could try registering your signals and then use signal tap to check your circuits logic. If it works with registers then it is probably a timing issue. If it still isn't working you should be able to see where your errors are, like switches not working correctly.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    The switches are definitely connected, i used them to control the on board LEDS.

    --- Quote End ---

    Not to be persnickety (since I don't know what you have and haven't actually done), but are you sure that each switch was controlling the correct LED? Same pins?

    --- Quote Start ---

    I've tried so many different things here!

    The only other thing i can think of is that maybe its some kind of syntax problem for example do i need to specify i want to use the binary value of 'SW' and multiply this. I'm guessing this is assumed though.

    --- Quote End ---

    At this point, you can probably expect to only get more guesses, but fundamentally if you have the following things it will work so it is worth questioning and even re-checking to verify that you really do have all these items:

    - Correct pin assignments. Are you verifying the pins in the output report from Quartus match what you think they should be?

    - Correct synthesis: Try running the post-route simulation model to see if it works correctly. Are you really downloading the correct file to the device? How do you know?

    - Bad synthesis tool: Try running a different version of Quartus

    I realize that these aren't likely to really help, but it looks like you're at the point where everything you should do you have done so the best advice would be for you to play your own devil's advocate and question everything at this point and accept nothing that you haven't proved as directly as possible. Don't accept things like 'well this worked so therefore xxx must be'. Measure xxx if at all possible.

    Good luck, wish I could be more help, but I'm running short on ideas.

    Kevin Jennings
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok i got it working. It was something i had no idea would make a difference but thought i'd try it. I hope you might be able to explain or help me understand why this makes a difference

    I added what a few other designs i've seen call a pipeline buffer- code below

    From looking at this, it just seems like the audio samples are being synced upto the system clock edge but i dont understand why that is necessary.

    library IEEE;
    use IEEE.std_logic_1164.all;
    entity pipeline_buffer is
    	port (
    		
    		clk: in std_logic;
    		lrclk: in std_logic;
    		reset: in std_logic;
    				
    		-- data
    		sample_in_left: in std_logic_vector(15 downto 0);
    		sample_out_left: out std_logic_vector(15 downto 0);
    		sample_in_right: in std_logic_vector(15 downto 0);
    		sample_out_right: out std_logic_vector(15 downto 0)
    		
    	);
    end entity pipeline_buffer;
    architecture beh of pipeline_buffer is
    	signal last_lrclk: std_logic;
    begin
    	process (clk, reset)
    	begin
    		if (reset='0') then
    			sample_out_right <= (others => '0');
    			sample_out_left <= (others => '0');
    		elsif rising_edge(clk) then
    			sample_out_right <= sample_in_right;
    			sample_out_left <= sample_in_left;
    		end if;
    	end process;
    end architecture beh; 
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Ok i got it working. It was something i had no idea would make a difference but thought i'd try it. I hope you might be able to explain or help me understand why this makes a difference

    I added what a few other designs i've seen call a pipeline buffer- code below

    From looking at this, it just seems like the audio samples are being synced upto the system clock edge but i dont understand why that is necessary.

    --- Quote End ---

    Nor will anyone else likely be able to figure out why is was necessary since you haven't posted your entire design (both the 'working' and the 'not working'). Synchronizing signals to a clock is necessary when asynchronous signals or signals from a different clock domain are used with synchronous logic, but the original code you posted has no clock so that wouldn't be the case...unless you haven't posted something that is relevant to the design. As an example, it is not even clear how your samples have morphed into a 'left' and a 'right'.

    Kevin
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Nor will anyone else likely be able to figure out why is was necessary since you haven't posted your entire design (both the 'working' and the 'not working'). Synchronizing signals to a clock is necessary when asynchronous signals or signals from a different clock domain are used with synchronous logic, but the original code you posted has no clock so that wouldn't be the case...unless you haven't posted something that is relevant to the design. As an example, it is not even clear how your samples have morphed into a 'left' and a 'right'.

    Kevin

    --- Quote End ---

    Yeah i guess it makes sense. I creates a serial in parallel out which frames the serial stream from the CODEC out and extracts left and right.

    Kevin, thanks very much for your time and help on this :-)

    Now i can move on with the project