Skip to main content
added 1458 characters in body
Source Link
user16324
user16324

Add to your testbench a monitor process that watches the output and compares it to the expected value, allowing for the delays through the filter.

Your VHDL style is better than some - even better than some textbook examples I have seen, but still: a few comments :

  1. Using named rather than positional assignment for the "dff" component instantiations would save possible confusion between inputs and outputs for anyone trying to follow the pipeline. This doesn't really matter here, because :

  2. you can eliminate the dffs altogether; replace them with lines of the form Q1 <= MCM3; in the same clocked process as Yout <= add_out3; that greatly simplifies the whole filter.

  3. You can reduce number of conversion functions by making H0..3 integer types; and if they are constant, make them constants! As multiplication between signed and integer is defined,no other changes are required.

    type coefficient is new integer range -128 .. 127;
    constant H0 : coefficient := -2;

  4. Lose the redundant parentheses in if ( rising_edge(Clk) ) then - this isn't C!

  5. The DRY principle applies in VHDL too... there are several ways to apply it to the testbench : my choice would be a local procedure.


   stim_proc: process

      procedure Input(D : in integer range -128 .. 127) is
      begin
         Xin <= to_signed(D,8); 
         wait for clk_period*1;
      end Input;

   begin        
      wait for Clk_period*2;
        Input(-3);
        Input( 1);

Add to your testbench a monitor process that watches the output and compares it to the expected value, allowing for the delays through the filter.

Add to your testbench a monitor process that watches the output and compares it to the expected value, allowing for the delays through the filter.

Your VHDL style is better than some - even better than some textbook examples I have seen, but still: a few comments :

  1. Using named rather than positional assignment for the "dff" component instantiations would save possible confusion between inputs and outputs for anyone trying to follow the pipeline. This doesn't really matter here, because :

  2. you can eliminate the dffs altogether; replace them with lines of the form Q1 <= MCM3; in the same clocked process as Yout <= add_out3; that greatly simplifies the whole filter.

  3. You can reduce number of conversion functions by making H0..3 integer types; and if they are constant, make them constants! As multiplication between signed and integer is defined,no other changes are required.

    type coefficient is new integer range -128 .. 127;
    constant H0 : coefficient := -2;

  4. Lose the redundant parentheses in if ( rising_edge(Clk) ) then - this isn't C!

  5. The DRY principle applies in VHDL too... there are several ways to apply it to the testbench : my choice would be a local procedure.


   stim_proc: process

      procedure Input(D : in integer range -128 .. 127) is
      begin
         Xin <= to_signed(D,8); 
         wait for clk_period*1;
      end Input;

   begin        
      wait for Clk_period*2;
        Input(-3);
        Input( 1);
Source Link
user16324
user16324

Add to your testbench a monitor process that watches the output and compares it to the expected value, allowing for the delays through the filter.