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 11 to Rev 12
- ↔ Reverse comparison
Rev 11 → Rev 12
/CounterLib.psC
File deleted
/Counter.rpj
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Counter.rpj
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: src/CCounter.vmc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/CCounter.vmc
===================================================================
--- src/CCounter.vmc (revision 11)
+++ src/CCounter.vmc (nonexistent)
src/CCounter.vmc
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: src/main.vmc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/main.vmc
===================================================================
--- src/main.vmc (revision 11)
+++ src/main.vmc (nonexistent)
src/main.vmc
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: src/main.vms
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/main.vms
===================================================================
--- src/main.vms (revision 11)
+++ src/main.vms (nonexistent)
src/main.vms
Property changes :
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: targets/Manual.env
===================================================================
--- targets/Manual.env (revision 11)
+++ targets/Manual.env (nonexistent)
@@ -1,54 +0,0 @@
-[Device 1]
-
- path = apisimdrv.dll
- type = LOCAL
- parameters = ".\!!gen!!.sym" ".\targets\Manual_.env" %NbPorts% %NbPorts%
-
-[Port 1]
-
- name = iReset
- mapping_type = data
- device_number = 1
- data_index = 1
- byte_length = 1
-
-[Port 2]
-
- name = iUp
- mapping_type = data
- device_number = 1
- data_index = 2
- byte_length = 1
-
-[Port 3]
-
- name = iDown
- mapping_type = data
- device_number = 1
- data_index = 3
- byte_length = 1
-
-[Port 4]
-
- name = oValue
- mapping_type = data
- device_number = 1
- data_index = 4
- byte_length = 1
-
-[Port 5]
-
- name = iLoad
- mapping_type = data
- device_number = 1
- data_index = 5
- byte_length = 1
-
-[Port 6]
-
- name = iLoadValue
- mapping_type = data
- device_number = 1
- data_index = 6
- byte_length = 1
-
Index: TestCounterEv/src/CCounter.vmc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: TestCounterEv/src/CCounter.vmc
===================================================================
--- TestCounterEv/src/CCounter.vmc (nonexistent)
+++ TestCounterEv/src/CCounter.vmc (revision 12)
TestCounterEv/src/CCounter.vmc
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: TestCounterEv/src/main.vmc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: TestCounterEv/src/main.vmc
===================================================================
--- TestCounterEv/src/main.vmc (nonexistent)
+++ TestCounterEv/src/main.vmc (revision 12)
TestCounterEv/src/main.vmc
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: TestCounterEv/src/main.vms
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: TestCounterEv/src/main.vms
===================================================================
--- TestCounterEv/src/main.vms (nonexistent)
+++ TestCounterEv/src/main.vms (revision 12)
TestCounterEv/src/main.vms
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: TestCounterEv/targets/Manual.env
===================================================================
--- TestCounterEv/targets/Manual.env (nonexistent)
+++ TestCounterEv/targets/Manual.env (revision 12)
@@ -0,0 +1,54 @@
+[Device 1]
+
+ path = apisimdrv.dll
+ type = LOCAL
+ parameters = ".\!!gen!!.sym" ".\targets\Manual_.env" %NbPorts% %NbPorts%
+
+[Port 1]
+
+ name = iReset
+ mapping_type = data
+ device_number = 1
+ data_index = 1
+ byte_length = 1
+
+[Port 2]
+
+ name = iUp
+ mapping_type = data
+ device_number = 1
+ data_index = 2
+ byte_length = 1
+
+[Port 3]
+
+ name = iDown
+ mapping_type = data
+ device_number = 1
+ data_index = 3
+ byte_length = 1
+
+[Port 4]
+
+ name = oValue
+ mapping_type = data
+ device_number = 1
+ data_index = 4
+ byte_length = 1
+
+[Port 5]
+
+ name = iLoad
+ mapping_type = data
+ device_number = 1
+ data_index = 5
+ byte_length = 1
+
+[Port 6]
+
+ name = iLoadValue
+ mapping_type = data
+ device_number = 1
+ data_index = 6
+ byte_length = 1
+
Index: TestCounterEv/Counter.rpj
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: TestCounterEv/Counter.rpj
===================================================================
--- TestCounterEv/Counter.rpj (nonexistent)
+++ TestCounterEv/Counter.rpj (revision 12)
TestCounterEv/Counter.rpj
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: TestCounterEv/CounterLib.psC
===================================================================
--- TestCounterEv/CounterLib.psC (nonexistent)
+++ TestCounterEv/CounterLib.psC (revision 12)
@@ -0,0 +1,163 @@
+library CounterLib
+{
+ // ===================================================================
+ // This is a library of counters
+ // Each counter supports:
+ // - resetting
+ // - counting up
+ // - counting down
+ // - loading a value from the input iLoad
+ //
+ // The code is straightforward, so you can easily create your own counter
+ // 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
+ // 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 Opr event
+ // - CCounterOprLevel: executes the operation at each step
+ //
+ // TESTING:
+ // - 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)
+ {
+ 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 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 { 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)
+ {
+ // 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
+ {
+ 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 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)
+ {
+ 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;
+ };
+ }
+ };
+
+};