Forum Discussion
Altera_Forum
Honored Contributor
16 years agoLUT help!!!
I have wrote this code for implementing a neural network.What it does is to take some values(inputs) and some weights and computes the SUM(values*weigths).What i want to do is to check if the total s...
Altera_Forum
Honored Contributor
16 years agoI wrote this code.What i need to do is to insert 4 values at each clock which i store on a 2-dimensional array and i want to compute the sum of these values.
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_ARITH.ALL; ENTITY test IS PORT( x1 : IN INTEGER RANGE 0 TO 255; clk,load : IN STD_LOGIC; output1 : out INTEGER RANGE 0 TO 1020); END test; ARCHITECTURE behavioral OF test IS TYPE windows IS ARRAY(0 TO 1,0 to 1) OF INTEGER RANGE 0 TO 255; BEGIN PROCESS(clk,x1) VARIABLE window : windows; VARIABLE sum : INTEGER RANGE 0 TO 1020; BEGIN IF(clk'EVENT AND clk='1') THEN IF(load='1') THEN FOR i IN 0 TO 1 LOOP FOR j IN 0 TO 1 LOOP window(i,j):=x1; sum:=sum+window(i,j); END LOOP; END LOOP; END IF; END IF; output1<=sum; END PROCESS; END behavioral; The code has no problem while compiling but in the simulation the results are wrong!!!.Please help.I set in the simulation for the x1 to take 2 values per clock but the result shows that something is wrong.