Counter constructor
Creates a Counter of width bits driven by clk.
Increments on each rising edge when en is high.
reset synchronously clears the count to zero.
Implementation
Counter(
Logic en,
Logic reset,
Logic clk, {
this.width = 8,
super.name = 'counter',
}) : super(definitionName: 'Counter_W$width') {
en = addInput('en', en);
reset = addInput('reset', reset);
clk = addInput('clk', clk);
addOutput('val', width: width);
val <= flop(clk, reset: reset, en: en, val + 1);
}