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

Rev 62 → Rev 63

/simple_customized_counter/trunk/README.md
1,175 → 1,350

# *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|
 
 
![](vertopal_8eefa2297591417ea9479cdce5d0964b/media/image1.png){width="4.0in"
height="0.58in"}
 
*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:\
> -Licenses at:
>
> 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:
>
> *VERY IMPORTANT*
 
+-----------------------------------------------------------------------+
| > Folder paths and file names you create must not contain spaces or |
| > special characters. |
+=======================================================================+
+-----------------------------------------------------------------------+
 
> *[To begin with...]{.underline}*
 
-----------------------------------------------------------------------
First double-click ***CopyLib.bat***
-----------------------------------------------------------------------
 
-----------------------------------------------------------------------
 
> 1.Open the library:\
> [C:\\Novakod_Studio\\OpenCoresLib\\simple_customized_counter\\CounterLib.psC]{.underline}
> 2.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\
// ===================================================================
 
> 3.Have a look at the code of the four counter templates. 4.Select the
> test bench for the desired core.
 
+-----------------------------------+-----------------------------------+
| > Core | > Test bench |
+===================================+===================================+
| > CCounterEvent_T | > TestCounterEvent |
+-----------------------------------+-----------------------------------+
| > CCounterLevel_T | > TestCounterLevel |
+-----------------------------------+-----------------------------------+
 
> CCounterOprLevel_T CCounterOprEvent_T
>
> TestCounterOprLevel\
> TestCounterOprEventBoard\
> TestCounterOprEventAPI
 
5.Follow ReadMe.pdf in the selected folder. *Have fun!*
 
![](vertopal_8eefa2297591417ea9479cdce5d0964b/media/image2.png){width="4.463887795275591in"
height="0.5798556430446195in"}
 
> *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.
 
*―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.
 
*―Indentation*\
Indentation of 4 spaces, no tabulation, is recommended for compatibility
between editors.
 
*―Suffixes and prefixes*\
Here is a list of prefixes and suffixes specific to psC. You should use
them systematically.
 
+-----------------+-----------------+-----------------+-----------------+
| Prefix | Suffix | > Apply to | > Example |
+=================+=================+=================+=================+
+-----------------+-----------------+-----------------+-----------------+
 
<table>
<colgroup>
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
<col style="width: 8%" />
</colgroup>
<thead>
<tr class="header">
<th>C</th>
<th></th>
<th><blockquote>
<p>Component</p>
</blockquote></th>
<th colspan="9" rowspan="4"><blockquote>
<p>// Component Ports componentCTest(inintiP,</p>
</blockquote>
<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th><blockquote>
<p>{};</p>
</blockquote></th>
<th><blockquote>
<p>outintoP)</p>
</blockquote></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<blockquote>
<p>CTestPTest; // Process</p>
</blockquote></th>
</tr>
<tr class="odd">
<th>P</th>
<th></th>
<th><blockquote>
<p>Process</p>
</blockquote></th>
</tr>
<tr class="header">
<th>i</th>
<th></th>
<th><blockquote>
<p>Input port</p>
</blockquote></th>
</tr>
<tr class="odd">
<th>o</th>
<th></th>
<th><blockquote>
<p>Output port</p>
</blockquote></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td></td>
<td>_t</td>
<td><blockquote>
<p>Type</p>
</blockquote></td>
<td colspan="9"><blockquote>
<p>typedefint:3int3_t;</p>
</blockquote></td>
</tr>
<tr class="even">
<td>c</td>
<td></td>
<td><blockquote>
<p>Constant</p>
</blockquote></td>
<td colspan="3"><blockquote>
<p>constint<br />
constint<br />
constiden enumColor</p>
</blockquote></td>
<td colspan="6"><blockquote>
<p>Lines[]=1to2;<br />
Cols[]=1to3;<br />
ifiercId[]={ A,B,C }; t{ cRed,cGreen,cBlue };</p>
</blockquote></td>
</tr>
<tr class="odd">
<td>t</td>
<td></td>
<td>Temp variable</td>
<td colspan="2" rowspan="2"><blockquote>
<p>tempt tempf</p>
<p>functi</p>
</blockquote></td>
<td colspan="7" rowspan="2"><blockquote>
<p>Add=V1+V2;<br />
ix8tAdd(fix8pF0,fix8pF1) =pF0+pF1;</p>
</blockquote>
<p>functionfct(intpVal,ubytepTyp){};</p></td>
</tr>
<tr class="even">
<td>p</td>
<td></td>
<td><blockquote>
<p>Parameters</p>
</blockquote></td>
</tr>
<tr class="odd">
<td></td>
<td>_T</td>
<td><blockquote>
<p>Template</p>
</blockquote></td>
<td colspan="9" rowspan="3"><blockquote>
<p>template&lt; intNVAL,identifierNAME &gt; functionAdd_T(){};</p>
<p>functionAdd_T&lt;8, oPort&gt;Add_I;</p>
</blockquote></td>
</tr>
<tr class="even">
<td></td>
<td>_I</td>
<td><blockquote>
<p>Template instance</p>
</blockquote></td>
</tr>
<tr class="odd">
<td colspan="2"><blockquote>
<p>All Caps</p>
</blockquote></td>
<td><blockquote>
<p>Template<br />
parameters</p>
</blockquote></td>
</tr>
<tr class="even">
<td colspan="2"><blockquote>
<p>One to three<br />
capital letters</p>
</blockquote></td>
<td><blockquote>
<p>For…end<br />
parameters</p>
</blockquote></td>
<td colspan="9"><blockquote>
<p>forIin&lt;cRange&gt;</p>
</blockquote>
<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>end</th>
<th><blockquote>
<p>CIncPInc##I;</p>
</blockquote></th>
</tr>
</thead>
<tbody>
</tbody>
</table></td>
</tr>
<tr class="odd">
<td><blockquote>
<p>s_ g_</p>
</blockquote></td>
<td></td>
<td colspan="10"><blockquote>
<p>Reserved, do not use</p>
</blockquote></td>
</tr>
</tbody>
</table>

powered by: WebSVN 2.1.0

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