Introduction: Cordic Algorithm Using VHDL

About: Mitu Raj -- Just a Hobbyst and Learner -- Chip Designer -- Software Developer -- Physics and Mathematics Enthusiast

##This is the most clicked, popular link in Google for VHDL implementation of CORDIC ALGORITHM to generate sine and cosine wave##


This is to inform that this blog is now archived and I have started a new website/blog of my own: Chipmunk Logic. I hope you guys follow/subscribe me for free content and knowledge and continue supporting me. Hereafter, I will publish all my future technical blogs there :)


At present time, many hardware efficient algorithms exist, but these are not well known due to the dominance of software systems over the many years. CORDIC is such an algorithm which is nothing but a set of shift and add logics used for computing a wide range of functions including certain trigonometric, hyperbolic, linear and logarithmic functions. This is the algorithm used in calculators etc. Thus by just using simple shifters and adders we can design a hardware with less complexity but power of DSP using cordic algorithm. Hence it can be designed as bare RTL design in VHDL or Verilog without using any dedicated floating point units or complex math IPs.

Step 1: VHDL and Modelsim

Here the cordic algorithm is implemented using VHDL to generate a sine wave and cose wave . It can output sine and cosine of input angle at great precision. The code is synthesizable on FPGA. Modelsim is used to simulate the design and the test bench .

Step 2: VHDL Code for the Design and the Test Bench

---- Guidelines ----

Binary scaling technique is used to represent floating point numbers.

Please go thru the attached docs before you code.


Go thru
Simulating cordic_v4.vhd - The Design

-The input is angle in 32 bits + sign bit ; it can process any angle from 0 to +/-360 degree with input precision of 0.000000000233 degree. When giving input -> MSB is the sign bit and the rest 32 bits represent magnitude .

-The output of the design is its sine and cos value in 16 bits + sign bit .ie; with precision 0.00001526. Please note that the output is displayed in 2's compliment form if the respective sine or cos value is negative.

Simulating testb.vhd - Test Bench For The Design

(1) Input angles and pull reset ='0'. After two steps of simulation pull reset to '1' and " run all ".

(2) In simulation window set the radix of sin and cos signals as decimal and format > Analog ( automatic ).

(3) Zoom out to see the waveform properly.

Step 3: Files Attached

(1) cordic_v4.vhd - Design .

(2) testb.vhd - Test bench for the design .

(3) Document on how to force angle inputs and convert the binary results.

Update: THESE FILES ARE OBSELETE AND NOT PROVIDED ANYMORE. PLEASE USE FILES FROM NEXT STEP.

Step 4: Mini-Cordic IP Core - 16 Bit

Limitation of the above implementation is


- slow, lower clock frequency of operation because of doing computations in a single clock cycle.


Mini-Cordic IP Core - 16 Bit

- Critical paths distributed to multiple cycles to improve performance.


- Faster - FPGA proven design synthesised upto 100 Mhz clock.


- More area optimised in HDL, Lesser hardware.


- Load and Done Status signals added.


- Only downside is lesser resolution compared to the previous one.


Testbench:

completely automated from 0 to 360 degree angle inputs


Files Attached:


1) mini cordic VHDL source files


2) mini cordic test bench


3) Mini Cordic IP Core manual


4) Doc on how to force angles and convert results

For any queries, feel free to contact me:


Mitu Raj

follow me: https://www.instructables.com/member/AmCoder/

mail: iammituraj@gmail.com


###Total downloads : 415 as of till 01-01-2023###

### Code last edited : Jan-11-2023 ###

Step 5: New Blog

I have launched my new website for my technical blogging. Sadly, I have to move on from instructables, where I have got the most support. Please continue supporting me at Chipmunk Logic. The blog is all about open-source codes and design techniques in VLSI digital design.