OpenCores
URL https://opencores.org/ocsvn/simple_customized_counter/simple_customized_counter/trunk

Subversion Repositories simple_customized_counter

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /simple_customized_counter
    from Rev 48 to Rev 49
    Reverse comparison

Rev 48 → Rev 49

/trunk/CounterLib.psC File deleted
/trunk/lib_CCounterEvent.vmc Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/lib_CCounterEvent.vmc Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: trunk/lib_CCounterOprEvent.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib_CCounterOprEvent.vmc =================================================================== --- trunk/lib_CCounterOprEvent.vmc (revision 48) +++ trunk/lib_CCounterOprEvent.vmc (nonexistent)
trunk/lib_CCounterOprEvent.vmc Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: trunk/lib_CCounterLevel.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib_CCounterLevel.vmc =================================================================== --- trunk/lib_CCounterLevel.vmc (revision 48) +++ trunk/lib_CCounterLevel.vmc (nonexistent)
trunk/lib_CCounterLevel.vmc Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: trunk/lib_CCounterOprLevel.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib_CCounterOprLevel.vmc =================================================================== --- trunk/lib_CCounterOprLevel.vmc (revision 48) +++ trunk/lib_CCounterOprLevel.vmc (nonexistent)
trunk/lib_CCounterOprLevel.vmc Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: trunk/lib/CounterLib.psC =================================================================== --- trunk/lib/CounterLib.psC (nonexistent) +++ trunk/lib/CounterLib.psC (revision 49) @@ -0,0 +1,175 @@ +// =================================================================== +// This is a library of counters +// =================================================================== +// Each counter supports: +// - Resetting +// - Counting up +// - Counting down +// - Loading a value from the input iLoadValue +// +// The code is straightforward, so you can easily create your own counter +// by changing the counter type or the operations. In fact you can +// create any functions like a shift register or even an +// ALU (Arithmetic and Logic Unit) or a calculator. +// +// The output always generates an event. +// If you don't want the event, remove the colon ':' in the value assignment. +// Ex: change oValue := 0; to oValue = 0; +// +// =================================================================== +// There are four counters in the library. +// +// The first two executes the operation on input events: +// - CCounterEvent: operations depends on inputs: iReset, iUp, iDown, iLoad +// - CCounterOprEvent: operations depends on a single input: iOpr +// +// The last two executes the operation at each step i.e. FPGA clock: +// - CCounterLevel: operations depends on inputs: iReset, iUp, iDown, iLoad +// - CCounterOprLevel: operations depends on a single input: iOpr +// +// =================================================================== +// TEST BENCHES: +// +// - CCounterEvent: Manual test with control panel +// Project in "TestCounterEvent" folder +// +// - CCounterOprEvent: Simulated DE1SoC board, you need the BSP +// Real DE1SoC board, you need the real board +// Project in "TestCounterOprEventBoard" folder +// Performed by a C++ program +// Project in "TestCounterOprEventAPI" folder +// << This project requires a paid license >> +// +// - CCounterLevel: Using signal editor and viewer +// Project in "TestCounterLevel" folder +// +// - CCounterOprLevel: Using signal editor and viewer +// Project in "TestCounterOprLevel" folder +// =================================================================== + +library CounterLib +{ + // ------------------------------------------------------------------- + // This counter executes the operation on input events + // There is a priority assigned to each function, in parenthesis + // 0 indicates highest priority + // and priority decreases with increasing value + // ------------------------------------------------------------------- + component CCounterEvent (in active bit iReset, + in active bit iUp, + in active bit iDown, + in active bit iLoad, + in passive ubyte iLoadValue, + out active ubyte oValue) + { + DoReset(0) on iReset + { + oValue := 0ub; + } + + CountUp(1) on iUp + { + oValue:++; + } + + CountDown(2) on iDown + { + oValue:--; + } + + LoadValue(3) on iLoad + { + oValue := iLoadValue; + } + }; + + // ------------------------------------------------------------------- + // This counter executes the operation at each step or FPGA clock cycle + // The priority is implemented with if and else instructions + // ------------------------------------------------------------------- + component CCounterLevel (in passive bit iReset, + in passive bit iUp, + in passive bit iDown, + in passive bit iLoad, + in passive ubyte iLoadValue, + out active ubyte oValue) + { + always() + { + if(iReset) + { + oValue := 0ub; + } + + else if(iUp) + { + oValue:++; + } + + else if(iDown) + { + oValue:--; + } + + else if(iLoad) + { + oValue := iLoadValue; + } + } + }; + + // ------------------------------------------------------------------- + // Define type and constants for the counter operation + // ------------------------------------------------------------------- + enum Opr_t { cOprNone, cOprReset, cOprUp, cOprDown, cOprLoad }; + + // ------------------------------------------------------------------- + // This counter executes the operation on input events. + // The input iOpr has the type Opr_t and determines the operation. + // There is no priority on the operation. + // ------------------------------------------------------------------- + // The switch statement has no break, only one case is executed + // ------------------------------------------------------------------- + component CCounterOprEvent (in active Opr_t iOpr, + in passive ubyte iLoadValue, + out active ubyte oValue) + { + ExecuteOpr(0) on iOpr + { + // The switch statement has no break, only one case is executed + switch(iOpr) + { + case cOprReset: oValue:= 0ub; + case cOprUp: oValue:++; + case cOprDown: oValue:--; + case cOprLoad: oValue := iLoadValue; + } + } + }; + + // ------------------------------------------------------------------- + // This counter executes the operation at each step or FPGA clock cycle + // The input iOpr has the type Opr_t and determines the operation + // There is no priority on the operations + // ------------------------------------------------------------------- + component CCounterOprLevel (in active Opr_t iOpr, + in passive ubyte iLoadValue, + out active ubyte oValue) + { + always() + { + // Send the event + oValue:; + + // Assign the value + // The switch instruction returns a value + oValue = switch(iOpr) + { + case cOprReset: 0ub; + case cOprUp: oValue + 1ub; + case cOprDown: oValue - 1ub; + case cOprLoad: iLoadValue; + }; + } + }; +}; Index: trunk/lib/lib_CCounterEvent.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib/lib_CCounterEvent.vmc =================================================================== --- trunk/lib/lib_CCounterEvent.vmc (nonexistent) +++ trunk/lib/lib_CCounterEvent.vmc (revision 49)
trunk/lib/lib_CCounterEvent.vmc Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/lib/lib_CCounterLevel.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib/lib_CCounterLevel.vmc =================================================================== --- trunk/lib/lib_CCounterLevel.vmc (nonexistent) +++ trunk/lib/lib_CCounterLevel.vmc (revision 49)
trunk/lib/lib_CCounterLevel.vmc Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/lib/lib_CCounterOprEvent.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib/lib_CCounterOprEvent.vmc =================================================================== --- trunk/lib/lib_CCounterOprEvent.vmc (nonexistent) +++ trunk/lib/lib_CCounterOprEvent.vmc (revision 49)
trunk/lib/lib_CCounterOprEvent.vmc Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/lib/lib_CCounterOprLevel.vmc =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/lib/lib_CCounterOprLevel.vmc =================================================================== --- trunk/lib/lib_CCounterOprLevel.vmc (nonexistent) +++ trunk/lib/lib_CCounterOprLevel.vmc (revision 49)
trunk/lib/lib_CCounterOprLevel.vmc Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.