OpenCores

Hello Digital World Counter

Project maintainers

Details

Name: simple_customized_counter
Created: Mar 3, 2023
Updated: Mar 7, 2023
SVN Updated: Mar 8, 2023
SVN: Browse
Latest version: download (might take a bit to start...)
Statistics: View
Bugs: 0 reported / 0 solved
Star0you like it: star it!

Other project properties

Category:Arithmetic core
Language:Other
Development status:Stable
Additional info:
WishBone compliant: No
WishBone version: n/a
License: LGPL

This is a library of counter templates

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.

Operation

Counters are either event triggered or level controlled.

  • Event triggered counter value changes for events at the inputs. For example, in there is an event on input iUp, the counter value will change on the next step or FPGA clock cycle.
  • Level controlled counters are the usual counters. At each step or FPGA clock cycle, the counter value changes according to the level of the inputs. For example, if the input iUp is one, then the counter will increase at the next step.

Priority

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.

Customize

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.

Where to start

Simply read the file ReadMe.pdf.

Counter code

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)
{ ... };