请教下面两种风格的代码哪种好些
时间:10-02
整理:3721RD
点击:
第一种:
第二种:
- reg [15:0] cnt;
- wire [15:0] cnt_next;
- always @(posedge clk or negedge rst) begin
- if(!rst) begin
- cnt<=0;
- end else begin
- cnt<=cnt_next;
- end
- end
- assign cnt_next=cnt+inc;
第二种:
- reg [15:0] cnt;
- always @(posedge clk or negedge rst) begin
- if(!rst) begin
- cnt<=0;
- end else if(inc==1'b1) begin
- cnt<=cnt+16'h1;
- end
- end
第二种简单明了
个人觉得第二种,去除一些inc的误操作
第一种好
第二种综合后能生成门控时钟,更省电。
