OpenCores
URL https://opencores.org/ocsvn/viirf/viirf/trunk

Subversion Repositories viirf

[/] [viirf/] [trunk/] [src/] [sos_core_df1_tb.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Muraer
--------------------------------------------------------------------------------------------------------------
2
-- MIT License
3
--  
4
-- Copyright (c) 2017 Mario Mauerer
5
--  
6
-- Permission is hereby granted, free of charge, to any person obtaining a copy
7
-- of this software and associated documentation files (the "Software"), to deal
8
-- in the Software without restriction, including without limitation the rights
9
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
-- copies of the Software, and to permit persons to whom the Software is
11
-- furnished to do so, subject to the following conditions:
12
-- 
13
-- The above copyright notice and this permission notice shall be included in all
14
-- copies or substantial portions of the Software.
15
-- 
16
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
-- SOFTWARE.
23
--
24
-----------------------------------------------------------------------------
25
--
26
-- VIIRF - Versatile IIR Filter
27
--
28
-- Testbench for sos_core_df1.vhd
29
--
30
-- This testbench does not test the correct implementation of the SOS, this is
31
-- done by the top-level testbench (sos_cascaded_top.vhd).
32
--
33
-- This only tests signals like strobes and internal routing / delays.
34
-- Hence, it is a very simple unit. It simply applies some coefficients/gains
35
-- and checks, if the data is output correctly / with the correct strobe. 
36
 
37
library IEEE;
38
use IEEE.STD_LOGIC_1164.all;
39
use IEEE.NUMERIC_STD.all;
40
 
41
-------------------------------------------------------------------------------
42
 
43
entity sos_core_df1_tb is
44
end entity sos_core_df1_tb;
45
 
46
-------------------------------------------------------------------------------
47
 
48
architecture arch_tb of sos_core_df1_tb is
49
 
50
  -- component generics
51
  constant W_DAT      : integer := 25;
52
  constant W_COEF     : integer := 18;
53
  constant W_FRAC     : integer := 16;
54
  constant SOSGAIN_EN : boolean := false;
55
 
56
  -- component ports
57
  signal ClkxCI  : std_logic := '1';
58
  signal RstxRI  : std_logic;
59
  signal DatxDI  : signed(W_DAT-1 downto 0);
60
  signal StrbxSI : std_logic;
61
  signal DatxDO  : signed(W_DAT-1 downto 0);
62
  signal StrbxSO : std_logic;
63
  signal b0xDI   : signed(W_COEF-1 downto 0);
64
  signal b1xDI   : signed(W_COEF-1 downto 0);
65
  signal b2xDI   : signed(W_COEF-1 downto 0);
66
  signal a1xDI   : signed(W_COEF-1 downto 0);
67
  signal a2xDI   : signed(W_COEF-1 downto 0);
68
  signal gxDI    : signed(W_COEF-1 downto 0);
69
 
70
begin  -- architecture arch_tb
71
 
72
  -- component instantiation
73
  DUT : entity work.sos_core_df1
74
    generic map (
75
      W_DAT      => W_DAT,
76
      W_COEF     => W_COEF,
77
      W_FRAC     => W_FRAC,
78
      SOSGAIN_EN => SOSGAIN_EN)
79
    port map (
80
      ClkxCI  => ClkxCI,
81
      RstxRI  => RstxRI,
82
      DatxDI  => DatxDI,
83
      StrbxSI => StrbxSI,
84
      DatxDO  => DatxDO,
85
      StrbxSO => StrbxSO,
86
      b0xDI   => b0xDI,
87
      b1xDI   => b1xDI,
88
      b2xDI   => b2xDI,
89
      a1xDI   => a1xDI,
90
      a2xDI   => a2xDI,
91
      gxDI    => gxDI);
92
 
93
  -- clock generation
94
  ClkxCI <= not ClkxCI after 5 ns;
95
 
96
  -- waveform generation
97
  WaveGen_Proc : process
98
  begin
99
    RstxRI  <= '1';
100
    DatxDI  <= (others => '0');
101
    StrbxSI <= '0';
102
    -- Set all coeffs to 1 or 2 in the Q-notation:
103
    b0xDI   <= shift_left(to_signed(1, W_COEF), W_FRAC);
104
    b1xDI   <= shift_left(to_signed(1, W_COEF), W_FRAC);
105
    b2xDI   <= shift_left(to_signed(1, W_COEF), W_FRAC);
106
    a1xDI   <= shift_left(to_signed(1, W_COEF), W_FRAC);
107
    a2xDI   <= shift_left(to_signed(1, W_COEF), W_FRAC);
108
    gxDI    <= shift_left(to_signed(2, W_COEF), W_FRAC);
109
    wait for 100 ns;
110
    wait until rising_edge(ClkxCI);
111
    RstxRI  <= '0';
112
 
113
    for I in 1 to 20 loop
114
      wait for 100 ns;
115
      wait until rising_edge(ClkxCI);
116
      DatxDI  <= to_signed(I, W_DAT);
117
      StrbxSI <= '1';
118
      wait until rising_edge(ClkxCI);
119
      StrbxSI <= '0';
120
    end loop;
121
    wait;
122
  end process WaveGen_Proc;
123
 
124
end architecture arch_tb;
125
 
126
-------------------------------------------------------------------------------
127
 
128
configuration sos_core_df1_tb_arch_tb_cfg of sos_core_df1_tb is
129
  for arch_tb
130
  end for;
131
end sos_core_df1_tb_arch_tb_cfg;
132
 
133
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.