-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneuron_tb.vhd
100 lines (84 loc) · 2.37 KB
/
neuron_tb.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.math_real.all;
entity neuron_tb is
end entity neuron_tb;
architecture tb_vhdl of neuron_tb is
component neuron is
generic (
address_0 : unsigned(5 downto 0):= "000000";
address_1 : unsigned(5 downto 0):= "000000";
post_spike_address : unsigned(5 downto 0) := "000000"
);
port(
clk_in : in std_logic;
reset_in : in std_logic;
address_in : in unsigned(5 downto 0);
pre_spike : in std_logic;
address_out : out unsigned(5 downto 0);
post_spike : out std_logic
);
end component;
constant CLKPERIODE : time := 50 us;
constant address_in_0 : unsigned(5 downto 0) := "000001";
constant address_in_1 : unsigned(5 downto 0) := "011000";
constant address_in_2 : unsigned(5 downto 0) := "011010";
constant address_in_3 : unsigned(5 downto 0) := "011011";
signal clk_in : std_logic := '1';
signal reset_in : std_logic := '0';
signal address_in : unsigned(5 downto 0) := "000000";
signal pre_spike : std_logic := '0';
signal post_spike : std_logic := '0';
signal address_out : unsigned(5 downto 0) := "000000";
signal temp_counter : integer := 0;
begin
neuron_1 : neuron
generic map(
address_0 => "000001",
address_1 => "000010",
post_spike_address => "110000"
)
port map(
clk_in => clk_in,
reset_in => reset_in,
address_in => address_in,
pre_spike => pre_spike,
address_out => address_out,
post_spike => post_spike
);
clk_gen : process
begin
wait for CLKPERIODE/2;
clk_in <= not clk_in;
end process clk_gen;
reset_gen : process
begin
reset_in <= '1';
wait for CLKPERIODE/2;
reset_in <= '0';
wait;
end process reset_gen;
spike_gen : process
begin
wait for CLKPERIODE;
temp_counter <= temp_counter + 1;
if temp_counter = 12 then
address_in <= address_in_0;
elsif temp_counter mod 29 = 0 then
address_in <= address_in_1;
elsif temp_counter mod 43 = 0 then
address_in <= address_in_2;
elsif temp_counter mod 58 = 0 then
address_in <= address_in_3;
elsif temp_counter mod 72 = 0 then
address_in <= address_in_0;
elsif temp_counter mod 80 = 0 then
address_in <= address_in_2;
elsif temp_counter > 4321 then
temp_counter <= 0;
else
address_in <= "000000";
end if;
end process spike_gen;
end architecture tb_vhdl;