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

Subversion Repositories pwm_with_dithering

[/] [pwm_with_dithering/] [trunk/] [testbench/] [analyzer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 TeroS
----------------------------------------------------------------------------------
2
-- Company:              Aboa Space Research Oy (ASRO)
3
-- Engineer:             Tero Säntti
4
-- 
5
-- Create Date:    15:23:55 01/28/2021 
6
-- Design Name:          PWM verifier
7
-- Module Name:    analyzer - Behavioral 
8
-- Target Devices: None / Simulation ONLY
9
-- Tool versions:  None / non-specific
10
-- Description:          Analog value analyzer for testing filtered PWM
11
--
12
-- Revision: 
13
-- Revision 0.01 - File Created
14
-- Additional Comments: 
15
--
16
----------------------------------------------------------------------------------
17
library IEEE;
18
use IEEE.STD_LOGIC_1164.ALL;
19
use IEEE.NUMERIC_STD.ALL;
20
use IEEE.math_real.all;
21
 
22
entity analyzer is
23
    Generic (
24
                                supply_voltage : real:=3.3;
25
                                filter_strength: real:=0.99
26
                                );
27
    Port ( enable : in std_logic;
28
                          v_in : in  real;
29
           v_out : buffer real;
30
                          v_max : buffer real;
31
                          v_min : buffer real;
32
                          v_p2p : out real
33
                          );
34
end analyzer;
35
 
36
architecture Behavioral of analyzer is
37
 
38
begin
39
 
40
v_p2p <= v_max - v_min;
41
 
42
doit:process(v_in,enable)
43
variable v_new:real;
44
begin
45
        if enable = '0' then
46
                v_out <= v_in;
47
                v_max <= 0.0;
48
                v_min <= supply_voltage;
49
        else
50
                v_new := (filter_strength * v_out) + ((1.0-filter_strength) * v_in);
51
                if v_in > v_max then v_max <= v_in; end if;
52
                if v_in < v_min then v_min <= v_in; end if;
53
                v_out <= v_new;
54
        end if;
55
end process;
56
 
57
end Behavioral;
58
 

powered by: WebSVN 2.1.0

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