|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
如题,用来测量脉冲信号周期,编译后错误是
Error (10133): Verilog HDL Expression error at Period.v(26): illegal part select of unpacked array "cnt"
程序如下:
module Period(
clk,
rst_n,
signal,
percounter
);
input clk, rst_n, signal;
output signed [9:0] percounter;
reg [9:0] percounter;
reg signal_reg;
reg cnt[9:0];
wire signal_pos;
always @ ( posedge clk or negedge rst_n ) begin
if ( !rst_n ) begin
signal_reg <= 1'b0;
end
else begin
signal_reg <= signal;
end
end
assign signal_pos = signal & (~signal_reg);
always @ ( posedge clk or negedge rst_n ) begin
if ( !rst_n ) begin
cnt[9:0] <= 10'd0;
end
else if ( signal_pos == 1'b1 ) begin
cnt[9:0] <= 10'd0;
end
else begin
cnt[9:0] <= cnt[9:0] + 10'd1;
end
end
always @ ( posedge clk or negedge rst_n ) begin
if ( !rst_n ) begin
percounter[9:0] <= 10'd0;
end
else if ( signal_pos == 1'b1 ) begin
percounter[9:0] <= cnt[9:0];
end
else begin
end
end
endmodule
求大神帮忙看看怎么改,不胜感谢~~ |
|