We considerer the counter as the "Hello World!" of digital systems, so the title...
By changing the template parameter TYPE you can instantiate counters from 2 to 64 bits. Each counter supports: reset, count up, count down and load value.
Counters are either event triggered or level controlled.
Some counters support priority. For example, the iReset has the highest priority and in case of simultaneous events, the counter will be reset. The priority can be easily changed depending on your needs.
The code is straightforward and you can easily customize the operations. For example you could make the counter increase by 2. You could also change a function to a shift, or with additional inputs, create an ALU - Arithmetic and Logic Unit, or a calculator.
Simply read the file ReadMe.pdf.
Here is the counter code showing only the interfaces. For more details, consult the ReadMe.pdf files.
template <identifier TYPE>
component CCounterEvent_T (in active bit iReset,
in active bit iUp,
in active bit iDown,
in active bit iLoad,
in passive TYPE iLoadValue,
out active TYPE oValue)
{ ... };
template <identifier TYPE>
component CCounterLevel_T (in active bit iReset,
in active bit iUp,
in active bit iDown,
in active bit iLoad,
in passive TYPE iLoadValue,
out active TYPE oValue)
{ ... };
};
enum Opr_t { cOprNone, cOprReset, cOprUp, cOprDown, cOprLoad };
template <identifier TYPE>
component CCounterOprEvent_T (in active Opr_t iOpr,
in passive TYPE iLoadValue,
out active TYPE oValue)
{ ... };
template <identifier TYPE>
component CCounterOprLevel_T (in active Opr_t iOpr,
in passive TYPE iLoadValue,
out active TYPE oValue)
{ ... };