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

Subversion Repositories artificial_neural_network

[/] [artificial_neural_network/] [trunk/] [ANN_kernel/] [RTL_VHDL_files/] [activation_function.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ojosynariz
----------------------------------------------------------------------------------
2
-- Company:
3
-- Engineer:
4
--
5
-- Create Date:    16:16:02 05/14/2014
6
-- Design Name:    Configurable ANN
7
-- Module Name:    activation_function - Structural
8
-- Project Name:
9
-- Target Devices:
10
-- Tool versions:
11
-- Description: Activation function selector. It instantiates the activation
12
--             funtion type selected with f_type parameter.
13
--
14
-- Dependencies:
15
--
16
-- Revision:
17
-- Revision 0.01 - File Created
18
-- Additional Comments:
19
--
20
----------------------------------------------------------------------------------
21
library IEEE;
22
use IEEE.STD_LOGIC_1164.ALL;
23
 
24
 
25
entity activation_function is
26
   generic
27
   (
28
      f_type : string := "linear"; -- Activation function type
29
      Nbit   : natural := 8        -- Bit width
30
   );
31
   port
32
   (
33
      reset   : in  std_logic;
34
      clk     : in  std_logic;
35
      run_in  : in  std_logic; -- Start and input data validation
36
      inputs  : in  std_logic_vector(Nbit-1 downto 0); -- Input data
37
      run_out : out std_logic; -- Output data validation, run_in for the next layer
38
      outputs : out std_logic_vector(Nbit-1 downto 0)  -- Output data
39
   );
40
end activation_function;
41
 
42
architecture Structural of activation_function is
43
 
44
begin
45
 
46
-- Linear activation function. It is a direct assignment:
47
linear_f:
48
   if (f_type = "linear") generate
49
      outputs <= inputs;
50
      run_out <= run_in;
51
   end generate;
52
 
53
-- Example 1: sigmoid activation function implemented as a Look-Up-Table (LUT):
54
Sigmoid_f:
55
   if (f_type = "siglut") generate
56
      siglut_inst: entity work.af_sigmoid
57
         generic map
58
         (
59
            Nbit => Nbit
60
         )
61
         port map
62
         (
63
            reset   => reset,
64
            clk     => clk,
65
            run_in  => run_in,
66
            inputs  => inputs,
67
            run_out => run_out,
68
            outputs => outputs
69
         );
70
   end generate;
71
 
72
-- Example 2: sigmoid activation function implemented as a LUT, with a second different set of parameters:
73
Sigmoid2_f:
74
   if (f_type = "siglu2") generate
75
      siglut_inst: entity work.af_sigmoid2
76
         generic map
77
         (
78
            Nbit => Nbit
79
         )
80
         port map
81
         (
82
            reset   => reset,
83
            clk     => clk,
84
            run_in  => run_in,
85
            inputs  => inputs,
86
            run_out => run_out,
87
            outputs => outputs
88
         );
89
   end generate;
90
 
91
-- Template to instance user activation function type ("userAF"):
92
--userAF_f:
93
   --if (f_type = "userAF") generate
94
      --yourAF_inst: entity work.--palace here user module name--
95
         --generic map
96
         --(
97
         --   Nbits => Nbits
98
         --)
99
         --port map
100
         --(
101
         --   reset => reset,
102
         --   clk   => clk,
103
         --   run_in  => run_in,
104
         --   inputs  => inputs,
105
         --   run_out => run_out,
106
         --   outputs => outputs
107
         --);
108
   --end generate;
109
-- User can instantiate as many types of activation function as needed, each one of them must be tagged as a 6 character string
110
 
111
end Structural;
112
 

powered by: WebSVN 2.1.0

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