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

Subversion Repositories jart

[/] [jart/] [trunk/] [BLRT/] [mod0.vhd] - Blame information for rev 87

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

Line No. Rev Author Line
1 42 jguarin200
-- Author : Julian Andres Guarin Reyes.
2
-- Project : JART, Just Another Ray Tracer.
3
-- email : jguarin2002 at gmail.com, j.guarin at javeriana.edu.co
4
 
5
-- This code was entirely written by Julian Andres Guarin Reyes.
6
-- The following code is licensed under GNU Public License
7
-- http://www.gnu.org/licenses/gpl-3.0.txt.
8
 
9
 -- This file is part of JART (Just Another Ray Tracer).
10
 
11
    -- JART (Just Another Ray Tracer) is free software: you can redistribute it and/or modify
12
    -- it under the terms of the GNU General Public License as published by
13
    -- the Free Software Foundation, either version 3 of the License, or
14
    -- (at your option) any later version.
15
 
16
    -- JART (Just Another Ray Tracer) is distributed in the hope that it will be useful,
17
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
18
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
    -- GNU General Public License for more details.
20
 
21
    -- You should have received a copy of the GNU General Public License
22
    -- along with JART (Just Another Ray Tracer).  If not, see <http://www.gnu.org/licenses/>.
23
 
24
-- Reminder 0 detector with load.
25
 
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
use ieee.std_logic_arith.all;
30
use ieee.std_logic_unsigned.all;
31
 
32
 
33
entity mod0 is
34
        generic (WIDTH : integer range 1 to 32);
35
        port (
36
 
37
                clk             : in std_logic, --Clock
38
                rst             : in std_logic, --Reset
39
                icload  : in std_logic_vector (WIDTH-1 downto 0),        -- Input data to load in the counter register
40
                imload  : in std_logic_vector (WIDTH-1 downto 0),        -- Output data to load in the module register (a comparison register)
41
                cload   : in std_logic, --Signal to load in the counter 
42
                mload   : in std_logic, --Signal to load in the module,
43
                enable  : in std_logic, --Signal to start counting,
44
                mod0    : out std_logic_vector -- Counter Value.
45
        );
46
end clearableCounter;
47
 
48
architecture rtl of clearableCounter is
49
 
50
        signal sCounter :  std_logic_vector (WIDTH-1 downto 0);  -- Register where the counting takes place
51
        signal sModule  :  std_logic_vector (WIDTH-1 downto 0);  -- Register where the module is stored
52
 
53
 
54
 
55
begin
56
 
57
 
58
        process (clk,rst)
59
        begin
60
 
61
                if rst='0' then
62
 
63
                        sCounter        <=  (others => '1');
64
                        sModule         <=      (others => '0');
65
                        mod0            <=              '1';
66
                elsif rising_edge (clk) then
67
 
68
                        -- Load a new module
69
                        if mload <='1' then
70
                                sModule <= imload;
71
                        end if;
72
 
73
                        -- Load a new counter
74
                        if cload <='1' then
75
                                sCounter <= icload;
76
                        end if;
77
 
78
                        -- Count Up and Detect Module.
79
                        if enable <='1' then
80
 
81
                                sCounter <= sCounter + 1;
82
                                if sCounter = sModule then
83
                                        mod0 <= '1';
84
                                else
85
                                        mod0 <= '0';
86
                                end if;
87
 
88
                        end if;
89
 
90
        end process;
91
 
92
end rtl;
93
 
94
 

powered by: WebSVN 2.1.0

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