在线咨询 切换到宽版
eetop公众号 创芯大讲堂 创芯人才网

 找回密码
 注册

手机号码,快捷登录

手机号码,快捷登录

搜帖子
查看: 3566|回复: 3

[求助] 请问这段代码怎么修正,刚学FPGA

[复制链接]
发表于 2014-7-15 20:58:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
module jtSIG(
             clk,

reset_n,

g,

jtsignal
);

input clk,reset_n,g;
output [1:0]jtsignal;
reg [1:0]jt;
always@( posedge clk or negedge reset_n )
begin
if(g==0)
  begin
  jt<=2'b00;
  end
  else
  begin
  jt<=2'b01;
  end
end

assign jtsignal=jt;

endmodule




Error (10200): Verilog HDL Conditional Statement error at jtSIG.v(13): cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct


Error (12152): Can't elaborate user hierarchy "jtSIG:JTSIG"
发表于 2014-7-15 21:11:13 | 显示全部楼层
always@( posedge clk or negedge reset_n )
begin
if(!reset_n)
  jt<=2'b00;
else if(g==0)
  begin
  jt<=2'b00;
  end
else
  begin
  jt<=2'b01;
  end
end
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-7-15 21:19:37 | 显示全部楼层
回复 2# henryshen2000
谢谢,就是必须得有if(!reset_n)   jt<=2'b00;这一句吗
回复 支持 反对

使用道具 举报

发表于 2014-7-16 08:37:21 | 显示全部楼层
回复 3# jessho
always@( posedge clk or negedge reset_n )
begin
if(!reset_n)
   ...
  else
    ...
end
这种代码表示的是带异步复位的寄存器(假定reset_n是低电平有效的复位信号)

always@( posedge clk)
begin
if(!reset_n)
   ...
  else
    ...
end
这个是同步复位的寄存器



always@( posedge clk)
begin
    ...
end
这个是不带复位的寄存器
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条


手机版| 小黑屋| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-9-14 01:50 , Processed in 0.017927 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表