I have a Nexys2, and i need to read from an ultrasonic sensor.
This is the sensor:
SRF05 Technical Documentation
Now, i'm doing my program from the Timing Diagram, it consists in two parts: enable sensor and read sensor, enable sensor part is ok because in simulation it works, but im having problems with the read part, in simulation works too, but when i try to synthetize i get this error:
Signal dist_temp cannot be synthesized, bad synchronous description.
--Variables para el sensor ultrasonico
shared variable flag: std_logic:= '0';
signal enable_temp: std_logic:= '0';
signal count_ultra: integer:= 0;
signal count_rd: integer:= 0;
signal dist_temp: std_logic_vector (7 downto 0):= "00000000";
begin
enable <= enable_temp;
[......] Counters part, it doesn't matter.
enable_sensor: process (clk_temp_1us)
begin
if (flag = '0') then
if (clk_temp_1us' event and clk_temp_1us = '1') then
count_ultra <= count_ultra + 1;
if (count_ultra >= 0 and count_ultra <= 20000) then
enable_temp <= '0';
elsif (count_ultra > 20000 and count_ultra < 20020) then
enable_temp <= '1';
elsif (count_ultra = 20020) then
count_ultra <= 0;
flag := '1';
enable_temp <= '0';
end if;
end if;
end if;
end process enable_sensor;
read_sensor: process(clk_temp_100ns, pulse_in, dist_temp)
begin
if (flag = '1') then
if (clk_temp_100ns' event and clk_temp_100ns = '1') then
if (pulse_in = '1') then
count_rd <= count_rd + 1;
if (count_rd = 144) then
count_rd <= 0;
dist_temp <= dist_temp + 1;
end if;
end if;
end if;
end if;
if (falling_edge(pulse_in)) then
flag := '0';
count_rd <= 0;
dist <= dist_temp;
dist_temp <= "00000000";
end if;
end process read_sensor;
I understand that Xilinx ISE sends that error because i'm trying to change something at both positive and negative edges of clock, i tried in different ways to write the code but i always end in the same.:sad::sad:
Any help will be appreciated