// "wchb-token-ring-e.hac"
// definition ripped and modified from "lib/copy.hac"

import "channel.hac";

// veriation, with cut-off reset
template <pint N, M>
defproc wchb_copy_e1of(e1of<N> L, R[M]; bool _Reset) {
bool _le;
c1of<N> RR;
_c1of<N> _r;
(;i:M:	RR.d = R[i].d;	)
prs {
(:j:N:
	~_Reset				-> _r.d[j]+
	(&:i:M:	 R[i].e	) &  L.d[j] & _Reset	-> _r.d[j]-
	(&:i:M:	~R[i].e	) & ~L.d[j] & _Reset	-> _r.d[j]+
	_r.d[j]				=> RR.d[j]-	// drive me!
)
	(&:j:N: _r.d[j] )		=> _le-		// nand
	_le				=> L.e-
}
}

template <pint M>
typedef	wchb_copy_e1of<1,M>		wchb_copy_e1of1;
template <pint M>
typedef	wchb_copy_e1of<2,M>		wchb_copy_e1of2;
template <pint M>
typedef	wchb_copy_e1of<3,M>		wchb_copy_e1of3;
template <pint M>
typedef	wchb_copy_e1of<4,M>		wchb_copy_e1of4;
template <pint M>
typedef	wchb_copy_e1of<5,M>		wchb_copy_e1of5;
template <pint M>
typedef	wchb_copy_e1of<6,M>		wchb_copy_e1of6;
template <pint M>
typedef	wchb_copy_e1of<7,M>		wchb_copy_e1of7;
template <pint M>
typedef	wchb_copy_e1of<8,M>		wchb_copy_e1of8;

// empty ring, deadlock, of course
bool _Reset, Reset;
e1of2 L, M, R;
wchb_copy_e1of2<1>
	X(L, {M}, _Reset),
	Y(M, {R}, _Reset),
	Z(R, {L}, _Reset);

