diff --git a/src/rtl/neuron.v b/src/rtl/neuron.v index 857c783f0b9efe1730a4b2550aa134b8a9978ad7..6895e96a1c08e4f1a324f68063380deb8394e346 100644 --- a/src/rtl/neuron.v +++ b/src/rtl/neuron.v @@ -101,7 +101,7 @@ module neuron #( else if(!backprop_done && backprop_running) begin - + // Adjust normal weights if( regidx < NUMBER_SYNAPSES ) begin if(backprop_in_port_store[regidx] && neuron_output) begin @@ -113,15 +113,26 @@ module neuron #( end regidx <= regidx+1; end - - else if( regidx == NUMBER_SYNAPSES ) + // Adjust RNN weights + else if( regidx < NUM_WEIGHTS ) + begin + if(rnn_inputs[regidx] && neuron_output) begin + RNNW[regidx-NUMBER_SYNAPSES] <= $signed(RNNW[regidx-NUMBER_SYNAPSES]) - $signed(dw); + end + else + if(rnn_inputs[regidx] && !neuron_output) begin + RNNW[regidx-NUMBER_SYNAPSES] <= $signed(RNNW[regidx-NUMBER_SYNAPSES]) + $signed(dw); + end + regidx <= regidx+1; + end + // Reset the redister index counter + else if( regidx == NUM_WEIGHTS ) begin //$display("Backprop done"); backprop_done <= 1; backprop_running <= 0; regidx <= 0; end - end else