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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [customCounter.vhd] - Blame information for rev 142

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 142 jguarin200
--! @file sm.vhd
2
--! @brief Maquina de Estados. Controla la operación interna y genera los mecanismos de sincronización con el exterior (interrupciones). 
3
--! @author Julián Andrés Guarín Reyes
4
--------------------------------------------------------------
5
-- RAYTRAC
6
-- Author Julian Andres Guarin
7
-- sm.vhd
8
-- This file is part of raytrac.
9
-- 
10
--     raytrac is free software: you can redistribute it and/or modify
11
--     it under the terms of the GNU General Public License as published by
12
--     the Free Software Foundation, either version 3 of the License, or
13
--     (at your option) any later version.
14
-- 
15
--     raytrac is distributed in the hope that it will be useful,
16
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
17
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
--     GNU General Public License for more details.
19
-- 
20
--     You should have received a copy of the GNU General Public License
21
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
 
24
library ieee;
25
use ieee.std_logic_1164.all;
26
use ieee.std_logic_unsigned.all;
27
 
28
 
29
entity customCounter is
30
        generic (
31
                width : integer := 9;
32
        )
33
        port (
34
                clk,rst,go,set : in std_logic;
35
                setValue : in std_logic_vector(width - 1 downto 0);
36
                count : out std_logic_vector (width - 1 downto 0)
37
        );
38
end entity;
39
 
40
 
41
 
42
architecture customCounter_arch of customCounter is
43
 
44
        constant rstMasterValue : std_logic := '0';
45
        signal scount_d, scount_q : std_logic_vector(width-1 downto 0);
46
 
47
 
48
begin
49
        count <= scount_d;
50
        add_proc:
51
        process (scount_q,go,set,setValue)
52
        begin
53
                case set is
54
                        when '1'  => scount_d <= setValue;
55
                        when others => scount_d <= scount_q+go;
56
                end case;
57
        end process;
58
 
59
        count_proc:
60
        process (clk,rst)
61
        begin
62
                if rst=rstMasterValue then
63
                        scount_q <= (others => '0');
64
                elsif clk='1' and clk'event then
65
                        scount_q <= scount_d;
66
                end if;
67
        end process;
68
end architecture;
69
 
70
 

powered by: WebSVN 2.1.0

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