Closed BGull00 closed 4 weeks ago
I think it might be best to rework this so it is based on the negative extrema of signed integers instead of constantly dealing with the -1
shenanigans of the positive end.
@BGull00, I did a fair amount of spreadsheet math for this, and put the RTL changes in. The neuron is not "aware" of the synapse weights, so it wouldn't be able to optimize SUM_WIDTH
based on them; it assumes it can receive any signed integer of CHARGE_WIDTH
on any input port at any time. The synthesis tool is obviously free to optimize further, but I think to preserve design abstraction and modularity, I don't want to add that level of awareness to the neuron. As a result, SUM_WIDTH
values may be overly generous.
The SUM_WIDTH field in risp_neuron.sv is being calculated incorrectly for the following neuron case:
The incorrect calculation uses this line of code:
localparam SUM_WIDTH = $clog2(NUM_INP * ((1 << (CHARGE_WIDTH - 2)) - 1) + POTENTIAL_ABS_MAX) + 1;
In this case, SUM_WIDTH results in 1. However, the incoming synapses to the neurons have weights of 1, 1, and -1, respectively. The correct SUM_WIDTH should be 2 in this case.