Ok i manage to do the first part of the project.What it does is :i insert some values for inputs(that will remain constants through all the process) and then when a clock EVENT i do this computation : input1*weight1+input2*weight2+input3*weight3.This is the multiply-accumulator unit.The second thing that i want to do(for which i need your help) is to compare this result(from the previous step) with a threshold and then fix the weight values in order to :
input1*weight1(new)+input2*weight2(new)+input3*weight3(new)>threshold.Here is my code
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity neuron is
port ( in1,in2,in3,w1,w2,w3 : in unsigned (7 downto 0);
clk : in std_logic;
id : out bit;
output : out unsigned (15 downto 0));
end neuron;
architecture behavioral of neuron is
type inputs is array (1 to 3) of unsigned (7 downto 0);
type weights is array (1 to 3) of unsigned (7 downto 0);
constant threshold : unsigned(15 downto 0):="0000011011100111";
constant sum : unsigned:="1";
begin
process(clk,w1,w2,w3)
variable weight : weights;
variable input : inputs;
variable prod,acc : unsigned (15 downto 0);
begin
if(clk'EVENT AND clk='1') then
input(1):=in1;
input(2):=in2;
input(3):=in3;
weight(1):=w1;
weight(2):=w2;
weight(3):=w3;
acc:=(others=>'0');
end if;
for j in 1 to 3 loop
prod:=input(j)*weight(j);
acc:=acc+prod;
end loop;
if(acc>threshold) then id<='1';
else id<='0';
end if;
output<=acc;
end process;
end behavioral;
I attached and a photo with the simulation results