-
Notifications
You must be signed in to change notification settings - Fork 2
/
sensory_neuron.v
61 lines (59 loc) · 1.7 KB
/
sensory_neuron.v
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Engineer: Mert İnan
//
// Create Date: 08:45:20 12/16/2015
// Module Name: sensory_neuron
// Project Name: BRAIN:M
// Target Devices: FPGA Board
// Description: This simple High Level State Machine is the smallest element of
// a brain that we instantiate in the top module. Its properties and
// actions are very similar to that of real sensory neurons found in
// mammalian brain. The sensory input for this neuron is the distance
// value measured by the PING))) Ultrasound module. It outputs high
// if the distance value is the same as its threshold value, which is
// also another input and is instantiated in the top module.
// Revision 0.01 - File Created
// Additional Comments: There will be a hundred of this sensory neuron in the
// finished design. Instantiating a hundred neurons would
// take a lot of space.
//////////////////////////////////////////////////////////////////////////////////
module sensory_neuron( clk, d, th, start, y);
input clk, start;
input [6:0] d, th;
output reg y;
reg [1:0] state, nextstate;
reg [6:0] dReg, dNext;
//sequential logic
always@(posedge clk)
begin
state <= nextstate;
dReg <= dNext;
end
//Combinational Logic
always@( state or dReg or start)
case (state)
2'b00:
begin
dNext = 7'b0;
nextstate = (start)? 2'b01: 2'b00;
y = 1'b0;
end
2'b01:
begin
dNext = d;
nextstate = 2'b10;
y = 1'b0;
end
2'b10:
if( dReg == th)
nextstate = 2'b11;
else
nextstate = 2'b00;
2'b11:
begin
y = 1'b1;
nextstate = 2'b00;
end
endcase
endmodule