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
    from Rev 23 to Rev 24
    Reverse comparison

Rev 23 → Rev 24

/CounterLib.psC
2,26 → 2,29
// This is a library of counters
// ===================================================================
// Each counter supports:
// - resetting
// - counting up
// - counting down
// - loading a value from the input iLoad
// - 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
// by changing the counter type or the operations. In fact you can
// create any functions like a shift register and 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
// change oValue := 0; to oValue = 0;
// Ex: change oValue := 0; to oValue = 0;
//
// ===================================================================
// There are four counters in the library:
// - CCounterEvent: executes the operation on input events
// - CCounterLevel: executes the operation at each step
// - CCounterOprEvent: executes the operation on input iOpr event
// - CCounterOprLevel: executes the operation at each step
// - CCounterOprEvent: executes the operation on input event using iOpr
// - CCounterOprLevel: executes the operation at each step using iOpr
//
// ===================================================================
// TESTING:
// TEST BENCHES:
// - CCounterEvent: Manual test with control panel
// Project in "TestCounterEvent" folder
// - CCounterLevel: Using waveform editor and viewer
109,27 → 112,22
// -------------------------------------------------------------------
// Define type and constants for the counter operation
// -------------------------------------------------------------------
enum Opr_t { cOprReset, cOprUp, cOprDown, cOprLoad };
enum Opr_t { cOprNone, cOprReset, cOprUp, cOprDown, cOprLoad };
 
// -------------------------------------------------------------------
// This counter executes the operation on iOpr input event
// The input iOpr has the type Opr_t, see above
// This counter executes the operation at each step or clock cycle
// The input iOpr has the type Opr_t and determines the operation
// 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)
component CCounterOprEvent (in active Opr_t iOpr,
in passive 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
// There is no priority on the operations
//
// The switch statement has no break, only one case is executed
 
ExecuteOpr(0) on iOpr
{
// The switch statement has no break, only one case is executed
switch(iOpr)
{
case cOprReset: oValue:= 0ub;
142,11 → 140,12
// -------------------------------------------------------------------
// This counter executes the operation at each step or clock cycle
// The priority is implemented with if and else instructions
// 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 active ubyte iLoadValue,
out active ubyte oValue)
component CCounterOprLevel (in active Opr_t iOpr,
in passive ubyte iLoadValue,
out active ubyte oValue)
{
always()
{
/ReadMe.txt
1,5 → 1,5
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
You will need Novakod Studio and DE1SoC BSP (Board Support Package)
You will need Novakod Studio and the DE1SoC BSP (Board Support Package)
Go to: https://icitechno.com/download
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 

powered by: WebSVN 2.1.0

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