summaryrefslogtreecommitdiff
path: root/tb/interval_timer.hpp
blob: 7cce26556071dec1d3ddaacb1b7e176ab8adc95e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef TALLER_INTERVAL_TIMER_HPP
#define TALLER_INTERVAL_TIMER_HPP

#include <cstdint>

#include "avalon.hpp"

namespace taller::avalon
{
	class interval_timer : public slave
	{
		public:
			interval_timer(std::uint32_t base) noexcept;

			void tick() noexcept;

			virtual bool read(std::uint32_t addr, std::uint32_t &data) noexcept final override;
			virtual bool write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable) noexcept final override;

		private:
			std::uint32_t count;
			std::uint32_t period;
			std::uint32_t snap;
			bool          status_to = false;
			bool          status_run = false;
			bool          control_ito = false;
			bool          control_cont = false;
	};
}

#endif