Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / vhdl_json / vhdl_files / 2-exportOK / cnes_guidelines / rule / data / STD_05700_bad.vhd @ 2051e520

History | View | Annotate | Download (3.43 KB)

1
-------------------------------------------------------------------------------------------------
2
-- Company   : CNES
3
-- Author    : Mickael Carl (CNES)
4
-- Copyright : Copyright (c) CNES.
5
-- Licensing : GNU GPLv3
6
-------------------------------------------------------------------------------------------------
7
-- Version         : V1
8
-- Version history :
9
--    V1 : 2015-04-08 : Mickael Carl (CNES): Creation
10
-------------------------------------------------------------------------------------------------
11
-- File name          : STD_05700_bad.vhd
12
-- File Creation date : 2015-04-08
13
-- Project name       : VHDL Handbook CNES Edition
14
-------------------------------------------------------------------------------------------------
15
-- Softwares             :  Microsoft Windows (Windows 7) - Editor (Eclipse + VEditor)
16
-------------------------------------------------------------------------------------------------
17
-- Description : Handbook example: Unsuitability of gated clocks: bad example
18
--
19
-- Limitations : This file is an example of the VHDL handbook made by CNES. It is a stub aimed at
20
--               demonstrating good practices in VHDL and as such, its design is minimalistic.
21
--               It is provided as is, without any warranty.
22
--               This example is compliant with the Handbook version 1.
23
--
24
-------------------------------------------------------------------------------------------------
25
-- Naming conventions:
26
--
27
-- i_Port: Input entity port
28
-- o_Port: Output entity port
29
-- b_Port: Bidirectional entity port
30
-- g_My_Generic: Generic entity port
31
--
32
-- c_My_Constant: Constant definition
33
-- t_My_Type: Custom type definition
34
--
35
-- My_Signal_n: Active low signal
36
-- v_My_Variable: Variable
37
-- sm_My_Signal: FSM signal
38
-- pkg_Param: Element Param coming from a package
39
--
40
-- My_Signal_re: Rising edge detection of My_Signal
41
-- My_Signal_fe: Falling edge detection of My_Signal
42
-- My_Signal_rX: X times registered My_Signal signal
43
--
44
-- P_Process_Name: Process
45
--
46
-------------------------------------------------------------------------------------------------
47

    
48
library IEEE;
49
use IEEE.std_logic_1164.all;
50
use IEEE.numeric_std.all;
51
use work.pkg_HBK.all;
52

    
53
--CODE
54
entity STD_05700_bad is
55
   port (
56
      i_Clock       : in  std_logic;    -- Clock signal
57
      i_Reset_n     : in  std_logic;    -- Reset signal
58
      i_Enable      : in  std_logic;    -- Enable signal
59
      i_Data        : in  std_logic;    -- Input data
60
      o_Data        : out std_logic;    -- Output data
61
      o_Gated_Clock : out std_logic     -- Gated clock
62
      );
63
end STD_05700_bad;
64

    
65
architecture Behavioral of STD_05700_bad is
66
   signal Enable_r    : std_logic;
67
   signal Gated_Clock : std_logic;
68
   signal Data_r      : std_logic;      -- Data signal registered
69
   signal Data_r2     : std_logic;      -- Data signal registered twice
70

    
71
begin
72
   DFF_En : DFlipFlop
73
      port map (
74
         i_Clock   => i_Clock,
75
         i_Reset_n => i_Reset_n,
76
         i_D       => i_Enable,
77
         o_Q       => Enable_r,
78
         o_Q_n     => open
79
         );
80
   -- Make the Flip-Flop work when Enable signal is at 1
81
   -- Enable signal on clock path
82
   Gated_Clock <= i_Clock and Enable_r;
83
   P_Sync_Data : process(i_Reset_n, Gated_Clock)
84
   begin
85
      if (i_Reset_n = '0') then
86
         Data_r  <= '0';
87
         Data_r2 <= '0';
88
      elsif (rising_edge(Gated_Clock)) then
89
            Data_r  <= i_Data;
90
            Data_r2 <= Data_r;
91
      end if;
92
   end process;
93

    
94
   o_Data <= Data_r2;
95
end Behavioral;
96
--CODE