Demo project
ZStudio contains a number of demos which can be imported directly. The following sections walk you through the demo projects and describe a set of ZStudio features along the way.
hello_world_in_nuclei_sdk
hello_world_in_nuclei_sdk demo is adopted as an example for step by step instructions on how to run and debug demo project on Nuclei N300 board.
Import demo project
Steps to import the demo into ZStudio:
-
On the ZStudio main menu, click File > New Project > New Project from SDK. On the invoked dialog, select project information.
-
On the invoked dialog, select project information.
New Project from SDK
-
Vendor: select Nuclei Sys
-
Board: select nuclei_fpga_eval
-
Application: select helloworld
-
Project Name: name the project as hello_world_in_nuclei_sdk
All other options can be default, just select them one by one.
-
-
Find the imported hello_world_in_nuclei_sdk project in the Solution Explorer.
Build the demo
-
In Project Controller view, select hello_world_in_nuclei_sdk as active project.
-
Click "Build", verify output file under output node in Project Navigator.
Run the demo on board
-
Connect a board to your computer with a USB adapter, make sure the USB is really be recognized by the PC.
Check if the board need Driver. Please visit Nuclei Board Labs to install the Driver for N300 on Linux or Window PC.
-
Create serial port connect
From the main menu, select View > Serial Port Monitor to invoke the view. Click the + button to configure the port settings, the Serial Port box automatically detects any communication port connected to your computer. Click OK to build the connect. Check if the status icon becomes green.
The status icon becomes green means Serial Port connect successfully. And the disconnect of board may cause serial port connect failure and the status icon will become red.
-
Specify run configuration
On the Toolbar, click
to open the Run Configuration window. Select the OpenOCD configuration from the top drop-down box. Check the OpenOCD configuration that matches the board you connected.


