Introduction

hello. Nami is getting used to the world of electronic circuits little by little.
Recently, I've been working on the issues given by my seniors while responding to customers little by little.

Last time, I wrote an article about useful features of Quartus®, an Intel® FPGA development tool (formerly Altera FPGA development tool).
"Pin arrangement in Quartus ~For those who like text base~"

This time, I will write about an episode that failed when I used IP (Intellectual Property), which is useful for logic circuit design, for the first time.
One day, Topu-senpai asked me how to use the kit and how to get used to HDL (hardware language).

Topuu-senpai ``Let's make a circuit that blinks an LED, and switch the clock frequency between 1MHz, 50MHz, and 150MHz each time you press a button, and change the blinking speed of the LED.''

I said, "Are there any conditions?"

Topuu-senpai "Shall we use an IP called ALTCLKCTRL for clock switching?"

Me: “So the day has finally come for us to use IP!”

What are IPs?

In the first place, an IP is a "pre-designed functional circuit block" that has a dedicated function on its own. This time, we will use PLL as an example.
PLL is a circuit that can change (divide, multiply) the frequency of the input clock.
See also this article about PLL.
『 About Buffer 』

Writing this from scratch in HDL is difficult and takes time.
IP exists to solve such problems.

Intel® FPGA has an IP called ALTPLL that has the function of PLL.
If you use this, you can easily change the frequency just by specifying the clock to be used.

Figure 1: IP Image

IPs with a wide variety of functions, not limited to PLL, have been released.
Very convenient!

By the way, Topuu-senpai wrote an article on how to use IP, so please refer to that as well.
"Let's use IP - I want to see the contents of IP -"

At first, I thought, "If you use a lot of IP, you can easily clear the problem!"
I thought so, but the reality was not so sweet.
I failed many times because of my ignorance.
I will explain ALTCLKCTRL before that sad episode.

ALTCLKCTRL

ALTCLKCTRL is an IP used to switch the operating clock.

Figure 2: ALTCLKCTRL

The block is as shown in Figure 2, and the output clock signal is switched according to the state of "clkselect".

Table 1: clkselect

This time the original frequency
・50MHz
and output from the PLL
・1MHz
・150MHz
All you have to do is input a total of three frequencies to ALTCLKCTRL and switch them!
I feel like I can do it easily!

Precautions when connecting

So, at first, I made connections without thinking about anything in particular (Fig. 3).

Figure 3 : Actual HDL description (when an error occurs)

But when I compile...

Figure 4: Error message

that? Is that it?
What is this error? (Fig.4)

Looking at the help, it seems that there is an invalid signal for the input...
What does it mean that the clock signal is input but disabled?

At times like this, there is only a user guide! As I read on, I see something like this...

Click here for the ALTCLKCTRL user guide

Figure 8, Filter_Sources

“Connectivity Restrictions.

・The input from the dedicated clock pin is inclk[0], inclk[1]
・The output clock from the PLL is inclk[2], inclk[3]

There was a restriction that you had to enter the .
I had no idea there was such a limit. It was a blind spot.

(Here's a note! This time we're talking about Cyclone V®, so the rules may be different depending on the device!)

that's right. I was putting the clock outputs from the PLL into inclk[0 ], inclk[1]!
That's what the previous error meant.

So, I corrected the connection point as shown in Figure 5.

Figure 5 : Actual HDL description (after modification)

After fixing it, the compilation finished successfully!

The final result is the circuit in Figure 6.
With this circuit, I was able to switch the clock safely and change the blinking speed of the LED!

Figure 6 : Circuit that can switch clocks

at the end

Although IP is very useful, it has limitations depending on the type of FPGA used.
You should read the user guide properly.
Everyone, please be careful when using IP!
But once you get the hang of it, it's very convenient!

・Since the IP already has functions on its own, it is possible to greatly reduce the man-hours required for circuit design.
・There are restrictions on connection, so be sure to refer to the user guide when using