|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
关于我写的5分频代码的疑惑
module div5_freq(clk_in, rst_n,clk_out);
input clk_in;
input rst_n;
output clk_out;
reg clkp;
reg clkn;
reg[2:0] countp;
reg[2:0] countn;
parameter div1 = 2 , div2 = 4; // div1=5 / 2, div2 = 5 - 1
assign clk_out = clkp | clkn;
[email=always@(posedge]always@(posedge[/email] clk_in or negedge rst_n)
begin
if(!rst_n)
clkp <= 0;
else if(countp == div1)
clkp <= ~clkp;
else if(countp == div2)
clkp <= ~clkp;
else
clkp <= clkp;
end
[email=always@(negedge]always@(negedge[/email] clk_in or negedge rst_n)
if(!rst_n)
clkn <= 0;
else if(countn == div1)
clkn<=~clkn;
else if(countn == div2)
clkn <=~ clkn;
else
clkn <= clkn;
[email=always@(posedge]always@(posedge[/email] clk_in or negedge rst_n)
if(!rst_n)
countp <= 0;
else if(countp == div2)
countp <= 0;
else
countp <= countp + 1;
[email=always@(negedge]always@(negedge[/email] clk_in or negedge rst_n)
if(!rst_n)
countn <= 0;
else if(countn == div2)
countn <= 0;
else
countn <= countn + 1;
endmodule
我发现这里输出变量clk_out没有定义类型,且我尝试着给输出定义为reg型。run之后结果发现仿真没完没了的进行,且仿真窗口也没有波形产生!
请问这是问什么? |
|