Files in VHDL

By ben06x | Electronics | 24 Apr 2021


Through this article, a programmable components from files will be described to generate a sinusoïde, on the basis of points previously recorded in a file.

Reading initial data: we can, for example, read the contents of a memory or a coefficient table of a complex operator such as a sinusoïde.

Writing simulation results: You can, for example, ask for the output of the simulation of a model to be written to a file.

We want to describe a signal synthesis block to generate a sinusoïde, on the basis of points previously recorded in a file, having the following configuration:

47e3fc8337aa79da6948d501fce3040a8bb1e307688568a3a20a75f94acec21c.png

 

The values are generated via four quadrants of 512 points each, thus making it possible to reduce the number of samples to be stored.

The figure below shows the principle of signal generation that we want to develop with a state machine:

83dfdadc3afbd231acf7d749a2968a9576debfa853d906f8fd9d8199fa4cbe9d.png

 

It has for symbol:

55ed80fe17ca394dc0f230b2236b972c090047cedcde570395d2e55304d2783e.png

 

A variable I serving as a counter and pointing to the value of the output signal is used. The coefficients of the sinus are in ascending order in the first quadrant of the sinusoid, then in descending order in the second quadrant. From the third quadrant, they are negative. We therefore recommend the same order as above, ascending then descending. We thus have I, incremented and decremented alternately for each quadrant. For this, we use two other variables. The first is the direction variable, used to identify the direction of change in the table. We thus have 0 for an incrementation of the counter and 1 for a decrementation of the variable I. Finally, the sign variable is used to identify the sign that will be applied to the output: 0 positive, 1 negative.

We thus have the architectural description of the sinus wave generator as follows:

240e1bfb0716baeef9f774c507baae9b85005eb7949a38cc7d0928d2c2f73030.png

The 512 values forming a sinus quadrant are generated using a python-type program. These values are represented, which will allow values from 0 to 500 tens of mV to be expressed.
We thus have the following program:

8bcd38782e7e35b55293b2a26c9e616e7fdd3cbcb2866b9d9c498650362faea6.png

 

We have the following code implemented:

31e3fb6836da729a33f5917b05daaec3806182d25cdd783abf97382940c4b8b6.png

gen_fc.vhd

 

db87a62f116de8acc21f7a9a8fa2b5db9aa26bfb5d12b5cdd68afceab62b0a67.png

pack.vhd

 

085201e299216541869b9780925a1e3f3a7897eb85901300fc2b0eb1c5d01ee5.png

test.vhd

 

We test our RTL description and we get the following simulation:

8d8a8fc9d49384b3ccf463f9c6ae3d791e0fb8c1f80910599b500b0175742f86.png

 

We have the generated sinusoid.

Through this article, a programmable components from files has been described to generate a sinusoïde, on the basis of points previously recorded in a file.

 

 

This article is part of my Electronics posts blog, in which you can find few articles about things i learnt in my post-graduated school :)

How do you rate this article?

5



Electronics
Electronics

Some articles about things i learnt in my post-graduated school :)

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.