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
    /
    from Rev 9 to Rev 10
    Reverse comparison

Rev 9 → Rev 10

/simple_customized_counter/trunk/CounterLib.psC
1,5 → 1,6
library CounterLib
{
// ===================================================================
// This is a library of counters
// Each counter supports:
// - resetting
11,34 → 12,37
// by changing the counter type or the operations
//
// The output always generates an event.
// If you don't want the event, remove the colon ':' in the value assignment
// -- oValue := 0
// If you don't want the event, remove the colon ':' in the value assignment
// change oValue := 0; to oValue = 0;
//
// There are four counters in the library:
// - CCounterEvent: executes the operation on separate input events
// - CCounterLevel: executes the operation at each step based
// - CCounterEvent: executes the operation on input events
// - CCounterLevel: executes the operation at each step
// - CCounterOprEvent: executes the operation on input Opr event
// - CCounterOprLevel: executes the operation at each step
// the operation is encoded on the input iOpr
//
// TESTING:
// - CCounterEvent: manual test with control panel
// - CCounterLevel: using waveform editor and viewer
// - CCounterOprLevel: using waveform editor and viewer
// - CCounterOprEvent: simulated and real DE1SoC board
// controlled by a C++ program
// - CCounterEvent: Manual test with control panel
// - CCounterLevel: Using waveform editor and viewer
// - CCounterOprLevel: Using waveform editor and viewer
// - CCounterOprEvent: > Smulated DE1SoC board, you only need the BSP
// > Real DE1SoC board, you need the board
// > Controlled by a C++ program
// ===================================================================
// -------------------------------------------------------------------
// 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)
in active bit iUp,
in active bit iDown,
in active bit iLoad,
in passive ubyte iLoadValue,
out active ubyte oValue)
{
// 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
 
DoReset(0) on iReset
{
oValue := 0ub;
60,16 → 64,17
}
};
// -------------------------------------------------------------------
// This counter executes the operation at each step or 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)
in passive bit iUp,
in passive bit iDown,
in passive bit iLoad,
in passive ubyte iLoadValue,
out active ubyte oValue)
{
// This counter executes the operation at each step or clock pulse
// The priority is implemented with if and else instructions
 
always()
{
if(iReset)
94,11 → 99,21
}
};
 
// -------------------------------------------------------------------
// Define type and constants for the counter operation
// -------------------------------------------------------------------
enum Opr_t { cOprReset, cOprUp, cOprDown, cOprLoad };
 
// -------------------------------------------------------------------
// This counter executes the operation on iOpr input event
// The input iOpr has the type Opr_t, see above
// There is no priority on the operations
// -------------------------------------------------------------------
// The switch statement has no break, only one case is executed
// -------------------------------------------------------------------
component CCounterOprEvent (in active Opr_t iOpr,
in active ubyte iLoadValue,
out active ubyte oValue)
in active ubyte iLoadValue,
out active ubyte oValue)
{
// This counter executes the operation on iOpr input event
// The input iOpr has the type Opr_t, see above
120,12 → 135,14
 
};
// -------------------------------------------------------------------
// This counter executes the operation at each step or clock cycle
// The priority is implemented with if and else instructions
// -------------------------------------------------------------------
component CCounterOprLevel (in active Opr_t iOpr,
in active ubyte iLoadValue,
out active ubyte oValue)
in active ubyte iLoadValue,
out active ubyte oValue)
{
// This counter executes the operation at each steo or clock pulse
// The priority is implemented with if and else instructions
always()
{
// Send the event

powered by: WebSVN 2.1.0

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