w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
gray_cnt_5.vhd
Go to the documentation of this file.
1-- $Id: gray_cnt_5.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2007-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: gray_cnt_5 - syn
7-- Description: 5 bit Gray code counter (ROM based)
8--
9-- Dependencies: -
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: xst 8.1-14.7; viv 2014.4-2016.4; ghdl 0.18-0.33
13-- Revision History:
14-- Date Rev Version Comment
15-- 2017-01-07 840 1.1 disable fsm recognition in vivado
16-- 2007-12-26 106 1.0 Initial version
17--
18-- Some synthesis results:
19-- - 2007-12-27 ise 8.2.03 for xc3s1000-ft256-4:
20-- LUT Flop clock(xst est.)
21-- 9 5 302MHz/ 3.31ns
22------------------------------------------------------------------------------
23
24library ieee;
25use ieee.std_logic_1164.all;
26
27use work.slvtypes.all;
28
29entity gray_cnt_5 is -- 5 bit gray code counter (ROM based)
30 port (
31 CLK : in slbit; -- clock
32 RESET : in slbit := '0'; -- reset
33 CE : in slbit := '1'; -- count enable
34 DATA : out slv5 -- data out
35 );
36end entity gray_cnt_5;
37
38
39architecture syn of gray_cnt_5 is
40
41 signal R_DATA : slv5 := (others=>'0');
42 signal N_DATA : slv5 := (others=>'0');
43
44 -- Note: in xst 8.2.03 fsm_extract="no" is needed. Otherwise an fsm
45 -- is inferred, using 'Johnson' encoding. DATA will be deduced
46 -- in a combinatorial logic, and will thus have very likely some
47 -- glitches at the clock transitions, rendering the whole Gray
48 -- coding useless.
49
50 attribute fsm_extract : string;
51 attribute fsm_extract of R_DATA : signal is "no";
52 attribute rom_style : string;
53 attribute rom_style of N_DATA : signal is "distributed";
54
55 -- Note: vivado started with -fsm_extraction one_hot didn't fsm recognize
56 -- this code up to 2016.2. With 2016.3 and later it is converted into a
57 -- 31 state one-hot fsm, unless explicitely suppressed
58 attribute fsm_encoding : string;
59 attribute fsm_encoding of R_DATA : signal is "none";
60
61begin
62
63 proc_regs: process (CLK)
64 begin
65
66 if rising_edge(CLK) then
67 if RESET = '1' then
68 R_DATA <= (others=>'0');
69 elsif CE = '1' then
70 R_DATA <= N_DATA;
71 end if;
72 end if;
73 end process proc_regs;
74
75 proc_next: process (R_DATA)
76 begin
77
78 N_DATA <= (others=>'0');
79 case R_DATA is
80 when "00000" => N_DATA <= "00001"; -- 0
81 when "00001" => N_DATA <= "00011"; -- 1
82 when "00011" => N_DATA <= "00010"; -- 2
83 when "00010" => N_DATA <= "00110"; -- 3
84 when "00110" => N_DATA <= "00111"; -- 4
85 when "00111" => N_DATA <= "00101"; -- 5
86 when "00101" => N_DATA <= "00100"; -- 6
87 when "00100" => N_DATA <= "01100"; -- 7
88 when "01100" => N_DATA <= "01101"; -- 8
89 when "01101" => N_DATA <= "01111"; -- 9
90 when "01111" => N_DATA <= "01110"; -- 10
91 when "01110" => N_DATA <= "01010"; -- 11
92 when "01010" => N_DATA <= "01011"; -- 12
93 when "01011" => N_DATA <= "01001"; -- 13
94 when "01001" => N_DATA <= "01000"; -- 14
95 when "01000" => N_DATA <= "11000"; -- 15
96 when "11000" => N_DATA <= "11001"; -- 16
97 when "11001" => N_DATA <= "11011"; -- 17
98 when "11011" => N_DATA <= "11010"; -- 18
99 when "11010" => N_DATA <= "11110"; -- 19
100 when "11110" => N_DATA <= "11111"; -- 20
101 when "11111" => N_DATA <= "11101"; -- 21
102 when "11101" => N_DATA <= "11100"; -- 22
103 when "11100" => N_DATA <= "10100"; -- 23
104 when "10100" => N_DATA <= "10101"; -- 24
105 when "10101" => N_DATA <= "10111"; -- 25
106 when "10111" => N_DATA <= "10110"; -- 26
107 when "10110" => N_DATA <= "10010"; -- 27
108 when "10010" => N_DATA <= "10011"; -- 28
109 when "10011" => N_DATA <= "10001"; -- 29
110 when "10001" => N_DATA <= "10000"; -- 30
111 when "10000" => N_DATA <= "00000"; -- 31
112 when others => null;
113 end case;
114 end process proc_next;
115
116 DATA <= R_DATA;
117
118end syn;
119
string rom_style
Definition: gray_cnt_5.vhd:52
slv5 :=( others => '0') R_DATA
Definition: gray_cnt_5.vhd:41
string fsm_encoding
Definition: gray_cnt_5.vhd:58
slv5 :=( others => '0') N_DATA
Definition: gray_cnt_5.vhd:42
string fsm_extract
Definition: gray_cnt_5.vhd:50
in CE slbit := '1'
Definition: gray_cnt_5.vhd:33
out DATA slv5
Definition: gray_cnt_5.vhd:35
in CLK slbit
Definition: gray_cnt_5.vhd:31
in RESET slbit := '0'
Definition: gray_cnt_5.vhd:32
std_logic_vector( 4 downto 0) slv5
Definition: slvtypes.vhd:37
std_logic slbit
Definition: slvtypes.vhd:30