module onescnt7
title 'Count the ones in a 7-bit word' 
"ONESCNT1 device 'P22V10'; 

" Input and output pins 
D6..D0                pin 1..7;
SUM2..SUM0            pin 17..19 istype 'com';
SA1..SA0              pin 14..15 istype 'com';
SB1..SB0              pin 22..23 istype 'com';

equations

"@CARRY 1;
[SA1..SA0] = D0 + D1 + D2;
[SB1..SB0] = D3 + D4 + D5;
[SUM2..SUM0] = [0, SA1..SA0] + [0, SB1..SB0] + [0, 0, D6];

end onescnt7
