On 16 August 2017 at 19:49, Les Newell <[email protected]> wrote:
> This is the inverse of the mux components. It takes an integer value and
> decodes it to up to 16 outputs.
I don't know how much comp has changed since the date on that comp,
but it could be simpler and have variable size.
Something like this. (but, I will point out that this core-dumped with
a sig11 on my VM, but it does compile and make the pins)
/********************************************************************
* Description: Demux16 HAL component.
*
* Author: Les Newell <les at sheetcam dot com>
* License: GPL Version 2 or later
*
* Copyright (c) 2009 All rights reserved.
*
********************************************************************/
component demux "Turn on one of N outputs depending on one input";
pin in u32 in "input in the range 0-N.";
pin out bit out-##[1 : personality] """One output goes on if the input
is in the range 0-15. Any other value results in no outputs on""";
param rw bit bargraph = 0 """If true the all outputs up to the input
value turn on. Note in bargraph mode the range is 0-16 where 0= all off.
In normal mode the range is 0-15 where 0= output 0 on""";
option personality;
license "GPL";
function _;
;;
FUNCTION(_){
int i;
for (i = 0; i < personality ; i++) {
out(i) = (bargraph) ? (in > i) : (in == i);
}
}
--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1916
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers