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-15 : Mickael Carl (CNES): Creation
|
10
|
-------------------------------------------------------------------------------------------------
|
11
|
-- File name : CNE_01500_good.vhd
|
12
|
-- File Creation date : 2015-04-15
|
13
|
-- Project name : VHDL Handbook CNES Edition
|
14
|
-------------------------------------------------------------------------------------------------
|
15
|
-- Softwares : Microsoft Windows (Windows 7) - Editor (Eclipse + VEditor)
|
16
|
-------------------------------------------------------------------------------------------------
|
17
|
-- Description : Handbook example: Identification of custom type name: 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
|
-- 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
|
|
52
|
entity CNE_01500_good is
|
53
|
port (
|
54
|
i_Reset_n : in std_logic; -- Reset signal
|
55
|
i_Clock : in std_logic; -- Clock signal
|
56
|
i_Addr : in std_logic_vector(1 downto 0); -- Address to read from or write to
|
57
|
i_Rd : in std_logic; -- Read signal
|
58
|
i_Wr : in std_logic; -- Write signal
|
59
|
i_Data : in std_logic; -- Incoming data to write
|
60
|
o_Data : out std_logic -- Data read
|
61
|
);
|
62
|
end CNE_01500_good;
|
63
|
|
64
|
--CODE
|
65
|
architecture Behavioral of CNE_01500_good is
|
66
|
type t_register is array (0 to 3) of std_logic; -- Array for signal registration
|
67
|
signal D : t_register; -- Actual signal
|
68
|
signal Data : std_logic; -- Module output
|
69
|
begin
|
70
|
-- Describes a simple Register bank with Read and Write signals
|
71
|
P_Register_Bank:process(i_Reset_n, i_Clock)
|
72
|
begin
|
73
|
if (i_Reset_n='0') then
|
74
|
D <= (others => '0');
|
75
|
Data <= '0';
|
76
|
elsif (rising_edge(i_Clock)) then
|
77
|
if (i_Rd='1') then
|
78
|
-- Read memory
|
79
|
Data <= D(to_integer(unsigned(i_Addr)));
|
80
|
elsif (i_Wr='1') then
|
81
|
-- Write memory
|
82
|
D(to_integer(unsigned(i_Addr))) <= i_Data;
|
83
|
end if;
|
84
|
end if;
|
85
|
end process;
|
86
|
|
87
|
o_Data <= Data;
|
88
|
end Behavioral;
|
89
|
--CODE
|