1 |
36 |
wfjm |
-- $Id: gray_cnt_5.vhd 751 2016-03-25 19:46:11Z mueller $
|
2 |
16 |
wfjm |
--
|
3 |
|
|
-- Copyright 2007- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
-- the terms of the GNU General Public License as published by the Free
|
7 |
|
|
-- Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
--
|
9 |
|
|
-- This program is distributed in the hope that it will be useful, but
|
10 |
|
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
-- for complete details.
|
13 |
|
|
--
|
14 |
|
|
------------------------------------------------------------------------------
|
15 |
|
|
-- Module Name: gray_cnt_5 - syn
|
16 |
|
|
-- Description: 5 bit Gray code counter (ROM based)
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: -
|
19 |
|
|
-- Test bench: -
|
20 |
|
|
-- Target Devices: generic
|
21 |
36 |
wfjm |
-- Tool versions: xst 8.1-14.7; viv 2014.4-2015.4; ghdl 0.18-0.33
|
22 |
16 |
wfjm |
-- Revision History:
|
23 |
|
|
-- Date Rev Version Comment
|
24 |
|
|
-- 2007-12-26 106 1.0 Initial version
|
25 |
|
|
--
|
26 |
|
|
-- Some synthesis results:
|
27 |
|
|
-- - 2007-12-27 ise 8.2.03 for xc3s1000-ft256-4:
|
28 |
|
|
-- LUT Flop clock(xst est.)
|
29 |
|
|
-- 9 5 302MHz/ 3.31ns
|
30 |
|
|
------------------------------------------------------------------------------
|
31 |
|
|
|
32 |
|
|
library ieee;
|
33 |
|
|
use ieee.std_logic_1164.all;
|
34 |
|
|
|
35 |
|
|
use work.slvtypes.all;
|
36 |
|
|
|
37 |
|
|
entity gray_cnt_5 is -- 5 bit gray code counter (ROM based)
|
38 |
|
|
port (
|
39 |
|
|
CLK : in slbit; -- clock
|
40 |
|
|
RESET : in slbit := '0'; -- reset
|
41 |
|
|
CE : in slbit := '1'; -- count enable
|
42 |
|
|
DATA : out slv5 -- data out
|
43 |
|
|
);
|
44 |
|
|
end entity gray_cnt_5;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
architecture syn of gray_cnt_5 is
|
48 |
|
|
|
49 |
|
|
signal R_DATA : slv5 := (others=>'0');
|
50 |
|
|
signal N_DATA : slv5 := (others=>'0');
|
51 |
|
|
|
52 |
|
|
-- Note: in xst 8.2.03 fsm_extract="no" is needed. Otherwise an fsm
|
53 |
|
|
-- is inferred, using 'Johnson' encoding. DATA will be deduced
|
54 |
|
|
-- in a combinatorial logic, and will thus have very likely some
|
55 |
|
|
-- glitches at the clock transitions, rendering the whole Gray
|
56 |
|
|
-- coding useless.
|
57 |
|
|
|
58 |
|
|
attribute fsm_extract : string;
|
59 |
|
|
attribute fsm_extract of R_DATA : signal is "no";
|
60 |
|
|
attribute rom_style : string;
|
61 |
|
|
attribute rom_style of N_DATA : signal is "distributed";
|
62 |
|
|
|
63 |
|
|
begin
|
64 |
|
|
|
65 |
|
|
proc_regs: process (CLK)
|
66 |
|
|
begin
|
67 |
|
|
|
68 |
|
|
if rising_edge(CLK) then
|
69 |
|
|
if RESET = '1' then
|
70 |
|
|
R_DATA <= (others=>'0');
|
71 |
|
|
elsif CE = '1' then
|
72 |
|
|
R_DATA <= N_DATA;
|
73 |
|
|
end if;
|
74 |
|
|
end if;
|
75 |
|
|
end process proc_regs;
|
76 |
|
|
|
77 |
|
|
proc_next: process (R_DATA)
|
78 |
|
|
begin
|
79 |
|
|
|
80 |
|
|
N_DATA <= (others=>'0');
|
81 |
|
|
case R_DATA is
|
82 |
|
|
when "00000" => N_DATA <= "00001"; -- 0
|
83 |
|
|
when "00001" => N_DATA <= "00011"; -- 1
|
84 |
|
|
when "00011" => N_DATA <= "00010"; -- 2
|
85 |
|
|
when "00010" => N_DATA <= "00110"; -- 3
|
86 |
|
|
when "00110" => N_DATA <= "00111"; -- 4
|
87 |
|
|
when "00111" => N_DATA <= "00101"; -- 5
|
88 |
|
|
when "00101" => N_DATA <= "00100"; -- 6
|
89 |
|
|
when "00100" => N_DATA <= "01100"; -- 7
|
90 |
|
|
when "01100" => N_DATA <= "01101"; -- 8
|
91 |
|
|
when "01101" => N_DATA <= "01111"; -- 9
|
92 |
|
|
when "01111" => N_DATA <= "01110"; -- 10
|
93 |
|
|
when "01110" => N_DATA <= "01010"; -- 11
|
94 |
|
|
when "01010" => N_DATA <= "01011"; -- 12
|
95 |
|
|
when "01011" => N_DATA <= "01001"; -- 13
|
96 |
|
|
when "01001" => N_DATA <= "01000"; -- 14
|
97 |
|
|
when "01000" => N_DATA <= "11000"; -- 15
|
98 |
|
|
when "11000" => N_DATA <= "11001"; -- 16
|
99 |
|
|
when "11001" => N_DATA <= "11011"; -- 17
|
100 |
|
|
when "11011" => N_DATA <= "11010"; -- 18
|
101 |
|
|
when "11010" => N_DATA <= "11110"; -- 19
|
102 |
|
|
when "11110" => N_DATA <= "11111"; -- 20
|
103 |
|
|
when "11111" => N_DATA <= "11101"; -- 21
|
104 |
|
|
when "11101" => N_DATA <= "11100"; -- 22
|
105 |
|
|
when "11100" => N_DATA <= "10100"; -- 23
|
106 |
|
|
when "10100" => N_DATA <= "10101"; -- 24
|
107 |
|
|
when "10101" => N_DATA <= "10111"; -- 25
|
108 |
|
|
when "10111" => N_DATA <= "10110"; -- 26
|
109 |
|
|
when "10110" => N_DATA <= "10010"; -- 27
|
110 |
|
|
when "10010" => N_DATA <= "10011"; -- 28
|
111 |
|
|
when "10011" => N_DATA <= "10001"; -- 29
|
112 |
|
|
when "10001" => N_DATA <= "10000"; -- 30
|
113 |
|
|
when "10000" => N_DATA <= "00000"; -- 31
|
114 |
|
|
when others => null;
|
115 |
|
|
end case;
|
116 |
|
|
end process proc_next;
|
117 |
|
|
|
118 |
|
|
DATA <= R_DATA;
|
119 |
|
|
|
120 |
|
|
end syn;
|
121 |
|
|
|