|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
寄存器变量不要在两个always块中赋值,如果在两个块中赋值,quartus会报错,Error (10028): Can't resolve multiple constant drivers for net "clk_out" at div.v(45)但是在modelsim中,却不会报错?这是为什么???求解答。
发现这个问题的过程是因为我想通过50m时钟得到10k时钟和10hz时钟,,
如果代码如下:则在modelsim中不能得到10hz时钟,,只能得到10khz,,
module ts(clk,rst, clk_10k, clk_1);
input clk;
input rst;
output clk_10k;
output clk_1;
reg clk_10k;
reg clk_1;
reg clk_out;
reg [11:0] n;
reg [8:0] m;
//-----------------fenpin-----------------------
always@(posedge clk)
begin
if(!rst)
begin
clk_10k <= 1'b0;
end
else
begin
n <= n + 12'd1;
if( n == 12'd2500)
begin
n <= 12'h0;
clk_10k <= ~clk_10k;
end
end
end
always@(posedge clk_10k)
begin
m <= m + 9'd1;
if( m == 9'd500)
begin
m <= 9'h0;
clk_1 <= ~clk_1;
end
end
always@( posedge clk_10k)//??
begin
k <= k + 2'd1;
if( k == 2'd3)
begin
k <= 2'd0;
clk_out <= ~clk_out;
end
end
endmodule
如果代码改为:。。则两者均能得到,,可是不是说一个变量不能在两个always块中赋值吗??
module ts(clk,rst, clk_10k, clk_1);
input clk;
input rst;
output clk_10k;
output clk_1;
reg clk_10k;
reg clk_1;
reg clk_out;
reg [11:0] n;
reg [8:0] m;
//-----------------fenpin-----------------------
always@(posedge clk)
begin
if(!rst)
begin
clk_10k <= 1'b0;
clk_1 <= 1'b0;
n <= 0;
m <= 0;
end
else
begin
n <= n + 12'd1;
if( n == 12'd2500)
begin
n <= 12'h0;
clk_10k <= ~clk_10k;
end
end
end
always@(posedge clk_10k)
begin
m <= m + 9'd1;
if( m == 9'd500)
begin
m <= 9'h0;
clk_1 <= ~clk_1;
end
end
endmodule |
|