/ src / hal / components / select8.comp
select8.comp
 1  component select8 "8-bit binary match detector";
 2  pin in bit enable = TRUE "Set enable to FALSE to cause all outputs to be set FALSE";
 3  pin in s32 sel "The number of the output to set TRUE.  All other outputs well be set FALSE";
 4  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";
 5  function _ nofp;
 6  license "GPL";
 7  ;;
 8  FUNCTION(_) {
 9  	hal_s32_t temp_sel;
10  	int i, temp_enable;
11  	temp_sel = sel;
12  	temp_enable = enable;
13  	for (i=0;i<8;i++) {
14  		if (!temp_enable || temp_sel!=i)
15  			out(i)=0;
16  		else
17  			out(i)=1;
18  	}
19  }