Skip to content
Snippets Groups Projects
Commit dcd96623 authored by ahoni's avatar ahoni
Browse files

add qat test

parent 025865dc
No related branches found
No related tags found
1 merge request!3Dev
...@@ -121,7 +121,9 @@ begin ...@@ -121,7 +121,9 @@ begin
case state is case state is
when multiplication => when multiplication =>
V_mult := std_logic_vector(signed(V) * signed(beta)); 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 if signed(V_buff) >= signed(v_threshold) then
spike <= '1'; spike <= '1';
......
...@@ -196,7 +196,7 @@ begin ...@@ -196,7 +196,7 @@ begin
end if; end if;
when wait_out_aer => 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 if read_empty = '1' then -- no more data to process
start_uart_transmission <= '1'; start_uart_transmission <= '1';
emu_state <= send_aer; emu_state <= send_aer;
......
...@@ -194,15 +194,12 @@ class BLif(ModNEFArchMod): ...@@ -194,15 +194,12 @@ class BLif(ModNEFArchMod):
mem_file = open(f"{output_path}/{self.mem_init_file}", 'w') mem_file = open(f"{output_path}/{self.mem_init_file}", 'w')
truc = open(f"temp_{self.mem_init_file}", 'w')
if self.quantizer.signed: if self.quantizer.signed:
for i in range(self.input_neuron): for i in range(self.input_neuron):
w_line = 0 w_line = 0
for j in range(self.output_neuron-1, -1, -1): for j in range(self.output_neuron-1, -1, -1):
w_line = (w_line<<bw) + two_comp(self.quantizer(weights[i][j]), bw) 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") mem_file.write(f"@{to_hex(i)} {to_hex(w_line)}\n")
......
...@@ -228,14 +228,17 @@ class BLIF(ModNEFNeuron): ...@@ -228,14 +228,17 @@ class BLIF(ModNEFNeuron):
if not self.mem.shape == forward_current.shape: if not self.mem.shape == forward_current.shape:
self.mem = torch.zeros_like(forward_current, device=self.mem.device) 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: if self.hardware_estimation_flag:
self.val_min = torch.min(self.mem.min(), self.val_min) self.val_min = torch.min(self.mem.min(), self.val_min)
self.val_max = torch.max(self.mem.max(), self.val_max) self.val_max = torch.max(self.mem.max(), self.val_max)
if self.reset_mechanism == "subtract": 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": elif self.reset_mechanism == "zero":
self.mem = self.mem*self.beta-self.reset*self.mem self.mem = self.mem*self.beta-self.reset*self.mem
else: else:
...@@ -268,6 +271,7 @@ class BLIF(ModNEFNeuron): ...@@ -268,6 +271,7 @@ class BLIF(ModNEFNeuron):
if self.hardware_estimation_flag: if self.hardware_estimation_flag:
val_max = max(abs(self.val_max), abs(self.val_min)) val_max = max(abs(self.val_max), abs(self.val_min))
val_max = self.quantizer(val_max) val_max = self.quantizer(val_max)
print(val_max)
self.hardware_description["variable_size"] = ceil(log(val_max)/log(256))*8 self.hardware_description["variable_size"] = ceil(log(val_max)/log(256))*8
else: else:
self.hardware_description["variable_size"]=16 self.hardware_description["variable_size"]=16
......
...@@ -60,6 +60,7 @@ class ModNEFNeuron(SpikingNeuron): ...@@ -60,6 +60,7 @@ class ModNEFNeuron(SpikingNeuron):
) )
self.fc = QuantLinear(in_features=in_features, out_features=out_features) 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 self.hardware_estimation_flag = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment