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

Subversion Repositories powersupplysequencer

[/] [powersupplysequencer/] [vhdl/] [tb/] [PowerSupply/] [PowerSupply.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dk4xp
-- simple power supply model for testbeds.
2
-- here we are not interested in line regulation. We just want to see
3
-- the reaction to the enable signal, the rough behaviour of the output
4
-- voltage and that it asserts powergood when the output voltage approaches
5
-- the intended value. And it breaks on command.
6
 
7
-- (c) 2009.. Gerhard Hoffmann  opencores@hoffmann-hochfrequenz.de
8
-- published under BSD conditions.
9
 
10
 
11
library IEEE;
12
use IEEE.STD_LOGIC_1164.ALL;
13
use IEEE.numeric_std.all;
14
use ieee.math_real.all;
15
 
16
 
17
 
18
entity PowerSupply is
19
  generic (
20
    voltage:    real := 3.3;
21
    risetime:   real := 1.0e-3    -- one millisecond
22
  );
23
 
24
  port (
25
    defective: in  boolean;
26
    ena:       in  std_logic;
27
    pgood:     out std_logic;
28
    vout:      out real
29
  );
30
end entity PowerSupply;
31
 
32
 
33
 
34
architecture behave of PowerSupply is
35
 
36
  signal cur_voltage:  real := 0.0;
37
  signal voltage_goal: real := 0.0;
38
 
39
 
40
  function bool2sl (b: boolean) return std_logic is
41
  begin
42
    if b  then return '1'; else return '0'; end if;
43
  end function bool2sl;
44
 
45
 
46
 
47
begin
48
 
49
u_regulate: process is
50
begin
51
 
52
  if ena = '1'
53
  then
54
    voltage_goal <= voltage;
55
  else
56
    voltage_goal <= 0.0;
57
  end if;
58
 
59
  -- 1.0e-6 is for the 1 us timestep
60
  cur_voltage   <= cur_voltage + (voltage_goal - cur_voltage) * ((1.0e-6 * 3.0) / risetime);
61
 
62
  pgood <= bool2sl ( (cur_voltage > (0.95 * voltage)) and not defective);
63
  vout  <= cur_voltage;
64
 
65
  wait for 1 us;
66
end process u_regulate;
67
 
68
 
69
end architecture behave;
70
 

powered by: WebSVN 2.1.0

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