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

Subversion Repositories ofdm

[/] [ofdm/] [branches/] [avendor/] [counter.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 tmsiqueira
 
2
library IEEE;
3
use IEEE.STD_LOGIC_1164.ALL;
4
use IEEE.STD_LOGIC_ARITH.ALL;
5
use IEEE.STD_LOGIC_UNSIGNED.ALL;
6
 
7
 
8
entity counter is
9
 
10
  generic (
11
    stage : natural := 3);
12
 
13
  port (
14
    clk       : in  std_logic;
15
    rst       : in  std_logic;
16
    mem_ready : in  std_logic;
17
    mem_bk : out std_logic;
18
    count      : out std_logic_vector(2*stage+2 downto 0));
19
 
20
end counter;
21
 
22
architecture counter of counter is
23
 
24
signal aux_mem_bk : std_logic;
25
signal count_aux : std_logic_vector(2*stage+2 downto 0);
26
constant max_count : std_logic_vector(2*stage+2 downto 0) := conv_std_logic_vector(stage-1,3)&conv_std_logic_vector(-1,2*stage);
27
 
28
 
29
begin
30
  count <=  count_aux;
31
  mem_bk <= aux_mem_bk;
32
 
33
process (clk, rst)
34
    variable initialize : std_logic_vector(1 downto 0);
35
  begin  -- process
36
    if rst = '1' then                   -- asynchronous reset (active low)
37
      count_aux <= max_count;
38
                aux_mem_bk <= '1';
39
    elsif clk'event and clk = '1' then  -- rising clock edge
40
      if count_aux = max_count then
41
        if mem_ready = '1' then
42
          aux_mem_bk <= not(aux_mem_bk);
43
          count_aux <= (others => '0');
44
        end if;
45
      else
46
        count_aux <= count_aux + 1;
47
      end if;
48
    end if;
49
  end process;
50
 
51
end counter;

powered by: WebSVN 2.1.0

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