Cordic算法的FPGA实现(附代码)

本文主要介绍了Cordic算法在FPGA中的实现,包括控制模块和计算模块的设计,通过仿真得到了期望的结果。适合FPGA初学者参考。
摘要由CSDN通过智能技术生成

FPGA新手,请多多指教
原理啥的就懒得说了,我看的是这个网页,比较详细
https://www.cnblogs.com/ninghechuan/p/8681006.html?utm_source=tuicool&utm

控制模块

module control(
    input [6:0]target,
	 input rst,
	 input clk,
	 input signed [26:0] xi,
	 input signed [26:0] yi,
	 input triggle,
	 
	 output reg [3:0] cnt,
	 output reg [26:0] cos_result,
    output reg signed [26:0] sin_result,
	 output reg [26:0]target_angle,
	 output reg cnt_start
	 );

reg [2:0] state;

parameter idle=3'b001;
parameter calculation=3'b010;
parameter finish=3'b100;


		always@(posedge rst or posedge clk)
			if(rst) begin
				state<=idle;
				target_angle<=0;
				cnt_start<=0;
				cos_result<=0;
				sin_result<=0;
				end
			else begin
					case(state)
						idle:begin 
								if(triggle) begin
									state<=calculation;
									target_angle<=(target<<<20);
									cnt_start<=1;
									end
								else begin
										state<=idle;
										cnt_start<=0;
									end
								end
							
						calculation:begin 
									if(cnt==15) begin 
										state<=finish;
										cnt_start<=0;
										end
									else begin
										state<=calculation;
										cnt_start<=1;
										end
								end
								
						finish:begin 
								state<=idle;
								cos_result<=xi;
								sin_result<=yi;
								end
							default:state<=idle;
						endcase
					end
					
		always@(posedge rst or posedge clk)
			if(rst) begin cnt<=0;
			end 
			else if(cnt_start) cnt<=cnt+1;
			else if(cnt==15) cnt<=0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值