Archive for February, 2023

C Ternary Operators and are they better

Friday, February 17th, 2023

Recently this was posted in a C for Embedded programming Linkedin group.

Attention C programmers!
Here’s a quick trick that can make your code more efficient and save you time. Did you know that you can use the ternary operator to simplify if-else statements?

For example, instead of writing:

if(x > 0){
y = 1;
}
else{
y = 0;
}

You can simplify it to:

y = (x > 0) ? 1 : 0;

This is particularly useful when you have multiple if-else statements within a loop. By using the ternary operator, you can make your code more readable and reduce the number of lines, leading to improved performance.

Give it a try and let me know what you think! 

C programming style for conditional code

Before you get all enthusiastic about this it is important to note that it is unlikely that the compiler will produce different or better machine executable code in the suggested case. It is really worth every software engineer spending time looking at the assembly code to see how little effect code shortcuts have. And this ternary construct is not allowed in some code standards. This paragraph was what I posted to the discussion.

The linkedin thread continued.

One person commented

“A neat trick, although I doubt that better performance would be a benefit. One should beware of premature optimization and overusing this technique. Code readability is king!”

Another added

“In my opinion, the use of ternary operator is often used and abused in places where it actually makes the code less readable. Some coding rules actually prohibit the use of the ternary operator altogether.”

One other person said politely

“sorry to give you this information, but even without any optimization the compiler will produce the same assembly, you can try by yourself using one of the different tools online such as https://godbolt.org/.”

It looks like godbolt.org might be a fun tool to allow software people to look at assembler for different compilers.

It is always good to look at the compiled output assembler code. It shows you what you have actually done.

Version Control the Code Tools for high quality software?

Friday, February 17th, 2023

I was traveling before Christmas to get to a couple of meetings. A software guy in one of the meetings had to step out because there was a pressing issue with a serial communications system. He was back in about 20 minutes because he had “fixed it”. Turns out an IDE/Compiler/ToolChain code library had been updated automatically and this had broken the serial comms.

So how are you controlling how you version the toolchain libraries? Do you version the toolchain?

Do you just roll the automatic updates in? Do you do anything? #software #communications #versioncontrol

How do you version control the code tools for high quality software?

One option to control the version of toolchain libraries is to freeze the version used in a project by specifying a specific version number in the project’s build system. This can prevent unexpected changes and breakage caused by automatic updates. Another option is to have a dedicated team responsible for testing and controlling updates to the toolchain libraries, and only roll out updates that have been thoroughly tested and deemed stable. Additionally, organizations could also consider setting up their own internal repository for the toolchain libraries, with version control and a process for testing and releasing updates.

Having clear control and visibility into the toolchain libraries used in a project can greatly increase the stability and reliability of the system. It can also minimize downtime and improve the efficiency of debugging and fixing issues. Overall, having a well-defined version control strategy for the toolchain libraries can lead to a better software development process and improved product quality.

More often than not the silicon vendor-provided code is not available in a repository but comes as some self-installing executable. that checks for updates and installs said updates them without telling you what they are, This is such a problematic low-quality approach. So it was so cool to see this SDK from NXP that is delivered in it’s GitHub repo. Such a good way to do it. Well done NXP.

Version Control the Code Tools

The link to the SDK information is https://spsdk.readthedocs.io/en/latest/spsdk.html#delivery

The GitHub link is https://github.com/nxp-mcuxpresso/spsdk.

Truly well done to NXP and whoever was in charge of setting this up.

Hopefully the other vendors will take the same approach.

ELMG Xilinx Partner Program Renewal

Wednesday, February 1st, 2023

We are super pleased that we just got news in an e-mail from the AMD Xilinx Partner Program that we have been accepted back into the Partner Program for another year until March 31 2024.

This means that our customers get the best of AMD Xilinx product and development tools to solve their challenges. ELMG Digital Power is unique among Xilinx Partners as we focus on using Xilinx FPGA, SoC and tools to control power electronics converters.

Xilinx FPGA for a long time

Our first experience with Xilinx FPGA in power electronics control was even before ELMG Digital Power started in 2001. Back in 1997 we used an Xilinx part to add high speed capability to a Ti DSP and implemented the ADC control, PWM and three phase hysteretic current control for a shunt active filter.

