w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
gray_cnt_n.vhd
Go to the documentation of this file.
1-- $Id: gray_cnt_n.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2007- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: gray_cnt_n - syn
7-- Description: Genric width Gray code counter
8--
9-- Dependencies: -
10-- Test bench: tb/tb_gray_cnt_n
11-- Target Devices: generic
12-- Tool versions: xst 8.1-14.7; ghdl 0.18-0.33
13-- Revision History:
14-- Date Rev Version Comment
15-- 2007-12-26 106 1.0 Initial version
16--
17-- Some synthesis results:
18-- - 2016-03-25 ise 14.7 for xc6slx16-csg324-2:
19-- DWIDTH LUT Flop clock(xst est.)
20-- 4 5 5 421MHz/ 2.37ns
21-- 5 6 6 414MHz/ 2.41ns
22-- 6 8 7 361MHz/ 2.77ns
23-- 8 10 9 321MHz/ 3.11ns
24-- 16 29 17 252MHz/ 3.96ns
25-- 32 70 33 214MHz/ 4.65ns
26-- 64 173 65 176MHz/ 5.66ns
27-- - 2007-12-27 ise 8.2.03 for xc3s1000-ft256-4:
28-- DWIDTH LUT Flop clock(xst est.)
29-- 4 6 5 305MHz/ 3.28ns
30-- 5 8 6 286MHz/ 2.85ns
31-- 8 13 9 234MHz/ 4.26ns
32-- 16 56 17 149MHz/ 6.67ns
33-- 32 95 33 161MHz/ 6.19ns
34-- 64 188 68 126MHz/ 7.90ns
35------------------------------------------------------------------------------
36
37library ieee;
38use ieee.std_logic_1164.all;
39
40use work.slvtypes.all;
41
42entity gray_cnt_n is -- n bit gray code counter
43 generic (
44 DWIDTH : positive := 8); -- data width
45 port (
46 CLK : in slbit; -- clock
47 RESET : in slbit := '0'; -- reset
48 CE : in slbit := '1'; -- count enable
49 DATA : out slv(DWIDTH-1 downto 0) -- data out
50 );
51end entity gray_cnt_n;
52
53
54architecture syn of gray_cnt_n is
55
56 signal R_AUX : slbit := '1';
57 signal R_DATA : slv(DWIDTH-1 downto 0) := (others=>'0');
58 signal N_DATA : slv(DWIDTH-1 downto 0) := (others=>'0');
59
60begin
61
62 assert DWIDTH>=3
63 report "assert(DWIDTH>=3): only 3 bit or larger supported"
64 severity failure;
65
66 proc_regs: process (CLK)
67 begin
68
69 if rising_edge(CLK) then
70 if RESET = '1' then
71 R_AUX <= '1';
72 R_DATA <= (others=>'0');
73 elsif CE = '1' then
74 R_AUX <= not R_AUX;
75 R_DATA <= N_DATA;
76 end if;
77 end if;
78 end process proc_regs;
79
80 proc_next: process (R_AUX, R_DATA)
81 variable r : slv(DWIDTH-1 downto 0) := (others=>'0');
82 variable n : slv(DWIDTH-1 downto 0) := (others=>'0');
83 variable s : slbit := '0';
84 begin
85
86 r := R_DATA;
87 n := R_DATA;
88 s := '1';
89
90 if R_AUX = '1' then
91 n(0) := not r(0);
92 else
93 for i in 1 to DWIDTH-2 loop
94 if s='1' and r(i-1)='1' then
95 n(i) := not r(i);
96 end if;
97 s := s and not r(i-1);
98 end loop;
99 if s = '1' then
100 n(DWIDTH-1) := r(DWIDTH-2);
101 end if;
102 end if;
103
104 N_DATA <= n;
105
106 end process proc_next;
107
108 DATA <= R_DATA;
109
110end syn;
111
slv( DWIDTH- 1 downto 0) :=( others => '0') N_DATA
Definition: gray_cnt_n.vhd:58
slbit := '1' R_AUX
Definition: gray_cnt_n.vhd:56
slv( DWIDTH- 1 downto 0) :=( others => '0') R_DATA
Definition: gray_cnt_n.vhd:57
DWIDTH positive := 8
Definition: gray_cnt_n.vhd:44
in CE slbit := '1'
Definition: gray_cnt_n.vhd:48
in CLK slbit
Definition: gray_cnt_n.vhd:46
out DATA slv( DWIDTH- 1 downto 0)
Definition: gray_cnt_n.vhd:50
in RESET slbit := '0'
Definition: gray_cnt_n.vhd:47
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31