dda的fpga实现(转载)

The general approach using DDAs will be to simulate a system of first-order differential equations, which can be nonlinear. Analog computers use operational amplifiers to do mathematical integration. We will use digital summers and registers. For any set of differential equations with state variables v1 to vm

dv1/dt = f1(t,v1,v2,v3,...vm) 
dv2/dt = f2(t,v1,v2,v3,...vm)
dv3/dt = f3(t,v1,v2,v3,...vm)

...
dvm/dt = fm(...) 

We will build the following circuitry to perform an Euler integration approximation to these equations in the form

v1(n+1) = v1(n) + dt*(f1(t,v1(n),v2(n),v3(n),...vm(n))
v2(n+1) = v2(n) + dt*(f2(t,v1(n),v2(n),v3(n),...vm(n))
v3(n+1) = v3(n) + dt*(f3(t,v1(n),v2(n),v3(n),...vm(n))
...
vm(n+1) = vm(n) + dt*(fm(...))


Where the variable values at time step n are updated to form the values at time step n+1. Each equation will require one integrator. The multiply may be replaced by a shift-right if dt is chosen to be a power of two. Most of the design complexity will be in calculating F(t,V(n))

We also need a number representation. I chose 18-bit 2‘s complement with the binary point between bits 15 and 16 (with bit zero being the least significant). Bit 17 is the sign bit. The number range is thus -2.0 to +1.999985. This range fits well with the Audio codec which requires 16-bit 2‘s complement for output to the DAC. Conversion from the 18-bit to 16-bit just requires truncating the least significant two bits ([1:0]). A few numbers are shown in the table below. Note that the underscore character in the hexidecimal form is allowed in verilog to improve readability.


Decimal number

18-bit 2‘s comp
representation


1.0

18‘h1_0000

0.5

18‘h0_8000

0.25

18‘h0_4000

0

18‘h0_0000

-0.25

18‘h3_c000

-0.5

18‘h3_8000

-1.0

18‘h3_0000

-1.5

18‘h2_8000

-2.0

18‘h2_0000


Second order system (damped spring-mass oscillator):
As an example, consider the linear, second-order differential equation resulting from a damped spring-mass system:

d2x/dt2 = -k/m*x-d/m*(dx/dt)

where k is the spring constant, d the damping coefficient, m the mass, and x the displacement. We will simulate this by converting the second-order system into a coupled first-order system. If we let v1=x and v2=dx/dt then the second order equation is equivalent to

dv1/dt = v2
dv2/dt = -k/m*v1-d/m*v2

These equations can be solved by wiring together two integrators, two multipliers and an adder as shown below. In the past this would have been done by using operational amplifiers to compute each mathematical operation. Each integrator must be supplied with an initial condition. 

Converting this diagram to Verilog, the top-level module verilog code defines the 18-bit, signed, state variables and a clock divider variable (count). The clocked section resets and updates the state variables. The combinatorial statements compute the Euler approximation to the F(t,V(n)). The separate multiply module ensures that the multiplies will be instantiated as hardware multipliers. The Audio_DAC_ADC module was modifed to allow either ADC-to-DAC passthru or to connect the computation output to the DAC, depending on the position of SW17. SW17 up connects the computation.

/state variables
reg signed [17:0] v1, v2 ;
wire signed [17:0] v1new, v2new ;
//signed mult output
wire signed [17:0] v1xK_M, v2xD_M ;
// the clock divider
reg [4:0] count;

//Update state variables of simulation of spring- mass
	always @ (posedge CLOCK_50)
	begin
		count <= count + 1;
		if (KEY[3]==0) //reset
		begin
			v1 <= 32‘h10000 ; //
			v2 <= 32‘h00000 ;
			//count <= 0;
		end
		else if (count==0)
		begin
			v1 <= v1new ;
			v2 <= v2new ;
		end
	end

	// Compute new F(t,v) with dt = 2>>9
	// v1(n+1) = v1(n) + dt*v2(n)
	assign v1new = v1 + (v2>>>9);
	// v2(n+1) = v2(n) + dt*(-k/m*v1(n) - d/m*v2(n))
	signed_mult K_M(v1xK_M, v1, 18‘h10000);
	signed_mult D_M(v2xD_M, v2, 18‘h00800);
	assign v2new = v2 - ((v1xK_M + v2xD_M)>>>9);

module signed_mult (out, a, b);
	output 		[17:0]	out;
	input 	signed	[17:0] 	a;
	input 	signed	[17:0] 	b;
	wire	signed	[17:0]	out;
	wire 	signed	[35:0]	mult_out;
	assign mult_out = a * b;
	assign out = {mult_out[35], mult_out[32:16]};
endmodule

Time scaling the solution requires consideration of the value of dt and the update rate (CLOCK_50/(clock divider)) of the state variables. As shown in the code, the clock divider variable (count) is 5-bits wide, so it will overflow and cause an update every 32 CLOCK_50 cycles. If the time step, dt=2-9, then 29 steps must equal one time unit. 29 steps at an update rate of 5*107/32 yields a time unit of 0.328 mSec. A k/m=1 implies a period of 6.28 time units per cycle, so one cycle in this case would be 2.06 mSec. corresponding to 486 Hz. 
If the calculation is scaled in time to be in the audio range, then the audio DAC may be used to watch waveforms on an oscilloscope. For the damped spring-mass oscillator with a k/m=1, d/m=1/16, dt=2-8, and a clock rate of 5*108/64 I got the figure below. The top trace is v1 and the bottom is v2. The frequency computed from the time scaling considerations is 486 Hz, while the measured was 475 Hz. Reducing dt to dt=2-9 (see paragraph above) and the clock divider to 32 made the measured frequency 486, matching the computed value. The better match with smaller dt illustrates that the integration is approximate. 
 
The whole project is zipped here. The design consumed 2% of the logic resources of the FPGA, 1% of the memory, and 4 out of 70 9-bit multipliers. You could threfore expect to put up to 50 integrators and 35 multipilers in a bigger design.

时间: 2024-07-31 15:32:54

dda的fpga实现(转载)的相关文章

FPGA静态时序分析——IO口时序(Input Delay /output Delay)(转载)

转载地址:http://www.cnblogs.com/linjie-swust/archive/2012/03/01/FPGA.html 1.1  概述 在高速系统中FPGA时序约束不止包括内部时钟约束,还应包括完整的IO时序约束和时序例外约束才能实现PCB板级的时序收敛.因此,FPGA时序约束中IO口时序约束也是一个重点.只有约束正确才能在高速情况下保证FPGA和外部器件通信正确. 1.2  FPGA整体概念 由于IO口时序约束分析是针对于电路板整个系统进行时序分析,所以FPGA需要作为一个

转载论文关于fir滤波器的fpga实现

摘 要 本文讨论的FIR滤波器因其具有严格的线性相位特性而得到广泛的应用.在工程实践中,往往要求信号处理具有实时性和灵活性,本论文研究FIR的FPGA解决方案正体现了电子系统的微型化和单片化. 本论文主要讨论了以下的问题: 首先,以FIR滤波器的基本理论为依据,研究适应工程实际的数字滤波器的设计方法,确定了直接型网络结构.窗函数设计法的设计方案: 然后,讨论了FPGA的原理与结构特点,总结FPGA的设计流程与设计原则,并用Verilog HDL语言根据设计方案编写出FIR滤波器程序: 接着,采用

转载FPGA学习之内嵌乘法器调用

补充一点,除法的时候如果直接a/b那么就会调用lpm模块,不管输入是否是常数,乘法的时候输入都是reg型变量会调用硬件乘法器,有一个是常数就会调用lpm模块. 上课的时候一直听老师说真正实践的时候你别想着要自己写一个乘法器,那样子做的孩子是笨蛋. 不管老师说得对不对,总之,既然FPGA内部有硬件乘法器那么为啥不直接使用呢,而且在写verilog使用是非常简单的,只是用个*号就轻易搞定. 只要所使用的FPGA内嵌有乘法器,则综合软件在综合的时候就会自动帮你调用乘法器实现. 下面是一段简单代码: m

xilinx和altera的fpga的不同之处!----如果不知道,你将为之付出代价! --转载

本人从2004年接触fpga开始,至今已经8年了.开发过altera的flex系列和cyclone3系列:开发过xilinx的vii和v5系列.下面谈谈本人对二者的一些不同,以便引起开发者对一些细节上的注意,免得为之付出代价,再走弯路!(1)altera的任意一个管脚都可以连接到这样的sig信号上always @ (posedge(sig)) ……:但是xilinx的fpga不能,只有clk信号才能够分配这样的信号.本人最早使用a公司flex系列的fpga,当fpga和dsp的emif连接时,为

基于FPGA 的简化UART 电路设计【转载】

0 引言 随着嵌入式系统的广泛推广和应用,UART ( Universal Asynchronous Receiver Transmiller )作为一种串行数据传输方式也得到广泛的使用.UART 允许在串行链路上进行全双工通信.串行外设到RS 232-C 异步串行接口一般采用专用的集成电路即UART 实现.常见的串行接口芯片如8250 .8251 .NS16450 等,能够实现比较全面的串行通信功能.而在实际应用中,我们往往并不需要如此完整的功能,从而会造成资源的浪费和成本的提高.随着EDA

观点:哪些人适合做FPGA开发?--转载

FPGA目前非常火,各个高校也开了FPGA的课程,但是FPGA并不是每个人都适合,FPGA讲究的是一个入道,入什么道,入电子设计的道,就是说,这个过程,你得从电子设计开始,然后再学FPGA,而不是先从VHDL开始,直接跳过数电模电.这一点非常重要,这涉及到你以后的发展高度的问题.我是过来人,我深刻体会到FPGA与数电模电的基础的深层次联系.对于本科生而言,你可以把FPGA当作业余兴趣,但不要把它当成今后的饭碗,你可以保持这个兴趣直到研究生读完.从我招聘的情况来看,做FPGA的至少要读过研究生.

【转载】 Jointwave零延时视频传输for FPGA/ASIC进入军工领域

半导体知识产权H.264/H.265 硅IP核供应商Jointwave公司的发布了一系列视频编解码RTL IP核,已经成功应用于军事工业领域的指挥作战,无人机UAV控制,航空和航天摄像机,视频记录黑匣子等应用 这些IP核对应技术特性如下:第一个特性是视频编码器和视频解码器配合工作可实现零延时视频传输系统,也只有实现了零延时才能应用到军事指挥作战和UAV & Avionics控制领域.第二特性是视觉无损,1路高清画面1080P@60FPS无压缩数据量是3Gbps,采用H.264 Intra onl

zedboard--zynq使用自带外设IP让ARM PS访问FPGA(八) 转载

文章来源 http://blog.chinaaet.com/detail/34609 熟悉了xps的操作,IP添加,总线连接设置,图形化方法检查(open graphical design view),检查总线及端口连接. 在file下面的图标中,打开导出到SDK并启动,完成程序编写. 参考超群天晴的博客http://www.cnblogs.com/surpassal/,使用XPS为PS 处理系统 添加额外的IP.从IP Catalog 标签添加GPIO,并与ZedBoard板子上的8个LED灯

转载--关于FPGA设计数字信号处理电路的心得

FPGA使用的越来越广泛,除了可用于设计控制电路以为,数字信号处理电路更是FPGA的强项和难点.个人可以说才刚刚入门FPGA设计,也做过一些数字信号处理方面的电路设计,记录下个人心得体会. (一)善用MATLAB来为设计做充分的准备和验证. 在学习EDA课程的时候,我们往往都是按照要求,直接打开QuartusII,噼里啪啦开始疯狂敲代码,然后仿真--不对--再改再仿真--还不对--再改直到仿真结果正确为止.不错,这的确是人们先入为主的一种方法.但这只是我们学习HDL语言,学习使用开发工具时候比较