ELMG Digital Power CTO recalls. “The expensive 1997 part was in a quad flat pack (QFP) package. It worked really well. I remember having to deal with simultaneous pin transitions causing ground bounce by skewing the edges. All of this is now standard in Xiinx FPGA fabric. We stopped using FPGA for some time as they did not meet our price point but when the reducing price of FPGAs allowed us to move into using them we were really pleased to see how fantastic the Xilinx Spartan 3 and Spartan 6 were. The continued Xilinx development and great support has meant that we are always pleased to use them.”

So even though we stopped using FPGA for a while due to their cost, we were pleased to return to using Xilinx FPGA when their prices became more affordable. The continued development and great support provided by Xilinx have made it a pleasure to use their products, including the Spartan 3, Spartan 6 FPGAs, Zynq 7000 System on Chip (SoC) and 7 series FPGA.

We have taken our expertise in FPGA power electronics and embodied it into our Power Core IP library, which we use to solve our customers’ power control challenges. Our renewed membership in the Xilinx Partner Program will allow us to stay up-to-date on the latest Xilinx products and technologies, and better serve our customers.

Xilinx Partner Program Renewal

As a member of the Xilinx Partner Program, we have access to a wide range of resources and benefits that will help us to continue providing our customers with the best possible solutions for their power control needs. These resources include access to the latest Xilinx technologies and tools, as well as training and technical support from Xilinx experts.

We are also excited to be able to take advantage of the marketing resources provided by the Xilinx Partner Program. These resources will allow us to promote our expertise in using Xilinx FPGA, SoC and tools to control power electronics converters to a wider audience and attract new customers.

Overall, our renewed membership in the Xilinx Partner Program is a great opportunity for us to continue providing our customers with the best possible solutions for their power control needs and to grow our business. We look forward to working closely with Xilinx in the coming years to develop innovative and effective power control solutions.Regenerate response

About AMD-Xilinx

AMD Xilinx is a leading provider of programmable logic devices (PLDs), including field-programmable gate arrays (FPGAs) and system-on-a-chip (SoC) devices. The company’s products are used in a wide range of applications, including aerospace and defense, automotive, broadcast and pro-AV, data center and enterprise, industrial, and wireless communications.

Xilinx’s FPGAs and SoCs are known for their high performance, low power consumption, and flexibility. They can be programmed to perform a wide range of functions, from simple logic gates to complex digital signal processing (DSP) algorithms. This flexibility allows customers to adapt their systems to changing requirements and to reduce their time-to-market.

Xilinx’s FPGA and SoC products are supported by a comprehensive suite of development tools and software, including the Xilinx Vivado Design Suite and the Xilinx SDK. These tools and software allow customers to design, implement, and debug their systems quickly and easily. Additionally, Xilinx’s partner ecosystem provides access to a wide range of IP cores, reference designs, and other resources to support customers’ design needs.

Xilinx also offers a wide range of support and training resources, including online resources, technical support, and training courses. This support and training helps customers to quickly get up to speed with Xilinx’s products and technologies and to develop their designs efficiently.

All of these features and resources make Xilinx a popular choice among engineers and designers in a wide range of industries, and ELMG Digital Power is proud to be a member of the Xilinx Partner Program, which helps to provide our customers with the best possible solutions for their power control needs.

About ELMG Digital Power

ELMG Digital Power is a company that uniquely specializes in using Xilinx FPGA, SoC and tools to control power electronics converters. Founded in 2001, the company has a long history of experience in this field, dating back to 1997 when they first used a Xilinx part to add high-speed capability to a Ti DSP.

The company’s expertise in using FPGA’s for power electronics control is embodied in their Power Core IP library, which they use to solve their customers’ power control challenges. With this library, they are able to offer a wide range of solutions for various power electronics applications, such as motor control, renewable energy, and electric vehicles.

The company’s team of experienced engineers and designers are dedicated to providing their customers with the best possible solutions for their power control needs. They work closely with their customers to understand their unique requirements and to develop custom solutions that meet their specific needs.

ELMG Digital Power is committed to staying at the forefront of power control technology and is a proud member of the Xilinx Partner Program. This membership gives the company access to the latest Xilinx technologies and tools, as well as training and technical support from Xilinx experts.

Overall, ELMG Digital Power is dedicated to providing their customers with the best possible solutions for their power control needs and are proud to be a member of the Xilinx Partner Program.