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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [n2h2/] [1.0/] [vhd/] [step_counter2.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Step counter2
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : step_counter2.vhd
6
-- Author     : kulmala3
7
-- Created    : 01.06.2005
8
-- Last update: 21.11.2005
9
-- Description: A simple counter which step size is parametrizable.
10
-- no synch clear.
11
-------------------------------------------------------------------------------
12
-- Copyright (c) 2005 
13
-------------------------------------------------------------------------------
14
-- Revisions  :
15
-- Date        Version  Author  Description
16
-- 01.06.2005  1.0      AK      Created
17
-------------------------------------------------------------------------------
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
use ieee.std_logic_arith.all;
22
use ieee.std_logic_unsigned.all;
23
 
24
entity step_counter2 is
25
 
26
  generic (
27
    step_size_g : integer := 4;
28
    width_g     : integer := 32);
29
 
30
  port (
31
    clk       : in  std_logic;
32
    rst_n     : in  std_logic;
33
    en_in     : in  std_logic;
34
    value_in  : in  std_logic_vector(width_g-1 downto 0);
35
    load_in   : in  std_logic;
36
    value_out : out std_logic_vector(width_g-1 downto 0)
37
    );
38
 
39
end step_counter2;
40
 
41
architecture rtl of step_counter2 is
42
  signal value_r         : std_logic_vector(width_g-1 downto 0);
43
  signal load_en_r : std_logic_vector(1 downto 0);
44
begin  -- rtl
45
  load_en_r <= load_in & en_in;
46
  value_out       <= value_r;
47
 
48
  process (clk, rst_n)
49
  begin  -- process
50
    if rst_n = '0' then                 -- asynchronous reset (active low)
51
      value_r <= (others => '0');
52
 
53
    elsif clk'event and clk = '1' then  -- rising clock edge
54
      case conv_integer(unsigned(load_en_r)) is
55
--        when "1-0" =>
56
        when 2 | 3 =>
57
          value_r <= value_in;
58
 
59
--        when "010" =>
60
        when 1 =>
61
          value_r <= value_r + conv_std_logic_vector(step_size_g, width_g);
62
--        when 0 =>
63
        when others =>
64
          value_r <= value_r;
65
 
66
--        when "--1" =>
67
--        when others =>
68
--          value_r <= (others => '0');
69
 
70
      end case;
71
 
72
 
73
    end if;
74
  end process;
75
 
76
 
77
 
78
end rtl;

powered by: WebSVN 2.1.0

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