aboutsummaryrefslogtreecommitdiffstats
path: root/src/hal/components/select8.comp
blob: 9893eed27f104f12a54545adaf36a35a34522617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
component select8 "8-bit binary match detector";
pin in bit enable = TRUE "Set enable to FALSE to cause all outputs to be set FALSE.";
pin in s32 sel "The number of the output to set TRUE.  All other outputs well be set FALSE.";
pin out bit out#[8] "Output bits.  If enable is set and the sel input is between 0 and 7, then the corresponding output bit will be set true.";
function _ nofp;
license "GPL";
author "Stephen Wille Padnos";
;;
FUNCTION(_) {
	hal_s32_t temp_sel;
	int i, temp_enable;
	temp_sel = sel;
	temp_enable = enable;
	for (i=0;i<8;i++) {
		if (!temp_enable || temp_sel!=i)
			out(i)=0;
		else
			out(i)=1;
	}
}
bues.ch cgit interface