T4V0,
@T4V0@kbin.social avatar

@dejo This is much better, but there is still some room for improvement.

There is a mismatch between your comparisons count and alarm_interval. Here in the code bellow you can see the issue:

if stop = '1' or count = alarm_interval then

count <= 0; -- count is 0 here

end if;

[...]

alarming <= '1' when count >= alarm_interval else '0'; -- This condition is never true due to count always being 0 or smaller the alarm_interval.
alarm <= alarming;


As it is right now, the alarming signal is never going to be '1'. It is best to split the comparison and write to alarming directly:

if stop = '1' then

count <= 0;
alarming <= '0';

end if;

if count = alarm_interval then

alarming <= '1';

end if;

[...]

alarm <= alarming;


As for the testbench, you should set the start and unset it only after the alarming is '1', and test if alarming is working after adjusting the timer:

stimuli : process

begin

-- Reset generation

reset <= '1';

wait for 20 us; -- Adjust delay to fit the new clock period

reset <= '0';

-- Add your stimuli and test cases here

-- For example:

start <= '1';
stop <= '0';

wait for 620 us; -- Wait until alarm is alarming

start <= '0'
stop <= '1';
adjust_interval_up <= '1';

wait for 1 us; -- Increment the timer by a minute

start <= '1';
stop <= '0';
adjust_interval_up <= '0';

wait for 1220 us; -- Wait until the alarm is alarming

start <= '0';
stop <= '1';
adjust_interval_down <= '1';

wait for 1 us; -- Decrement the timer by a minute

start <= '1';
stop <= '0';
adjust_interval_down <= '0';

wait for 620 us; -- Wait until the alarm is alarming

start <= '0';
stop <= '1';

wait for 20 us;

-- ...

-- Stop the clock and hence terminate the simulation

TbSimEnded <= '1';

wait;

end process;

I suggest changing the 100 ms time slices you use in the timer to a minute instead. That way your simulation time could be much quicker (though you would also have to change the testbench delays).

  • Todo
  • Suscrito
  • Moderado
  • Favoritos
  • random
  • noticiascr
  • science@kbin.social
  • CostaRica
  • Todos las revistas