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

Subversion Repositories vg_z80_sbc

[/] [vg_z80_sbc/] [trunk/] [rtl/] [ctrm.vhd] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 hharte
-- Hi Emacs, this is -*- mode: vhdl; -*-
2
----------------------------------------------------------------------------------------------------
3
--
4
-- Up Syncronous counter of N bits with a/syncronous reset
5
--
6
-- Copyright (c) 2007 Javier Valcarce García, javier.valcarce@gmail.com
7
-- $Id: ctrm.vhd,v 1.1 2008-12-01 02:00:10 hharte Exp $
8
--
9
----------------------------------------------------------------------------------------------------
10
-- This program is free software: you can redistribute it and/or modify
11
-- it under the terms of the GNU Lesser 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
-- This program 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 Lesser General Public License for more details.
19
--
20
-- You should have received a copy of the GNU Lesser General Public License
21
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
----------------------------------------------------------------------------------------------------
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.numeric_std.all;
26
 
27
 
28
entity ctrm is
29
  generic (
30
    M : integer := 08);
31
  port (
32
    reset : in  std_logic;              -- asyncronous reset
33
    clk   : in  std_logic;
34
    ce    : in  std_logic;              -- enable counting
35
    rs    : in  std_logic;              -- syncronous reset
36
    do    : out integer range (M-1) downto 0
37
    );
38
end ctrm;
39
 
40
-------------------------------------------------------------------------------
41
-------------------------------------------------------------------------------
42
architecture arch of ctrm is
43
  signal c : integer range (M-1) downto 0;
44
begin
45
 
46
  do <= c;
47
 
48
  process(reset, clk)
49
  begin
50
    if reset = '1' then
51
      c <= 0;
52
 
53
    elsif rising_edge(clk) then
54
      if ce = '1' then
55
        if rs = '1' then
56
          c <= 0;
57
        else
58
          c <= c + 1;
59
        end if;
60
      end if;
61
    end if;
62
  end process;
63
 
64
end arch;

powered by: WebSVN 2.1.0

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