This is the inverse of the mux components. It takes an integer value and
decodes it to up to 16 outputs. For instance if the input is 6, output 6
will be on and all others off. It also supports a bargraph mode for
things such as load meters. In that case for an input of 6 outputs 0-5
would be on.
Les
/********************************************************************
* 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 demux16 """Turn on one of 16 outputs depending on one input\
""";
pin in u32 in """input in the range 0-15.\
""";
pin out bit out00;
pin out bit out01;
pin out bit out02;
pin out bit out03;
pin out bit out04;
pin out bit out05;
pin out bit out06;
pin out bit out07;
pin out bit out08;
pin out bit out09;
pin out bit out10;
pin out bit out11;
pin out bit out12;
pin out bit out13;
pin out bit out14;
pin out bit out15 """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""";
function _;
license "GPL";
;;
FUNCTION(_) {
if(bargraph)
{
out00 = (in > 0);
out01 = (in > 1);
out02 = (in > 2);
out03 = (in > 3);
out04 = (in > 4);
out05 = (in > 5);
out06 = (in > 6);
out07 = (in > 7);
out08 = (in > 8);
out09 = (in > 9);
out10 = (in > 10);
out11 = (in > 11);
out12 = (in > 12);
out13 = (in > 13);
out14 = (in > 14);
out15 = (in > 15);
}else
{
out00 = (in == 0);
out01 = (in == 1);
out02 = (in == 2);
out03 = (in == 3);
out04 = (in == 4);
out05 = (in == 5);
out06 = (in == 6);
out07 = (in == 7);
out08 = (in == 8);
out09 = (in == 9);
out10 = (in == 10);
out11 = (in == 11);
out12 = (in == 12);
out13 = (in == 13);
out14 = (in == 14);
out15 = (in == 15);
}
}
------------------------------------------------------------------------------
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