I try to make a sensor with one input a three inoutputs. If the sensor change its value, send the information for three outputs and if un inoupts receive sth it send the information to the rest but not by itself. This is my code, I hace latch beacuse I change the value in two different places, but i dont know hoy can i make it. Please help me.
Lectura is the port when the inout received something.
Ad1,2,3 is the acumulator to compare the value
d1,d2,d3 its the inout
if (lectura1='1' or lectura2='1' or lectura3='1') THEN
if (lectura1= '1' AND d1/=Ad1 AND lectura2 ='0' AND lectura3 ='0') THEN
d2<= d1;
d3<= d1;
Ad1 <= d1;
d1 <= d1;
Ad2<= Ad2;
Ad3<= Ad3;
elsif (lectura1= '0' AND d2/=Ad2 AND lectura2 ='1' AND lectura3 ='0') THEN
d1<= d2;
d3<= d2;
Ad1 <= Ad1;
d2 <= d2;
Ad2<= d2;
Ad3<= Ad3;
elsif (lectura1= '0' AND d3/=Ad3 AND lectura2 ='0' AND lectura3 ='1') THEN
d1<= d3;
d3<= d3;
Ad1 <= Ad1;
d2 <= d3;
Ad2<= Ad2;
Ad3<= d3;
else
d1<="00000000";
d2<="00000000";
d3<="00000000";
Ad2<= Ad2;
Ad1 <= Ad1;
Ad3<= Ad3;
end if;
else
Lectura is the port when the inout received something.
Ad1,2,3 is the acumulator to compare the value
d1,d2,d3 its the inout
if (lectura1='1' or lectura2='1' or lectura3='1') THEN
if (lectura1= '1' AND d1/=Ad1 AND lectura2 ='0' AND lectura3 ='0') THEN
d2<= d1;
d3<= d1;
Ad1 <= d1;
d1 <= d1;
Ad2<= Ad2;
Ad3<= Ad3;
elsif (lectura1= '0' AND d2/=Ad2 AND lectura2 ='1' AND lectura3 ='0') THEN
d1<= d2;
d3<= d2;
Ad1 <= Ad1;
d2 <= d2;
Ad2<= d2;
Ad3<= Ad3;
elsif (lectura1= '0' AND d3/=Ad3 AND lectura2 ='0' AND lectura3 ='1') THEN
d1<= d3;
d3<= d3;
Ad1 <= Ad1;
d2 <= d3;
Ad2<= Ad2;
Ad3<= d3;
else
d1<="00000000";
d2<="00000000";
d3<="00000000";
Ad2<= Ad2;
Ad1 <= Ad1;
Ad3<= Ad3;
end if;
else