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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [genlib/] [gray_cnt_4.vhd] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 wfjm
-- $Id: gray_cnt_4.vhd 418 2011-10-23 20:11:40Z mueller $
2
--
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_4 - syn
16
-- Description:    4 bit Gray code counter (ROM based)
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
22
-- 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
--     4    4   365MHz/ 2.76ns
30
------------------------------------------------------------------------------
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
 
35
use work.slvtypes.all;
36
 
37
entity gray_cnt_4 is                    -- 4 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 slv4                     -- data out
43
  );
44
end entity gray_cnt_4;
45
 
46
 
47
architecture syn of gray_cnt_4 is
48
 
49
  signal R_DATA : slv4 := (others=>'0');
50
  signal N_DATA : slv4 := (others=>'0');
51
 
52
  -- Note: in xst 8.2.03 fsm_extract="no" is needed. Otherwise an fsm is
53
  --       inferred. For 4 bit the coding was 'Gray', but see remarks in
54
  --       gray_cnt_5. To be save, disallow fsm inferal, enforce reg+rom.
55
 
56
  attribute fsm_extract : string;
57
  attribute fsm_extract of R_DATA : signal is "no";
58
  attribute rom_style : string;
59
  attribute rom_style of N_DATA : signal is "distributed";
60
 
61
begin
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 "0000" => N_DATA <= "0001";    --  0
81
      when "0001" => N_DATA <= "0011";    --  1
82
      when "0011" => N_DATA <= "0010";    --  2
83
      when "0010" => N_DATA <= "0110";    --  3
84
      when "0110" => N_DATA <= "0111";    --  4
85
      when "0111" => N_DATA <= "0101";    --  5
86
      when "0101" => N_DATA <= "0100";    --  6
87
      when "0100" => N_DATA <= "1100";    --  7
88
      when "1100" => N_DATA <= "1101";    --  8
89
      when "1101" => N_DATA <= "1111";    --  9
90
      when "1111" => N_DATA <= "1110";    -- 10
91
      when "1110" => N_DATA <= "1010";    -- 11
92
      when "1010" => N_DATA <= "1011";    -- 12
93
      when "1011" => N_DATA <= "1001";    -- 13
94
      when "1001" => N_DATA <= "1000";    -- 14
95
      when "1000" => N_DATA <= "0000";    -- 15
96
      when others => null;
97
    end case;
98
  end process proc_next;
99
 
100
  DATA <= R_DATA;
101
 
102
end syn;
103
 

powered by: WebSVN 2.1.0

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