我在Quartus II 13.1寫了一個加法器,程序如下
`timescale 1ns/1ns
module Counter_Design
(
//global clock
input clk, //50MHz
input rst_n,
//user interface
output reg [3:0] cnt
);
//----------------------------
//Counter for 4 bit data
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
cnt <= 0;
else
cnt <= cnt + 1'b1;
end
endmodule
所生成的RTL視圖如下:
在加法器中cnt的值應每次加一,而在RTL視圖中出現了B[3:0]爲4’h8的情況,本以爲這裏應爲4’h1。後來經過細緻觀察發現,點開RTl視圖左邊的B[3:0]屬性發現 B[0]位爲高,其他位爲低,因此推斷B在這裏應爲一個選擇信號,並不是cnt要加的數,B[3..0]的4’h8只是選擇cnt的第0位加1。