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

Subversion Repositories zpu

[/] [zpu/] [trunk/] [zpu/] [zpu4/] [src/] [timer.vhd] - Blame information for rev 93

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 93 oharboe
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
entity timer is
6
  port(
7
       clk              : in std_logic;
8
                 areset                         : in std_logic;
9
                 we                                     : in std_logic;
10
                 din                                    : in std_logic_vector(7 downto 0);
11
                 adr                                    : in std_logic_vector(2 downto 0);
12
                 dout                                   : out std_logic_vector(7 downto 0));
13
end timer;
14
 
15
 
16
architecture behave of timer is
17
 
18
signal  sample  : std_logic;
19
signal  reset           : std_logic;
20
 
21
 
22
signal  cnt             : unsigned(63 downto 0);
23
signal  cnt_smp : std_logic_vector(63 downto 0);
24
 
25
begin
26
 
27
        reset <= '1' when (we = '1' and din(0) = '1') else '0';
28
        sample <= '1' when (we = '1' and din(1) = '1') else '0';
29
 
30
        process(clk, areset)    -- Carry generation
31
        begin
32
                if areset = '1' then
33
                        cnt <= (others => '0');
34
                        cnt_smp <= (others => '0');
35
                elsif (clk'event and clk = '1') then
36
                        cnt <= cnt + 1;
37
                        if sample = '1' then
38
--                              report "sampling" severity failure;
39
                                cnt_smp <= std_logic_vector(cnt);
40
                        end if;
41
                end if;
42
        end process;
43
 
44
 
45
        process(cnt_smp, adr)
46
        begin
47
                case adr is
48
                        when "000"      => dout <= cnt_smp(7 downto 0);
49
                        when "001"      => dout <= cnt_smp(15 downto 8);
50
                        when "010"      => dout <= cnt_smp(23 downto 16);
51
                        when "011"      => dout <= cnt_smp(31 downto 24);
52
                        when "100"      => dout <= cnt_smp(39 downto 32);
53
                        when "101"      => dout <= cnt_smp(47 downto 40);
54
                        when "110"      => dout <= cnt_smp(55 downto 48);
55
                        when others     => dout <= cnt_smp(63 downto 56);
56
                end case;
57
        end process;
58
 
59
 
60
end behave;
61
 

powered by: WebSVN 2.1.0

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