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

Subversion Repositories pulse_processing_algorithm

[/] [pulse_processing_algorithm/] [wr_gray_cntr.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 panda_emc
-- fifo_wr_addr gray counter with synchronous reset
2
 
3
LIBRARY ieee;
4
USE ieee.std_logic_1164.all;
5
USE ieee.std_logic_arith.all;
6
 
7
-- pragma translate_off
8
library UNISIM;
9
use UNISIM.VCOMPONENTS.ALL;
10
-- pragma translate_on
11
--
12
 
13
 
14
ENTITY wr_gray_cntr IS
15
        port (
16
                        clk                             :       in std_logic;
17
                        reset                           :       in std_logic;
18
                        cnt_en                          :       in std_logic;
19
                        wgc_gcnt                        :       out     std_logic_vector(3 downto 0)
20
 
21
                  );
22
END wr_gray_cntr ;
23
 
24
ARCHITECTURE wr_gray_cntr OF wr_gray_cntr IS
25
 
26
component FDCE
27
    port(
28
      Q                              :  out   STD_ULOGIC;
29
      C                              :  in    STD_ULOGIC;
30
      CE                             :  in    STD_ULOGIC;
31
      CLR                            :  in    STD_ULOGIC;
32
      D                              :  in    STD_ULOGIC
33
      );
34
end component;
35
 
36
-- gray encoded signals
37
 
38
signal  d0      :       STD_ULOGIC;
39
signal  d1      :       STD_ULOGIC;
40
signal  d2      :       STD_ULOGIC;
41
signal  d3      :       STD_ULOGIC;
42
signal  gc_int :  std_logic_vector(3 downto 0);
43
 
44
BEGIN
45
 
46
    wgc_gcnt <= gc_int(3 downto 0);
47
 
48
    d0 <=  ( (not gc_int(3)) and (not gc_int(2)) and (not gc_int(1)) ) or ( gc_int(3) and gc_int(2) and (not gc_int(1)) ) or ( gc_int(3) and (not gc_int(2)) and gc_int(1) ) or ( (not gc_int(3)) and gc_int(2) and gc_int(1) );
49
---    d0 <= ( not gc_int(1) and ( gc_int(3) xnor gc_int(2))) or (gc_int(1) and ( gc_int(3) xor gc_int(2)));
50
    d1 <= ( gc_int(1) and (not gc_int(0)) ) or ( (not gc_int(3)) and (not gc_int(2)) and gc_int(0) ) or ( gc_int(3) and gc_int(2) and gc_int(0) );
51
    d2 <= ( (not gc_int(3)) and gc_int(1) and (not gc_int(0)) ) or ( gc_int(2) and (not gc_int(1)) ) or ( gc_int(2) and gc_int(0) );
52
    d3 <= ( gc_int(2) and (not gc_int(1)) and (not gc_int(0)) ) or ( gc_int(3) and gc_int(0) ) or ( gc_int(3) and gc_int(1) );
53
 
54
 
55
bit0 : FDCE port map (
56
                      Q   => gc_int(0),
57
                      C   => clk,
58
                      CE  => cnt_en,
59
                      CLR => reset,
60
                      D   => d0
61
                     );
62
 
63
bit1 : FDCE port map (
64
                      Q   => gc_int(1),
65
                      C   => clk,
66
                      CE  => cnt_en,
67
                      CLR => reset,
68
                      D   => d1
69
                     );
70
 
71
bit2 : FDCE port map (
72
                      Q   => gc_int(2),
73
                      C   => clk,
74
                      CE  => cnt_en,
75
                      CLR => reset,
76
                      D   => d2
77
                     );
78
 
79
bit3 : FDCE port map (
80
                      Q   => gc_int(3),
81
                      C   => clk,
82
                      CE  => cnt_en,
83
                      CLR => reset,
84
                      D   => d3
85
                     );
86
 
87
 
88
END wr_gray_cntr;

powered by: WebSVN 2.1.0

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