|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2012-5-10 22:28:58
|
显示全部楼层
dragon_hn 发表于 2012-5-10 09:55 ![](static/image/common/back.gif)
18000个D触发器用FPGA不是什么难事。
照我下面的方法:
非常感谢以上各位网友提供的意见方案,我根据回复情况总结了三种方案:
1,用多个D触发器实现延时,但由于EPM240的资源不够,显然做不到误差微秒的要求。
2,将波形采样存储,18MS后再读取输出,EPM240的RAM有限,需要外加缓存。
3,按照网友dragon_hn 提供的方案,写了一段代码如下:
/**************************************************************
* File Name : signal_delay.v
* Author :
* Version : Quartus II 9.1 SP2
* CreateDate : 2012/5/10
* Description : phase compensation
**************************************************************/
/* pin allocation :
* function :
*************************************************************/
module signal_delay( Rst,CLOCK_1M,A_ZRE0_CROSS,A_ZRE0_CROSS_MOVE);
input CLOCK_1M; // 时钟
input A_ZRE0_CROSS; // 输入信号
input Rst;
output A_ZRE0_CROSS_MOVE; // 延迟输出信号
/**************************************************************
*Description :定时器1,时长:
* pin allocation :
**************************************************************/
parameter UP_TIMER_VAL=131071; //
reg up_timer18ms_enable;
reg [16:0] up_timer18ms_cnt; //
wire up_timer18ms_over;
always @(posedge CLOCK_1M or negedge Rst)
if (!Rst)
up_timer18ms_cnt <=0;
else
up_timer18ms_cnt<= up_timer18ms_cnt + 1'b1;
/**************************************************************
* Description :定时器2,时长:
* pin allocation :
**************************************************************/
parameter DOWN_TIMER_VAL =131071;
reg down_timer18ms_enable;
reg [16:0] down_timer18ms_cnt; //
wire down_timer18ms_over;
always @(posedge CLOCK_1M)
if (!Rst)
down_timer18ms_cnt <= 0; //
else
down_timer18ms_cnt <= down_timer18ms_cnt+ 1'b1;
/**************************************************************
* Description : 上升沿定时器清零
* pin allocation :
**************************************************************/
always @(posedge A_ZRE0_CROSS)
up_timer18ms_cnt <= 0;
/**************************************************************
* Description : 下降 沿定时器清零
* pin allocation :
**************************************************************/
always @(negedge A_ZRE0_CROSS)
down_timer18ms_cnt <= 0;
/**************************************************************
* Description :
* pin allocation : A_ZRE0_CROSS-->pin12 , A_ZRE0_CROSS_MOVE -->pin42
**************************************************************/
reg A_ZRE0_CROSS_MOVE;
always @(posedge CLOCK_1M)
if(up_timer18ms_cnt==17999) //
A_ZRE0_CROSS_MOVE <=1;
//end
else if(down_timer18ms_cnt==17999)
A_ZRE0_CROSS_MOVE <=0;
endmodule
为什么编译出错,Can't resolve multiple constant drivers for net "up_timer18ms_cnt [16]" at signal_delay.v(25) ,根据百度提示是两个进程不能对一个变量赋值,对CPLD不是很懂,VERILOG也是刚看了一些指令,希望大家多指教,怎么来改正这段代码实现输出信号延时要求,尤其希望网友dragon_hn根据你的思路给予指导,十分谢谢。
|
|