Design of A Basic Block
Design of A Basic Block
Design of A Basic Block
2 Root Folder
Once you have downloaded the example you may open the project which contains the
following directories and files:
Directories:
o apps: Contains test applications and examples.
o config: Contains different configuration files which must not be modified.
o lib: Contains source files (.cc and .h) for the developed blocks.
o swig: As GNU Radio combines C++ programmed blocks with Python
flowgraphs, Swig tool is employed to automatically generate python
interfaces for C++ blocks. .i files required by this tool are stored in this
folder.
o python: Contains python scripts.
o grc: Contains the .xml files needed by the grc tool.
Each folder contains a Makefile.am file because autotools (autoconf, automake and
libtool) are employed in order to automatically compile and link. Also due to this tools
the following files are included in the root folder: AUTHORS, bootstrap, ChangeLog,
config.guess, config.sub, configure.ac, Makefile.am, Makefile.common, Makefile.swig,
Makefile.swig.gen.t, NEWS, README, README.hacking, version.sh.
3 lib Folder
This folder contains all the C++ source files (gr_my_amplifier_ff.cc and
gr_my_amplifier_ff.h) and the Makefile.am for compilation. All the signal processing
functionality of the block is inserted in the work method of the .cc file. In the amplifier
this method is as follows:
int gr_my_amplifier_ff::work
(int noutput_items, gr_vector_const_void_star &
input_items,gr_vector_void_star &output_items) {
const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];
for (int i = 0; i < noutput_items; i++){
out[i] = in[i] * (float)d_k;
}
return noutput_items;
}
Obviously this a very simple example of a variable gain amplifier with little signal
processing, but your code may be as complex as you desire.
4 swig Folder
This folder contains the files employed by the SWIG tool to create python interfaces for
C++ classes. These files are: gr_my.i, gr_my_amplifier_ff.i, Makefile.am and
Makefile.swig.gen. Astonishingly, the provided Makefile.swig.gen file is incorrect and
must be regenerated afterwards (explained in section 6) but surely due to a
configuration error the autotools need it in order to work correctly.
5 grc Folder
This folder contains the files employed by the grc tool, i.e. the definition file
myBlock.xml and the compilation one Makefile.am.
myBlock.xml
tag name: the name we want to assign to our block in the graphical interface.
tag category: The folder in which our block will be clasified in the graphical
interface.
tag calback: Includes the methods for changing the attributes related to the
tag chek: Checking rules for all the parameters, e.g. param1>= 1
tags sink and source: The example is prepared for one input and one output.
Otherwise, add as many entries as inputs/outputs.
o myFolder: Name of the folder containing the new module. Although there
are no indications for its naming. A uniform name could be gr-my-module.
o make_myBlock: Name of the public constructor of our blocks C++ class.
o param1: Name of our blocks input parameter (we are considering only
one parameter in the template)
o d_param1: internal attribute of our blocks class. It is permanently
associated to the input parameter. According to GNU Radio naming
convention the d prefix is added.
o grcName: Name of the developed block in the grc interface.
o grcParam1: internal name of the parameter in the grc.
o grcParam1Name: name of the parameter in the graphical interface.
o grcParamType: data type of the parameter.