Module Construction

To start a new module from scratch, first make sure you have a valid ROCCC project loaded or have created a new project as described in the Project Creation tutorial. Once you have a valid project open, select “New -> Module” under the ROCCC menu or toolbar to begin creating a new module.

A window will open asking for the details of the new module. Input the name of this new module and which project to add the module to. Next add all the ports that this module will have. You will do this by giving a port a name, choosing a direction, bit size, and its data type. Once you fill those out, select “Add” and this will add that port to the list of ports for this new module. Continue repeating this for all ports you wish to have in the new module.

If you ever need to edit an already added port, simply double click the field you wish to edit and you will be able to change the value of that field. Once everything is added correctly, click “Finish” and the module will be added to the project.

The new file will open in the editor with the necessary starter code to begin coding the module. The C code will contain your module function call with the input and output ports as parameters to the function.


Coding a Module

Module code must create an implementation function that defines what computations occur. The parameters passed into the function must be in the order of inputs first and outputs last. Output ports are identified as reference parameters using the “&” symbol by its data type in the parameter list. All return statements are ignored and cannot be used as a form of control flow. The computation inside this function will be translated to hardware.

When defining the modules’ implementation all input ports can only be read from and all output ports can only be written to. There can be no path where you write to an output port multiple times inside the implementation function. No other functions can be defined in this file. You can create and use temporary variables inside the implementation function which will be transformed into internal registers at compile time. All internal variables but be declared at the beginning of the function before they can be used.

For this example we are going to define the MACC module to add num3 to the product of num1 and num2. We will store this result in our output port sum.


Compiling a Module

Once you have coded the module and are ready to compile it into VHDL, click “Build” under the ROCCC menu or toolbar. An optimizations window will pop up with various pages and optimizations to select from. These will be described in future tutorials so for now simply select “Finish” at the bottom right of the optimizations page to start the compilation.

Once you press finish, ROCCC will start compiling the file. All compile messages or errors will be displayed on the console inside of Eclipse. On successful compile, ROCCC will create a vhdl folder in the current module’s root directory. The vhdl folder will contain the vhdl file generated for the module you created.

An entry in the IP Cores view inside of eclipse should appear after successfully compiling the module as well. From there you can look at the latency of your module and the ports that ROCCC generated.

For more in depth detail of all you can do when coding a module including using loops, calling other modules, and using floating points, take a look at the modules on the examples section of the ROCCC webpage.


<< Project Creation Tutorials Home System Construction >>