Z
zooplibob
I have the following code in my state machine for an I2C controller.
Basically when I get to state data_out4, I want to increment the
variable "datacount" by 1. However I stay in that state for many clock
cycles and it increments many times. How can I code it so that it
increments the variable only once when I'm in that state? Thanks
elsif state = data_out1 then
sda_sig <= 'Z';
scl_sig <= '0';
elsif state = data_out2 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '0';
elsif state = data_out3 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '1';
elsif state = data_out4 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '0';
datacount:=datacount+1;
Basically when I get to state data_out4, I want to increment the
variable "datacount" by 1. However I stay in that state for many clock
cycles and it increments many times. How can I code it so that it
increments the variable only once when I'm in that state? Thanks
elsif state = data_out1 then
sda_sig <= 'Z';
scl_sig <= '0';
elsif state = data_out2 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '0';
elsif state = data_out3 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '1';
elsif state = data_out4 then
if data_out(7-datacount) = '0' then
sda_sig <= '0';
else
sda_sig <= 'Z';
end if;
scl_sig <= '0';
datacount:=datacount+1;