SystemC Development with CapsimTMK

Description

SystemC Development

 

Getting Started

Download

Blocks

Sample Applications

SystemC Resources

Sample SystemC Applications

IIR Filter Example

Check here for IIR Filter Example.

Simple Sine Wave and Gain Example

The simple block diagram below goes a long way to explain how it all works. The sinesc block generates a sinusoidal sample on each positive edge of the clock and the gainsc block multiplies the sample by a factor provided as a parameter and the printsc block prints the sample to the console.

The topology describing the block diagram and generated by CapsimTMK is shown here. The XML Topology description generated from the topology and used to generate the SystemC code main.cpp is shown here.

In the SystemC Block Diagram system, each block is divided into sections. The key sections are:

SystemC Block Key Sections
XML Section Description Tag
Parameters Defines parameters for the block that can be changed interactively prior to saving a topology and executing SystemC executable . Default values supported. <PARAMETERS>
Input Ports Input ports can be int,float, double. If SystemC to support must include appropriate include files (stars.h etc). <INPUT_BUFFERS>
Output Ports Output ports can be int,float, double. If SystemC to support must include appropriate include files (stars.h etc). <OUTPUT_BUFFERS>
States These are SystemC and C variables that maintain state in the block between clock cycles. Default values supported. <STATES>
Declarations Variables used in the run-time or initialization code. <DECLARATIONS>
Initialization Code that is executed upon system reset (rst_n neg edge) <INIT_CODE>
Run-Time Code that is executed each clock cycle. <MAIN_CODE>
   

The sinesc block generates a sinusoid with amplitude, frequency and phase determined by the parameters. Since it is a source block the number of samples is also specified. It will stop SystemC after the specified number of samples have been generated and output.

The gainsc block inputs floating point samples on each clock and multiplies the sample by a gain specified in the parameter. It outputs the sample.

The printsc block inputs a floating point sample on each clock and prints it to the console (stdout).

Each block is converted to a SystemC include file that is included in main.cpp which instantiates the block, sets its parameters and connects the clock and reset as well as making the connections to the other blocks.

Blocks and Conversions
XML SystemC
SystemC Header Block
C Stub Block
sinesc.c
gainsc.c
printsc.c

See main.cpp for instantiation and connections.

The topology generated by CapsimTMK is shown here.

The XML Topology from which main.cpp is generated is shown here.

CapsimTMK Topology


# topology file: example.t
#--------------------------------------------------- 
# Title: 
# Author: 
# Date: 
# Description: 
#--------------------------------------------------- 
inform title 
inform author 
inform date 
inform descrip 
arg -1 (none)
param int 9999 num_of_samples "total number of samples to output"
param float 1 magnitude "Enter Magnitude"
param float 32000 fs "Enter Sampling Rate"
param float 1000 freq "Enter Frequency"
param float 0 phase "Enter Phase"
block sinesc0 sinesc
param float 1 factor "Gain factor"
block gainsc0 gainsc
param float 1 factor "Gain factor"
block printsc0 printsc
connect sinesc0 0 gainsc0 0 {sinesc0:y:float,gainsc0:x:float}
connect gainsc0 0 printsc0 0 {gainsc0:y:float,printsc0:x:float}

 

XML Topology Generated from CapsimTMK Topology

<TOPOLOGY>
<INFORMATION>
 <INFO><ELEMENT>title</ELEMENT><TEXT></TEXT></INFO>
 <INFO><ELEMENT>author</ELEMENT><TEXT></TEXT></INFO>
 <INFO><ELEMENT>date</ELEMENT><TEXT></TEXT></INFO>
 <INFO><ELEMENT>descrip</ELEMENT><TEXT></TEXT></INFO>
 </INFORMATION>
<ARGUMENTS>
   <ARG><NUMBER>-1</NUMBER><TYPE>(none)</TYPE><VALUE></VALUE><DEF>arg</DEF></ARG>
</ARGUMENTS>
    
<BLOCKS>
<BLOCK_INST> <PARAMETERS> <PARAM><TYPE>int</TYPE><VALUE>128</VALUE><NAME>num_of_samples</NAME><DEF>"total number of samples to output"</DEF></PARAM> <PARAM><TYPE>float</TYPE><VALUE>1</VALUE><NAME>magnitude</NAME><DEF>"Enter Magnitude"</DEF></PARAM> <PARAM><TYPE>float</TYPE><VALUE>32000</VALUE><NAME>fs</NAME><DEF>"Enter Sampling Rate"</DEF></PARAM> <PARAM><TYPE>float</TYPE><VALUE>1000</VALUE><NAME>freq</NAME><DEF>"Enter Frequency"</DEF></PARAM> <PARAM><TYPE>float</TYPE><VALUE>0</VALUE><NAME>phase</NAME><DEF>"Enter Phase"</DEF></PARAM> </PARAMETERS> <BLOCK><NAME>sinesc0</NAME><MODEL>sinesc</MODEL></BLOCK> </BLOCK_INST>
  <BLOCK_INST>
    <PARAMETERS>
       <PARAM><TYPE>float</TYPE><VALUE>1</VALUE><NAME>factor</NAME><DEF>"Gain factor"</DEF></PARAM>
    </PARAMETERS>
    <BLOCK><NAME>gainsc0</NAME><MODEL>gainsc</MODEL></BLOCK>
  </BLOCK_INST>
    
  <BLOCK_INST>
     <BLOCK><NAME>printsc0</NAME><MODEL>printsc</MODEL></BLOCK>
  </BLOCK_INST>
</BLOCKS>
<CONNECTIONS>
  <CONNECT>
    <FROM>
       <NAME>sinesc0</NAME><PORT>0</PORT><PNAME>y</PNAME><PTYPE>float</PTYPE>
    </FROM>
    <TO>
       <NAME>gainsc0</NAME><PORT>0</PORT><PNAME>x</PNAME><PTYPE>float</PTYPE>
    </TO>
   </CONNECT>
   <CONNECT>
      <FROM>
        <NAME>gainsc0</NAME><PORT>0</PORT><PNAME>y</PNAME><PTYPE>float</PTYPE>
      </FROM>
      <TO>
        <NAME>printsc0</NAME><PORT>0</PORT><PNAME>x</PNAME><PTYPE>float</PTYPE>
      </TO>
   </CONNECT>
</CONNECTIONS>
</TOPOLOGY>

 


Contact | ©2007 Silcon DSP Corporation , Portland, Oregon