0

No, I need the shortest possible solution, preferably with macro folding.

1 Answer 1

0

Here is how I did this, cascading Repeat macros:

Name     8-bit counter ;
PartNo   MIC20181 ;
Date     2015/2/8 ;
Revision 01 ;
Designer Engineer ;
Company  Donghua University ;
Assembly None ;
Location  ;
Device   g16v8 ;

/* Input pins */

Pin 1 = CLK;
Pin 11 = GND;

/* Output pins */

PinNode [12..19] = [Q7..0];

Append Q0.D = !Q0;

Append Q1.D = !Q1 & Q0;
Append Q1.D = Q0 & !Q1;

$Repeat P = [2..7]
$Repeat R = [{P - 1}..0]
Append Q{P}.D = Q{P} & !Q{R};
$RepEnd
Append Q{P}.D = !Q{P} & !([Q{P-1}..0]:#);
$RepEnd

The trick here is how I (ab)used $Repeat macros.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.