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/trunk/OpenCoresLib/simple_customized_counter
    from Rev 55 to Rev 58
    Reverse comparison

Rev 55 → Rev 58

/CounterLib.psC
1,6 → 1,11
// ===================================================================
// This is a library of counters
// This is a library of counter templates
// ===================================================================
// Template parameter:
// - TYPE determines the type of the counter
// Ex: TYPE = ubyte creates an 8 bits unsigned counter
//
// ===================================================================
// Each counter supports:
// - Resetting
// - Counting up
8,9 → 13,9
// - 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.
// by changing 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 assignment.
17,34 → 22,34
// Ex: change oValue := 0; to oValue = 0;
//
// ===================================================================
// There are four counters in the library.
// There are four counter templates 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
// - CCounterEvent_T: operations depends on inputs: iReset, iUp, iDown, iLoad
// - CCounterOprEvent_T: 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
// - CCounterLevel_T: operations depends on inputs: iReset, iUp, iDown, iLoad
// - CCounterOprLevel_T: operations depends on a single input: iOpr
//
// ===================================================================
// TEST BENCHES:
//
// - CCounterEvent: Manual test with control panel
// Project in "TestCounterEvent" folder
// - CCounterEvent_T: 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 >>
// - CCounterOprEvent_T: 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
// - CCounterLevel_T: Using signal editor and viewer
// Project in "TestCounterLevel" folder
//
// - CCounterOprLevel: Using signal editor and viewer
// Project in "TestCounterOprLevel" folder
// - CCounterOprLevel_T: Using signal editor and viewer
// Project in "TestCounterOprLevel" folder
// ===================================================================
 
library CounterLib
55,16 → 60,17
// 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)
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)
{
DoReset(0) on iReset
{
oValue := 0ub;
oValue := (TYPE)0;
}
 
CountUp(1) on iUp
87,18 → 93,19
// 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)
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)
{
always()
{
if(iReset)
{
oValue := 0ub;
oValue := (TYPE)0;
}
 
else if(iUp)
130,9 → 137,10
// -------------------------------------------------------------------
// 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)
template <identifier TYPE>
component CCounterOprEvent_T (in active Opr_t iOpr,
in passive TYPE iLoadValue,
out active TYPE oValue)
{
ExecuteOpr(0) on iOpr
{
139,7 → 147,7
// The switch statement has no break, only one case is executed
switch(iOpr)
{
case cOprReset: oValue:= 0ub;
case cOprReset: oValue:= (TYPE)0;
case cOprUp: oValue:++;
case cOprDown: oValue:--;
case cOprLoad: oValue := iLoadValue;
152,9 → 160,10
// 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)
template <identifier TYPE>
component CCounterOprLevel_T (in active Opr_t iOpr,
in passive TYPE iLoadValue,
out active TYPE oValue)
{
always()
{
165,7 → 174,7
// The switch instruction returns a value
oValue = switch(iOpr)
{
case cOprReset: 0ub;
case cOprReset: (TYPE)0;
case cOprUp: oValue + 1ub;
case cOprDown: oValue - 1ub;
case cOprLoad: iLoadValue;

powered by: WebSVN 2.1.0

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