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 61 to Rev 62
    Reverse comparison

Rev 61 → Rev 62

/trunk/README.md
0,0 → 1,175

# *Counter Library*
***Novakod Studio*** is the integrated development environment (IDE) for the ***psC language***.
 
- Cores in this library use the psC language.
- Compiling the core with the IDE generates ***Quality VHDL code***.
- The generated VHDL code can be used in any FPGA project.
- You can use the cores as is or create your own customized core.
- You can also use Novakod Studio for any FPGA applications, then generate VHDL.
 
*Materials*
 
You need ***Novakod Studio*** and the ***DE1SoC BSP*** (Board Support Package)
 
- Download at: [https://icitechno.com/download](https://icitechno.com/download%20)
- Licenses at: <https://icitechno.com/licenses>
 
If you want to experiment with a real board, you need the DE1SoC board. This board is fully integrated into Novakod Studio. ***psC programs run without modification on the real board***.
 
- Buy at: [Terasic](https://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&No=836)
 
*VERY IMPORTANT*
 
Folder paths and file names you create must not contain spaces or special characters.
#### *To begin with…*
First double-click ***CopyLib.bat***
 
1. Open the library: [C:\Novakod_Studio\OpenCoresLib\simple_customized_counter\CounterLib.psC](file:///C:\Novakod_Studio\OpenCoresLib\simple_customized_counter\CounterLib.psC)
1. Here is the first part of the counter library:
 
// ===================================================================
 
// 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
 
// - Counting down
 
// - Loading a value from the input iLoadValue
 
//
 
// The code is straightforward, so you can easily create your own counter
 
// 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.
 
// Ex: change oValue := 0; to oValue = 0;
 
//
 
// ===================================================================
 
// There are four counter templates in the library.
 
//
 
// The first two executes the operation on input events:
 
// - 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\_T: operations depends on inputs: iReset, iUp, iDown, iLoad
 
// - CCounterOprLevel\_T: operations depends on a single input: iOpr
 
//
 
// ===================================================================
 
// TEST BENCHES:
 
//
 
// - CCounterEvent\_T: Manual test with control panel
 
// Project in "TestCounterEvent" folder
 
//
 
// - 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\_T: Using signal editor and viewer
 
// Project in "TestCounterLevel" folder
 
//
 
// - CCounterOprLevel\_T: Using signal editor and viewer
 
// Project in "TestCounterOprLevel" folder
 
// ===================================================================
 
1. Have a look at the code of the four counter templates.
1. Select the test bench for the desired core.
 
|Core|Test bench|
| - | - |
|CCounterEvent\_T|TestCounterEvent|
|CCounterLevel\_T|TestCounterLevel|
|CCounterOprLevel\_T|TestCounterOprLevel|
|CCounterOprEvent\_T|<p>TestCounterOprEventBoard</p><p>TestCounterOprEventAPI</p>|
1. Follow ReadMe.pdf in the selected folder.
 
*Have fun!*
# *Basic coding rules*
#### *Print this page...*
The psC language is based on C++ syntax and everything you learned about designing, coding and documenting C++ programs can be used with psC. You should look at the examples to get a good feeling for the coding style.
1. #### *Naming convention*
As in C++, carefully choose names for variables, ports, functions, components, and so on, to reflect their usage. This must be done as early as possible as it greatly improves readability. In psC, the recommended naming convention is capitalized first word letter, like ExeOpr.
1. #### *Indentation*
Indentation of 4 spaces, no tabulation, is recommended for compatibility between editors.
1. #### *Suffixes and prefixes*
Here is a list of prefixes and suffixes specific to psC. You should use them systematically.
 
|Prefix|Suffix|Apply to|Example|
| - | - | - | - |
|C||Component|<p>// Component Ports</p><p>component* CTest* (in* int* iP,* </p><p>` `out* int* oP)* </p><p>{* };</p><p></p><p>CTest* PTest; // Process</p>|
|P||Process||
|i||Input port||
|o||Output port||
||\_t|Type|typedef* int:3* int3\_t;|
|c||Constant|<p>const* int* cLines[]* =* 1* to* 2;</p><p>const* int* cCols* []* =* 1* to* 3;</p><p>const* identifier* cId[]* =* { A,* B,* C };</p><p>enum* Color\_t* { cRed,* cGreen,* cBlue };</p>|
|t||Temp variable|<p>temp* tAdd* =* V1* +* V2;</p><p>temp* fix8* tAdd(fix8* pF0,* fix8* pF1) =* pF0* +* pF1; </p><p>function* fct(int* pVal,* ubyte* pTyp)* {* };</p>|
|p||Parameters||
||\_T|Template|<p>template< int* NVAL, identifier* NAME ></p><p>* function* Add\_T(* )* {* };</p><p></p><p>function* Add\_T<8, oPort>* Add\_I;</p>|
||\_I|Template instance||
|All Caps|Template parameters||
|One to three capital letters|For…end parameters|<p>for* I* in* <cRange></p><p>* CInc* PInc##I;</p><p>end</p>|
|s\_ g\_||Reserved, do not use|
 
 

powered by: WebSVN 2.1.0

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