Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (3.24 KB)

1
-------------------------------------------------------------------------------------------------
2
-- Company   : CNES
3
-- Author    : Mickael Carl (CNES)
4
-- Copyright : Copyright (c) CNES.
5
-- Licensing : GNU GPLv3
6
-------------------------------------------------------------------------------------------------
7
-- Version         : V1.1
8
-- Version history :
9
--    V1   : 2015-04-07 : Mickael Carl (CNES): Creation
10
--    V1.1 : 2016-05-03 : F.Manni (CNES) : add initialization for D_re
11
-------------------------------------------------------------------------------------------------
12
-- File name          : STD_03600_bad.vhd
13
-- File Creation date : 2015-04-07
14
-- Project name       : VHDL Handbook CNES Edition
15
-------------------------------------------------------------------------------------------------
16
-- Softwares             :  Microsoft Windows (Windows 7) - Editor (Eclipse + VEditor)
17
-------------------------------------------------------------------------------------------------
18
-- Description : Handbook example: Reset sensitive level: bad example
19
--
20
-- Limitations : This file is an example of the VHDL handbook made by CNES. It is a stub aimed at
21
--               demonstrating good practices in VHDL and as such, its design is minimalistic.
22
--               It is provided as is, without any warranty.
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

    
52
entity STD_03600_bad is
53
   port (
54
      i_Reset_n : in  std_logic;        -- Reset signal
55
      i_Clock   : in  std_logic;        -- Clock signal
56
      i_D       : in  std_logic;        -- Async signal
57
      o_Q       : out std_logic         -- Rising edge of i_D
58
      );
59
end STD_03600_bad;
60

    
61
--CODE
62
architecture Behavioral of STD_03600_bad is
63
   signal D_r1  : std_logic;            -- D signal registered 1 time
64
   signal D_r2  : std_logic;            -- D signal registered 2 times
65
   signal D_re  : std_logic;            -- Module output
66
   signal Reset : std_logic;            -- Reset signal (active high)
67
begin
68
   P_First_Register : process(i_Reset_n, i_Clock)
69
   begin
70
      if (i_Reset_n = '0') then
71
         D_r1 <= '0';
72
      elsif (rising_edge(i_Clock)) then
73
            D_r1 <= i_D;
74
      end if;
75
   end process;
76

    
77
   Reset <= not i_Reset_n;
78

    
79
   P_Second_Register : process(Reset, i_Clock)
80
   begin
81
      if (Reset = '1') then
82
         D_r2 <= '0';
83
         D_re <= '0';
84
      elsif (rising_edge(i_Clock)) then
85
            D_r2 <= D_r1;
86
            D_re <= D_r1 and not D_r2;
87
      end if;
88
   end process;
89

    
90
   o_Q <= D_re;
91
end Behavioral;
92
--CODE