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

Subversion Repositories uart_fpga_slow_control_migrated

[/] [uart_fpga_slow_control/] [trunk/] [code/] [library/] [gh_Pulse_Generator.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 aborga
-----------------------------------------------------------------------------
2
--      Filename:       gh_Pulse_Generator.vhd
3
--
4
--      Description:
5
--              A Pulse Generator
6
--
7
--      Copyright (c) 2005, 2006 by George Huber 
8
--              an OpenCores.org Project
9
--              free to use, but see documentation for conditions 
10
--
11
--      Revision        History:
12
--      Revision        Date            Author          Comment
13
--      --------        ----------      ---------       -----------
14
--      1.0             09/24/05        S A Dodd        Initial revision
15
--      1.1             02/18/06        G Huber         add gh_ to name
16
--      1.2             03/09/06        S A Dodd        fix typo's, add Period reload 
17
--                                                         if Period_count > Period
18
--
19
-----------------------------------------------------------------------------
20
 
21
library IEEE;
22
USE ieee.std_logic_1164.all;
23
USE ieee.std_logic_unsigned.all;
24
USE ieee.std_logic_arith.all;
25
 
26
entity gh_Pulse_Generator is
27
        GENERIC(size_Period: INTEGER := 16);
28
        port(
29
                clk         : in std_logic;
30
                rst         : in std_logic;
31
                Period      : in std_logic_vector (size_Period-1 downto 0);
32
                Pulse_Width : in std_logic_vector (size_Period-1 downto 0);
33
                ENABLE      : in std_logic;
34
                Pulse       : out std_logic
35
                );
36
end entity;
37
 
38
architecture a of gh_Pulse_Generator is
39
 
40
COMPONENT gh_counter_down_ce_ld is
41
        GENERIC (size: INTEGER :=8);
42
        PORT(
43
                CLK   : IN      STD_LOGIC;
44
                rst   : IN      STD_LOGIC;
45
                LOAD  : IN      STD_LOGIC;
46
                CE    : IN      STD_LOGIC;
47
                D     : IN  STD_LOGIC_VECTOR(size-1 DOWNTO 0);
48
                Q     : OUT STD_LOGIC_VECTOR(size-1 DOWNTO 0)
49
                );
50
END COMPONENT;
51
 
52
        signal trigger        : std_logic;
53
        signal LD_Period      : std_logic;
54
        signal Period_Count   : std_logic_vector(size_Period-1 downto 0);
55
        signal Width_Count    : std_logic_vector(size_Period-1 downto 0);
56
        signal Period_cmp     : std_logic_vector(size_Period-1 downto 0);
57
        signal Width_cmp      : std_logic_vector(size_Period-1 downto 0);
58
 
59
        signal LD_width      : std_logic;
60
        signal E_width       : std_logic;
61
 
62
begin
63
 
64
-- constant compare values  -----------------------------------
65
        Period_cmp(size_Period-1 downto 1) <= (others =>'0');
66
        Period_cmp(0) <= '1';
67
        Width_cmp <= (others => '0');
68
---------------------------------------------------------------
69
 
70
 
71
U1 : gh_counter_down_ce_ld
72
        Generic Map(size_Period)
73
        PORT MAP(
74
                clk => clk,
75
                rst => rst,
76
                LOAD => LD_Period,
77
                CE => ENABLE,
78
                D => Period,
79
                Q => Period_Count
80
                );
81
 
82
        LD_Period <= trigger or (not ENABLE);
83
 
84
        trigger <= '1' when (Period_Count > Period) else
85
                   '1' when (Period_Count = Period_cmp) else
86
                   '0';
87
 
88
-----------------------------------------------------------
89
 
90
U2 : gh_counter_down_ce_ld
91
        Generic Map(size_Period)
92
        PORT MAP(
93
                clk => clk,
94
                rst => rst,
95
                LOAD => LD_width,
96
                CE => E_width,
97
                D => Pulse_Width,
98
                Q => Width_Count
99
                );
100
 
101
        LD_width <= trigger;
102
 
103
        E_width <= '0' when (Width_Count = Width_cmp) else
104
                   '1';
105
 
106
        Pulse <= E_width;
107
 
108
end a;
109
 

powered by: WebSVN 2.1.0

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