-
Run the demo on board
Click
to run the demo on board and check the output in Serial Port Monitor view.
Debug the demo on board
Add breakpoints and start debug session. The debugger runs to the first breakpoint it encounters and stops. Click Step Over button and check the project output in Serial Port Monitor view.
HPMicro Demo
This section provides step by step instructions on how to use the HPM Tool for one-stop embedded development in ZSolution, using sample projects from the HPMicro SDK.
Importing the HPMicro SDK
To import the HPMicro SDK sample projects into ZSolution:
-
On the ZStudio main menu, go to File > New Project > New Project from SDK. On the invoked dialog, select project information.
New Project from SDK
-
Vendor: select HPMicro
-
Board: select hpm5300evk
-
Application: select hello_world
-
Project Name: name the project as HPMicro_Demo
-
Linker Script: select ram
All other options can be default, just select them one by one.
-
-
Find the imported Hello World project in the Solution Explorer.
Configuring pins with HPM Tools
ZSolution integrates HPMicro Tools (Pinmux and Clock Tool) to support direct MCU pins and clock configuration within ZStudio while developing applications. In this demo we are going to show you how to light an LED with GPIO pins.
-
In the menu bar, select Tools > HPM Tools to access the HPMicro Tools page. Select the target development platform SoC as "HPM5361" and the Package as "LQFP100." Click Create Project to enter the configuration interface, where you can configure the pins and clock.
-
Refer to the HPM5300EVK Board Diagram. For example, the anode of LED2 is connected to 3.3V, and the cathode is connected to the PA23 I/O pin. Setting PA23 to low will light up the LED, while setting it to high will turn it off.
-
In ZSolution, click the PA23 pin and, in the popup, select GPIO.A[23]. Set the GPIO properties: set the direction to "Output," the output level to "High," and choose "GPIO0" as the GPIO Controller. Click "OK."
-
Click Code Preview at the top-right corner to view the pin configuration initialization code generated by the HPM Pinmux Tool (
.cand.hfiles). Since the.hfile already exists in the HPM SDK, only the.cfile needs to be applied to the project. -
The source file names and function names generated by the HPM Pinmux Tool conflict with those in the SDK. To avoid conflicts, this demo only copies the pin configuration initialization code provided by the HPM Pinmux Tool. In the imported demo project, replace the
hello_world.c. with the generated configuration code below.main.c/*
* Copyright (c) 2021 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <stdio.h>
#include "board.h"
#include "hpm_debug_console.h"
#include "hpm_gpio_drv.h"
#include "hpm_gpiom_drv.h"
static void init_pins_led(void)
{
// Pin initialization code generated by HPM Pinmux Tool
HPM_IOC->PAD[IOC_PAD_PA23].FUNC_CTL = IOC_PA23_FUNC_CTL_GPIO_A_23;
gpiom_set_pin_controller(HPM_GPIOM, GPIOM_ASSIGN_GPIOA, 23, gpiom_soc_gpio0);
gpio_set_pin_output(HPM_GPIO0, GPIO_OE_GPIOA, 23);
gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOA, 23, 1);
}
int main(void)
{
board_init(); // Initialize the development board
init_pins_led(); // Initialize the GPIO for the LED
while(1)
{
gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOA, 23, 0); // Set pin low to turn on LED
board_delay_ms(500);
gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOA, 23, 1); // Set pin high to turn off LED
board_delay_ms(500);
}
return 0;
}
As shown in the code above, the main function calls the SDK's
board_init function to initialize the board's peripheral clocks and
some I/Os. It then calls init_pins_led to initialize the GPIO in the
HPM Pinmux Tool-generated code. In the while loop, the
gpio_write_pin function sets the PA23 I/O pin's level, and the
board_delay_ms function is used to alternate the LED's blinking.
Program Compilation and Flashing
ZSolution supports program flashing via OpenOCD.
-
Build the project: Set "demo" as active project and click Build. Check build process in Build Console and verify the output file.
-
Select the OpenOCD configuration from the dropdown menu at the top. ZStudio provides built-in run configurations for projects created from the SDK, which can be used directly.
-
From the main menu, select View > Serial Port Monitor to invoke the view. Click the + button to configure the port settings, the Serial Port box automatically detects any communication port connected to your computer. Click OK to build the connect. Check if the status icon becomes green.
-
In the run configuration, select the connection target as "Development Board" and choose the OpenOCD configuration created in the previous step. Click Run and you should see the LEDs on the development board alternately blinking.

AccInst
AccInst demo is adopted as an example for step by step instructions on how to launch a profile session to identify bottlenecks and optimize source code.
You can try out this example in ZStudio Cloud.
Open AccInst solution
Steps to open the demo in ZStudio:
-
On the ZStudio main menu, click File > Import Example Solutions. Select AccInst from pull-down box and click Open.
-
Check the Normal project and Accelerated project in the AccInst solution in ZStudio.
Compared to Normal project, Accelerated project has optimized source code by adding accelerated instruction.
Build
Steps to build Normal and Accelerated project:
-
Set the Normal project as active project, select the Debug configuration and RISC-V platform, then Click Build button and Check the success of the build process in the Build Console view.
-
Set the Accelerated project as active project and reserve other configuration, then Click Build button and Check the success of the build process in the Build Console view.
Launch profiling sessions
Steps to launch profiling sessions for both Normal and Accelerated projects with default configurations:
-
Set the Normal project as active project, select Profiling > Start Profiling from main menu. Once starting profiling, you should wait for the The profiling has finished! prompted from message window and profiling results will be opened in editor.
-
Set the Accelerated project as active project, select Profiling > Start Profiling from main menu. Once starting profiling, you should wait for the The profiling has finished! prompted from message window and the profiling results will be opened in editor.
Compare profiling result
According to the Function Summary, the bottleneck function is
tpt_mat_cmplx_mult_q15. The function tpt_mat_cmplx_mult_q15 contains
a three-tier nested for loop. The innermost loop performs matrix
multiplications. Since the innermost loop is where the most CPU time is
spent, optimizing the performance of the tpt_mat_cmplx_mult_q15
function potentially lead to overall performance improvements for the
code.
To use profiling results comparison tool and see how changes that you've made affect performance:
-
On the main menu, select View > Profiling Comparison to invoke the comparison tool.
-
In the profiling comparison side bar, you need to specify Normal project profiling result as the reference benchmark. Right-click and select Select as Base.
-
Click the
button to invoke the configuration window. And click "Ok" when you are happy with the configuration.
- Select the data visualization of the Program Performance Comparison: select at least one form between chart and table.
- Select items to compare. The default items are Instruction Count, Cycle Count and Instruction Per Cycle. You can select by yourself.
-
Use Shift or Ctrl to select two profiling results, right click on one, and select Compare to achieve quick compare.
-
The profiling comparison view will be opened in editor.
The decrease of self cycle and self instruction of
tpt_mat_cmplx_mult_q15 as well as Cycle Count and Instruction
Count of Accelerated project demonstrate that optimizing
the performance of the tpt_mat_cmplx_mult_q15 function improves
overall performance and efficiency.

鄂公网安备 42018502007513