A system is a component that generally does computations on input streams of data which results in streams of data out. There can also be input and output scalar ports that are used in a system. To start a new system 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 -> System ” under the ROCCC menu or toolbar to begin creating a new system.
A window will open asking for the details of the new system. Input the name of this new system, which project to add the system to, and how many dimensions the streams will have. Once you have filled those out, select “Finish” and the new system will be added to the project. A new file will open in the editor with some starter code to begin coding the system. The C code will contain a few arrays, indexes, and a loop construct.
Coding a System
System code assumes connections to the outside world via memories or streams passed to the system function as pointers and accessed as arrays. All of the system logic is done inside a for loop in which the stream data is accessed by using the loop index plus any constant offset. The number of loop iterations done and amount of memory accessed are dependent on the loop conditional and the index step size.
When defining the systems’ implementation all input streams can only be read from and all output streams can only be written to. All streams and scalars should be passed in as parameters to the system function. All input ports and streams should come first, followed by all output streams and ports. Output scalars will need to be passed in as reference variables using the “&” symbol.
So for this example we are going to define the WithinBounds system. This system will take in a stream of points as x, y pairs and will check to see if those points are within a user defined bound. It will store the results in an output stream called results.
In the code above, points is an input stream since it is only read and results is our output stream since we write to it. The variables leftBound, rightBound, upperBound, and lowerBound are input ports since they are passed in as input scalars and are only read from. The variables x and y are simply here to make the code more readable and are used internally.
Understanding Stream Sizes
Let’s also look at the way we are accessing the two streams above. The number of elements the hardware will expect for each stream is dependent on the number of loop iterations and the memory that is accessed in each loop iteration.
To figure out the number of elements the hardware will expect for each stream, we must first realize how many times the loop body will be run. Since it goes from 0 to 100 and we are stepping by two, that means we will have 50 loop iterations.
We are accessing two adjacent values from the points stream each loop iteration and the loop index is stepping by two. This means each value we read will be a different value and we will read 100 values total.
(50 loop iterations * 2 unique values accessed each iteration) = 100 values read from points.
So that means the hardware will expect 100 elements from the points stream.
Even though our input stream is of size 100, our output stream, results, will not be in this case. Each loop iteration we only write to one location in results. Therefore since there are 50 loop iterations, that means results will be size 50.
(50 loop iterations * 1 unique location written to each iteration) = 50 values written to results.
Determining how many total values are accessed is a little more tricky in more complex examples but for the most part it should fall under this basic idea.
Compiling A System
Once you have coded the system 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 system’s root directory. The vhdl folder will contain the vhdl files generated for the system you created
You should notice there are handful more vhdl files generated for a system than for a module. Each the files are named in ways that describe their functions. There are three files generated that control the loop, input, and output. The vhdl file generated that has no suffix contains the logic for the system just compiled.
For more in depth detail of all you can do when coding a system including using multi-dimensional streams, calling other modules, and systolic array generation, take a look at the systems on the examples section on the ROCCC webpage.
|<< Module Construction||Tutorials Home||Using Compiled Modules >>|