OpenCores
URL https://opencores.org/ocsvn/forth-cpu/forth-cpu/trunk

Subversion Repositories forth-cpu

[/] [forth-cpu/] [trunk/] [timer.vhd] - Diff between revs 3 and 5

Show entire file | Details | Blame | View Log

Rev 3 Rev 5
Line 22... Line 22...
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
 
 
library ieee,work,std;
library ieee,work,std;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std.all;
 
use work.util.common_generics;
 
 
entity timer is
entity timer is
        generic(
        generic(
 
                g: common_generics;
                timer_length: positive := 16);
                timer_length: positive := 16);
        port(
        port(
                clk:          in  std_ulogic;
                clk:          in  std_ulogic;
                rst:          in  std_ulogic;
                rst:          in  std_ulogic;
 
 
Line 63... Line 65...
        irq_en      <= control_c(irq_enable_bit);
        irq_en      <= control_c(irq_enable_bit);
        compare     <= control_c(timer_highest_bit downto 0);
        compare     <= control_c(timer_highest_bit downto 0);
 
 
        counter_o   <= std_ulogic_vector(count);
        counter_o   <= std_ulogic_vector(count);
 
 
        clockRegisters: process(clk, rst)
 
        begin
 
                if rst = '1' then
 
                        control_c <= (others => '0');
 
                elsif rising_edge(clk) then
 
                        control_c <= control_n;
 
                end if;
 
        end process;
 
 
 
        counter: process (clk, rst)
        counter: process (clk, rst)
        begin
        begin
                if rst = '1' then
                if rst = '1' and g.asynchronous_reset then
                        count <= (others => '0');
                        count     <= (others => '0') after g.delay;
 
                        control_c <= (others => '0') after g.delay;
                elsif rising_edge(clk) then
                elsif rising_edge(clk) then
 
                        if rst = '1' and not g.asynchronous_reset then
 
                                count     <= (others => '0') after g.delay;
 
                                control_c <= (others => '0') after g.delay;
 
                        else
 
                                control_c <= control_n;
                        if reset_timer = '1' or timer_reset = '1' then
                        if reset_timer = '1' or timer_reset = '1' then
                                count <= (others => '0');
                                        count <= (others => '0') after g.delay;
                        elsif enabled = '1' then
                        elsif enabled = '1' then
                                count <= count + 1;
                                        count <= count + 1 after g.delay;
                        else
                        else
                                count <= count;
                                        count <= count after g.delay;
 
                                end if;
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
        output: process(count, we, control_i, control_c, compare, irq_en, enabled)
        output: process(count, we, control_i, control_c, compare, irq_en, enabled)
        begin
        begin
                irq         <= '0';
 
                control_n   <= control_c;
 
                timer_reset <= '0';
 
 
 
                control_n(timer_reset_bit)  <= '0'; -- reset
 
 
 
                if we = '1' then
                if we = '1' then
                        control_n <= control_i;
                        control_n <= control_i after g.delay;
 
                else
 
                        control_n                   <= control_c after g.delay;
 
                        control_n(timer_reset_bit)  <= '0' after g.delay; -- reset
                end if;
                end if;
 
 
                if count = unsigned(compare) and enabled = '1' then
                if count = unsigned(compare) and enabled = '1' then
                        if irq_en = '1' then
                        irq         <= irq_en after g.delay;
                                irq <= '1';
                        timer_reset <= '1' after g.delay;
                        end if;
                else
                        timer_reset <= '1';
                        irq         <= '0' after g.delay;
 
                        timer_reset <= '0' after g.delay;
                end if;
                end if;
        end process;
        end process;
end architecture;
end architecture;
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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