Skip to content

Commit

Permalink
spiking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mountains-high authored and mountains-high committed Nov 2, 2023
1 parent 5bad89f commit 9256c02
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/if_neuron.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,22 @@ module if_neuron (
output reg [7:0] state
);
reg [7:0] threshold;
wire [7:0] next_state;


always @(posedge clk) begin
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
state <= 0;
threshold <= 230;
state <= 8'b0;
threshold <= 8'hE6; // Example threshold value
end else if (state >= threshold) begin
state <= 8'b0; // Reset the state when the threshold is crossed
end else begin
state <= next_state;
state <= state + current;
end
end

// next_state logic and spiking logic
//assign spike = (state >= threshold);
//assign next_state = (spike ? 0 : current) + (spike ? 0 : (state >> 1)+(state >> 2)+(state >> 3));

// Spiking logic
assign spike = (state >= threshold);

always @(posedge clk or posedge rst_n) begin
if (!rst_n) begin
next_state <= 0;
end else if (spike) begin
next_state <= 0;
end else begin
next_state <= current;
end
end


endmodule

0 comments on commit 9256c02

Please sign in to comment.