(原創) vector的part select寫法 (SOC) (Verilog)
Abstract
vector型態可作bit select與part select,但part select有一種較為罕見的寫法。
Introduction
使用環境:Quartus II 7.2 SP3
bit select語法很直觀,就沒什麼問題,問題在part select有兩種寫法。
vector_part_select.v / Verilog
1 module vector_part_select (
2 input [3:0] SW,
3 output [17:0] LEDR
4 );
5
6 assign LEDR[1:0] = SW[3:2] & SW[1:0];
7 assign LEDR[3-:2] = SW[3-:2] | SW[1-:2];
8
9 endmodule
2 input [3:0] SW,
3 output [17:0] LEDR
4 );
5
6 assign LEDR[1:0] = SW[3:2] & SW[1:0];
7 assign LEDR[3-:2] = SW[3-:2] | SW[1-:2];
8
9 endmodule
同樣是對vector作part select取2 bit,第6行的SW[1:0]是從1bit取到0 bit,而第7行的SW[1-:2]是從1bit向右取2 bit,其實意義都一樣,只是寫法不同,較常見的是第6行的寫法,不過第7行的寫法也合法。
Conclusion
這是Verilog 2001較新的寫法,不過在Quartus II 7.2 SP3已經支援,可安心使用。