1 |
d93979b7
|
Arnaud Dieumegard
|
-------------------------------------------------------------------------------------------------
|
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-07 : Mickael Carl (CNES): Creation
|
10 |
|
|
-------------------------------------------------------------------------------------------------
|
11 |
|
|
-- File name : STD_03600_good.vhd
|
12 |
|
|
-- File Creation date : 2015-04-07
|
13 |
|
|
-- Project name : VHDL Handbook CNES Edition
|
14 |
|
|
-------------------------------------------------------------------------------------------------
|
15 |
|
|
-- Softwares : Microsoft Windows (Windows 7) - Editor (Eclipse + VEditor)
|
16 |
|
|
-------------------------------------------------------------------------------------------------
|
17 |
|
|
-- Description : Handbook example: Reset sensitive level: good 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 |
|
|
--
|
23 |
|
|
-------------------------------------------------------------------------------------------------
|
24 |
|
|
-- Naming conventions:
|
25 |
|
|
--
|
26 |
|
|
-- i_Port: Input entity port
|
27 |
|
|
-- o_Port: Output entity port
|
28 |
|
|
-- b_Port: Bidirectional entity port
|
29 |
|
|
-- g_My_Generic: Generic entity port
|
30 |
|
|
--
|
31 |
|
|
-- c_My_Constant: Constant definition
|
32 |
|
|
-- t_My_Type: Custom type definition
|
33 |
|
|
--
|
34 |
|
|
-- My_Signal_n: Active low signal
|
35 |
|
|
-- v_My_Variable: Variable
|
36 |
|
|
-- sm_My_Signal: FSM signal
|
37 |
|
|
-- pkg_Param: Element Param coming from a package
|
38 |
|
|
--
|
39 |
|
|
-- My_Signal_re: Rising edge detection of My_Signal
|
40 |
|
|
-- My_Signal_fe: Falling edge detection of My_Signal
|
41 |
|
|
-- My_Signal_rX: X times registered My_Signal signal
|
42 |
|
|
--
|
43 |
|
|
-- P_Process_Name: Process
|
44 |
|
|
--
|
45 |
|
|
-------------------------------------------------------------------------------------------------
|
46 |
|
|
|
47 |
|
|
library IEEE;
|
48 |
|
|
use IEEE.std_logic_1164.all;
|
49 |
|
|
use IEEE.numeric_std.all;
|
50 |
|
|
|
51 |
|
|
entity STD_03600_good is
|
52 |
|
|
port (
|
53 |
|
|
i_Reset_n : in std_logic; -- Reset signal
|
54 |
|
|
i_Clock : in std_logic; -- Clock signal
|
55 |
|
|
i_D : in std_logic; -- Async signal
|
56 |
|
|
o_Q : out std_logic -- Rising edge of i_D
|
57 |
|
|
);
|
58 |
|
|
end STD_03600_good;
|
59 |
|
|
|
60 |
|
|
--CODE
|
61 |
|
|
architecture Behavioral of STD_03600_good is
|
62 |
|
|
signal D_r1 : std_logic; -- D signal registered 1 time
|
63 |
|
|
signal D_r2 : std_logic; -- D signal registered 2 times
|
64 |
|
|
signal D_re : std_logic; -- Module output
|
65 |
|
|
begin
|
66 |
|
|
P_First_Register : process(i_Reset_n, i_Clock)
|
67 |
|
|
begin
|
68 |
|
|
if (i_Reset_n = '0') then
|
69 |
|
|
D_r1 <= '0';
|
70 |
|
|
elsif (rising_edge(i_Clock)) then
|
71 |
|
|
D_r1 <= i_D;
|
72 |
|
|
end if;
|
73 |
|
|
end process;
|
74 |
|
|
|
75 |
|
|
P_Second_Register : process(i_Reset_n, i_Clock)
|
76 |
|
|
begin
|
77 |
|
|
if (i_Reset_n = '0') then
|
78 |
|
|
D_r2 <= '0';
|
79 |
|
|
D_re <= '0';
|
80 |
|
|
elsif (rising_edge(i_Clock)) then
|
81 |
|
|
D_r2 <= D_r1;
|
82 |
|
|
D_re <= D_r1 and not D_r2;
|
83 |
|
|
end if;
|
84 |
|
|
end process;
|
85 |
|
|
|
86 |
|
|
o_Q <= D_re;
|
87 |
|
|
end Behavioral;
|
88 |
|
|
--CODE
|