The following example describes in detail how a Digilent ZYBO Board containing a ARM Processor and a Xilinx FPGA is configured to be used with flink. The FPGA will contain a single channel PWM module and a single channel GPIO module.
The FPGA is connected directly to the Processors AXI Interface.
Setup FPGA Design
Start as described in flink VHDL. Follow below directions at the specific step.
The first thing we do in the code which is not given from the helloworld example is to set the base address for the bus operations. To do that we use the set_axi_base_address(base_address) method. This Address is the info devices address which we configured in the block design memory map bevore.
The next step is to open the flinkdevice with the flink_open(&bus_ops) method. The bus_ops depends on how the fpga is connected to the processor. In our example the fpga is connected to the internal axi bus of the processor. Flink allready offers the bus_ops for this bustype so we can use them.
With the flink_get_nof_subdevices(dev) method we can check how many subdevices have been found. In our case this should return 3 (info, pwm, gpio). If this is not the case, ensure that you have entered the correct value for “Dev Size” in the infoDevice. The correct value is: number of flink subdevices * 4096.
To easy access the subdevices we need a reverence to them. There are different ways to get this reference. In our example we will use the flink_get_subdevice_by_unique_id(dev, id) method. In the block design we configured the unique ids of our three blocks. So with this ids we can get easy accesses to our subdevices for example to get access to the info device we will use the method with id=0 for the pwm we use id=2.
After we have a reference to a subdevice we can use the subdevice specific methods to interact with it. In our example we us three methods to configure the pwm output. First we get the base clock frequency with wich the pwm subdevice is connected. For that we us flink_pwm_get_baseclock(pwm_subdev,&baseclk). With this frequency we can configure the pwm period and high time with the two following methods: flink_pwm_set_period(pwm_subdev, 0,baseclk),
flink_pwm_set_hightime(pwm_subdev, 0,baseclk/2). In this example we set the period to baseclk which corresponds to 1sec. The hightime is set to baseclk/2 which will result in a pwm ratio of 50%
The same thing we can do with the gpio subdevice. There we only need two methods: with flink_dio_set_direction(gpio_subdev, 0, FLINK_OUTPUT) we set the direction of the gpio to output. Then we can use flink_dio_set_value(gpio_subdev, 0,1) to set it to a high state.
The Linux part works the same on all systems please checke this page.
All listed modules also include the Zynq7-Processing System, the Processor System Reset and one AXI-Smartconnect.