我正在尝试将 Verilog 程序翻译成 VHDL,并且偶然发现了在 Verilog 程序中使用问号 ( ?
) 运算符的语句。
以下是Verilog代码;
1 module music(clk, speaker);
2 input clk;
3 output speaker;
4 parameter clkdivider = 25000000/440/2;
5 reg [23:0] tone;
6 always @(posedge clk) tone <= tone+1;
7 reg [14:0] counter;
8 always @(posedge clk) if(counter==0) counter <= (tone[23] ? clkdivider-1 : clkdivider/2-1); else counter <= counter-1;
9 reg speaker;
10 always @(posedge clk) if(counter==0) speaker <= ~speaker;
11 endmodule
我不明白第8行,有人可以解释一下吗?我在 asic-world 网站上读到问号是该Z
字符的 Verilog 替代项。但我不明白为什么在这种情况下使用它。
亲切的问候