import numpy as np


class Delay:
	def __init__(self, dt, delay, ic):
		self.nd = int(delay/dt + 0.5)
		self.delay_line = np.ones(self.nd+1)*ic
		self.ri = 0
		self.wi = 0

	def initial(self, ic):
		self.delay_line = np.ones(self.nd+1)*ic

	def put(self, data):
		self.delay_line[self.wi] = data
		self.wi += 1
		if self.wi >= self.delay_line.size:
			self.wi = 0

	def get(self):
		self.ri += 1
		if self.ri >= self.delay_line.size:
			self.ri = 0

		result = self.delay_line[self.ri]
		return result


if __name__ == '__main__':
	d = Delay(1, 1)

	for i in range(1, 20):
		d.put(i)
		print("In = {}, out = {}".format(i, d.get()))
