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

Subversion Repositories pwm_with_dithering

[/] [pwm_with_dithering/] [trunk/] [testbench/] [pseudo_ADC.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:    16:41:42 02/04/2021 
6
-- Design Name:          PWM verifier
7
-- Module Name:    pseudo_ADC - Behavioral 
8
-- Target Devices: None / Simulation ONLY
9
-- Tool versions:  None / non-specific
10
-- Description:          Show ADC-like conversion from real to digital.
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 pseudo_ADC is
23
    Generic (
24
                                bits : integer :=16;
25
                                supply_voltage : real:=3.3
26
                                );
27
    Port ( v_in : in  real;
28
                          digital_out : out std_logic_vector(bits-1 downto 0)
29
                          );
30
end pseudo_ADC;
31
 
32
architecture Behavioral of pseudo_ADC is
33
signal v_internal:real:=0.0;
34
signal scale:real:=(2.0 ** bits);
35
signal max:real:=(2.0 ** bits) - 1.0;
36
 
37
begin
38
 
39
ADC:process(v_in)
40
variable value:real;
41
begin
42
        value := scale*v_in/supply_voltage;
43
        if value > max then value:= max; end if;
44
        digital_out <= STD_LOGIC_VECTOR(to_unsigned(natural(value),bits));
45
end process;
46
 
47
end Behavioral;
48
 

powered by: WebSVN 2.1.0

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