In my project of a modern replica of a retro computer “Agat-7” I needed to generate several different clocks. Some of them can be produced by the PLL built in FPGA, others are a simple division of the main clock. But there is another group of clock signals that are not as simple to get. I use a 50MHz oscillator with FPGA and produce the main system clock of 32.5MHz by PLL. It is perfect for a VGA output in 1024×768 mode and for the CPU clock (32.5 / 32 = 1.016MHz), but it is not good for the TV output which requires 10.5MHz for pixel clock and 17.734475MHz for colour encoding subcarrier. Instead of using additional oscillators, user svofski from zx.pk.ru forum suggested me to use phase accumulator to generate such frequencies in FPGA. It is a quite simple but efficient method that can be also used for generating different waveforms apart of a simple clock signal. You can have more information about it in Wikipedia.

I’ve created a simple calculator to determine constants and accuracy of the generator:

Here is an example of a VHDL code. It generates 17.5MHz output clock from 250MHz clock using a 32-bit accumulator register:

The idea of this method is to have an accumulator register (usually at least 32-bit) to which a certain constant is added at each step of the main clock. It causes overflow after certain periods and the remainder goes to the next cycle causing another overflow after some cycles. The generated clock is the highest bit of the accumulator. On a certain step it will take one step less to overflow the accumulator, so the output clock time will be less on this step. The proportion between “long” and “short” timings determines the average output frequency. Higher input frequency will make the difference between “long” and “short” steps less, so the output signal becomes more accurate.Therefore, the disadvantage of this method is unstable duty cycle, especially when the main and the generated frequencies are too close. Here is an example of generating 15MHz clock with a 50MHz main clock:

As you can see, despite of an accurate average frequency of the clock, individual periods are different. If we use a 250MHz main clock the picture becomes much better:

There are still some irregularities in the duty cycle, but they are good enough for most purposes. At least in my project abovementioned TV signals are generated from a 275MHz clock (produced by a PLL multiplication) with this method and the output is quite impressive.

To use the calculator, you need to enter the main clock and the desired clock frequencies as well as the intended length of the accumulator register. The best achievable frequency and its variance against the goal is calculated. If the result is not good enough, try to increase accumulator length.

Also, the calculator shows how the duty cycle fluctuates from period to period compare to the ideal 50% duty cycle. To improve this parameters the initial clock frequency needs to be increased.

The last calculated parameter is the decimal number that needs to be added to the accumulator register at each step of the main clock. This number is used directly in VHDL code.

Of course that method is not universal but can serve as a great tool in many cases, reducing elements in a project or allowing to use cheaper FPGA with less PLLs on board. The calculator helps to assess the drawbacks of the method in each particular situation and make a decision of which method of clock generation to use.

As you may remember, I’ve designed a universal platform for building retro-computers “Retrobyte”. I have successfully tested it by building the “Mikro-80” computer a few months ago and now I’m working on adapting my other retro-computer project “AGAT-7” to this platform. “AGAT-7” requires more functionality than “Retrobyte” has, so I’ve build an extension board for[…]

A blog format is not very suitable for short status updates of my projects, sharing ideas or interesting facts and news. So, I have created a twitter account to supplement the blog. You can now see the latest tweets on the right side of the home page. The detailed articles are still going to be[…]

The computer “Mikro-80” was made in the Soviet Union in 1980 by a team of enthusiasts before in 1982, the magazine “Radio” began publishing its documentations and schematics. In a nutshell, this was the first accessible personal computer in the USSR; in that era, only single digits of people in the country had the ability[…]

In my previous post, I explained my idea of a modular platform for building modern replicas of retro-computers, of which the Rev.A has already been built and tested. In the process, I found a few things to improve: On the silkscreen, the diode D1 was shown incorrectly (the cathode points to the anode) The voltage[…]

During the time I worked on the “Agat-7” replica, I came across the need for constant changes and improvements; these resulted from either new ideas or troubleshooting. Some of these troubleshoots involve tinkering with the circuit board. Currently, I have four different revisions and modifications of PCB’s for “Agat”; this isn’t even the total amount,[…]

The multimedia center in my car is quite useful – it features a built in GPS navigator, a rear-view camera, an MP3 player and several other handy functions. However, its greatest weakness is the inability to play music via Bluetooth. The only supported option is the hands-free bluetooth phone connection mode. To listen to music[…]

Not so long ago I found out about a very interesting computer under the name of Maximite. It is built on the microprocessor PIC, on which are assigned all the main functions of this computer. This small device was made in 2011 and became popular enough so that now some games and programs were made for[…]

In the previous post, I promised to tell you about the holders that I made for the spool of plastic for my 3D printer. In the original kit, there is no holder or support for the plastic and it just sits there next to the printer. The spool, positioned thus, often tangles and requires constant attention. This[…]

It was always a problem to find a proper enclosure for my devices. So, I decided to build a 3D printer for these purposes. It is a great project to build. It can be used not only for customised enclosures but for all sorts of other projects. I didn’t want to buy a pre-build printer[…]

I’m about to finalise my Rev.0 of the modern replica of the retro-computer “AGAT-7”. The next step will be Rev.A design with fixed mistakes, improvements and some new ideas. In this post I’m going to summarise the Rev.0 experience and share with you with some ideas for Rev.A. At the moment the Rev.0 computer starts[…]