diff --git a/ModNEF_Sources/modules/neurons/BLIF/beta_lif.vhd b/ModNEF_Sources/modules/neurons/BLIF/beta_lif.vhd index 83722e01ae4a66b269a62f1762ba4d73b2e90685..468271ea6ba3bf46f53401973a106edf3564a651 100644 --- a/ModNEF_Sources/modules/neurons/BLIF/beta_lif.vhd +++ b/ModNEF_Sources/modules/neurons/BLIF/beta_lif.vhd @@ -121,7 +121,9 @@ begin case state is when multiplication => V_mult := std_logic_vector(signed(V) * signed(beta)); - V_buff := V_mult(fixed_point + variable_size-1 downto fixed_point); + V_mult := std_logic_vector(shift_right(signed(V_mult), fixed_point)); + V_buff := V_mult(variable_size-1 downto 0); + --V_buff := V_mult(fixed_point + variable_size-1 downto fixed_point); if signed(V_buff) >= signed(v_threshold) then spike <= '1'; diff --git a/ModNEF_Sources/modules/uart/uart_xstep.vhd b/ModNEF_Sources/modules/uart/uart_xstep.vhd index efa627517e6d45757e228a1550fe72c74c21bd6c..43ade23fb24a4abc96bd3e07499f0679eb360a17 100644 --- a/ModNEF_Sources/modules/uart/uart_xstep.vhd +++ b/ModNEF_Sources/modules/uart/uart_xstep.vhd @@ -196,7 +196,7 @@ begin end if; when wait_out_aer => - if i_emu_ready = '1' then + if i_emu_ready = '1' and network_to_uart_busy='0' then if read_empty = '1' then -- no more data to process start_uart_transmission <= '1'; emu_state <= send_aer; diff --git a/modneflib/modnef/arch_builder/modules/BLIF/blif.py b/modneflib/modnef/arch_builder/modules/BLIF/blif.py index b6a06638e6a46539fe768489c2455ccd32699cda..9dc9af6c60627682068086fb893a789f7e899930 100644 --- a/modneflib/modnef/arch_builder/modules/BLIF/blif.py +++ b/modneflib/modnef/arch_builder/modules/BLIF/blif.py @@ -193,8 +193,6 @@ class BLif(ModNEFArchMod): bw = self.quantizer.bitwidth mem_file = open(f"{output_path}/{self.mem_init_file}", 'w') - - truc = open(f"temp_{self.mem_init_file}", 'w') if self.quantizer.signed: for i in range(self.input_neuron): @@ -202,7 +200,6 @@ class BLif(ModNEFArchMod): for j in range(self.output_neuron-1, -1, -1): w_line = (w_line<<bw) + two_comp(self.quantizer(weights[i][j]), bw) - truc.write(f"{i} {j} {two_comp(self.quantizer(weights[i][j]), bw)}\n") mem_file.write(f"@{to_hex(i)} {to_hex(w_line)}\n") diff --git a/modneflib/modnef/modnef_torch/modnef_neurons/blif_model/blif.py b/modneflib/modnef/modnef_torch/modnef_neurons/blif_model/blif.py index c435ed14c7e52ce6af762100892e129324875329..08f17e763ec7194a98a93e2647ba287c5bd37f2e 100644 --- a/modneflib/modnef/modnef_torch/modnef_neurons/blif_model/blif.py +++ b/modneflib/modnef/modnef_torch/modnef_neurons/blif_model/blif.py @@ -228,14 +228,17 @@ class BLIF(ModNEFNeuron): if not self.mem.shape == forward_current.shape: self.mem = torch.zeros_like(forward_current, device=self.mem.device) - self.mem = self.mem + forward_current + self.reset = self.mem_reset(self.mem) + + self.mem = self.mem + forward_current - self.reset*self.threshold if self.hardware_estimation_flag: self.val_min = torch.min(self.mem.min(), self.val_min) self.val_max = torch.max(self.mem.max(), self.val_max) + if self.reset_mechanism == "subtract": - self.mem = self.mem*self.beta#-self.reset*self.threshold + self.mem = self.mem*self.beta elif self.reset_mechanism == "zero": self.mem = self.mem*self.beta-self.reset*self.mem else: @@ -268,6 +271,7 @@ class BLIF(ModNEFNeuron): if self.hardware_estimation_flag: val_max = max(abs(self.val_max), abs(self.val_min)) val_max = self.quantizer(val_max) + print(val_max) self.hardware_description["variable_size"] = ceil(log(val_max)/log(256))*8 else: self.hardware_description["variable_size"]=16 diff --git a/modneflib/modnef/modnef_torch/modnef_neurons/modnef_torch_neuron.py b/modneflib/modnef/modnef_torch/modnef_neurons/modnef_torch_neuron.py index 49b31e55ef6d5a4b6a9f76653fc65e0e0043edd9..9a48b0c61d4cd08aad983bab0aca0942a4f5d0dc 100644 --- a/modneflib/modnef/modnef_torch/modnef_neurons/modnef_torch_neuron.py +++ b/modneflib/modnef/modnef_torch/modnef_neurons/modnef_torch_neuron.py @@ -60,6 +60,7 @@ class ModNEFNeuron(SpikingNeuron): ) self.fc = QuantLinear(in_features=in_features, out_features=out_features) + #self.fc = nn.Linear(in_features=in_features, out_features=out_features, bias=False) self.hardware_estimation_flag = False