Using Compiled Modules
One of the strengths of the ROCCC toolset is its focus on modular bottom-up designs through code reuse. This is done by calling already finished modules inside of other ROCCC components. For example, let’s look at the following three modules below which each calculate the volume of some specific piece of geometry.
![]() |
Volume of Cylinder = PI * r^2 * h |
|
Volume of Cone = PI / 3 * r^2 * h |
|
|
Volume of Pyramid = r * h / 3 |
If we have coded and compiled each of these modules, they would exist in our database and we will be able to see the details of each one inside our IP Cores view. Each one of these modules takes in two inputs and one output, all of type float.

Calling Modules in the Database
With modules inside our IP Cores database, we can begin to reuse them in future components without having to recode any of them. So to give an example of how this works, let’s make a simple volume calculator that will compute either the volume of a cone, cylinder, or pyramid depending on what value we pass to it. The value 0 will correspond to the cylinder, 1 for the cone, and 2 for the pyramid. Start by creating a new module with two float inputs, one select line, and a result output. We can then set up the control flow to call our correct volume computation depending on what value the select line has.

Now that we have our structure in place, all we need to do is call our previously coded modules in each of the correct spots. Let’s start with calling the volumeOfCylinder module when the select line is equal to 0. Place your mouse cursor in your code where you want the module call to be placed.
Go to the IP Cores view and find the volumeOfCylinder component. To add a call to this module in our code, double click the name of the volumeOfCylinder component.

This will automatically insert a function call to that module in our code. It will outline what values need to be passed in at which locations via comments in the argument list. It will also insert the line “#include roccc-library.h” at the top of your code so you can call that function.

So now that we have our function call in place, we can start passing the necessary values into the function call. We will place radius and height as the two inputs, and have the result stored to our volume output.

Now that we know how to insert a call to a component that is in the IP Cores database, we can go ahead and finish our calculator by inserting a call to volumeOfCone when the select line is 1 and a call to volumeOfPyramid when the select line is 2. Again, do this by moving your cursor to where you want the call to be inserted and double click the desired module in the IP Cores view.
It is suggested that you always use this method when calling a module rather than hand writing it because the port order of the function call may not match the order the ports were created in the module you are calling.

Once you have all three module calls in place, compile the module and vhdl code will be generated for our calculator. ROCCC will instantiate these inserted module calls in the VHDL and hook up all the signals correctly for you.
| << System Construction | Tutorials Home | Adding and Using External Cores >> |
