bitwise operators
Build a circuit that has two 3-bit inputs that computes the bitwise-OR of the two vectors, the logical-OR of the two vectors, and the inverse (NOT) of both vectors. Place the inverse of in the upper half of (i.e., bits [5:3]), and the inverse of in the lower half. bout_nota Bitwise vs. Logical Operators Earlier, we mentioned that there are bitwise and logical versions of the various boolean operators (e.g., norgate). When using vectors, the distinction between the two operator types becomes important. A bitwise operation between two N-bit vectors replicates the operation for each bit of the vector and produces a N-bit output, while a logical operation treats the entire vector as a boolean value (true = non-zero, false = zero) and produces a 1-bit output. Look at the simulation waveforms at how the bitwise-OR and logical-OR differ.
1 module top_module( 2 input [2:0] a, 3 input [2:0] b, 4 output [2:0] out_or_bitwise, 5 output out_or_logical, 6 output [5:0] out_not 7 ); 8 assign out_or_bitwise=a|b; 9 assign out_or_logical=(a>0)|(b>0); //逻辑或和按位或这两个的区别还待记牢 10 assign out_not= {~b,~a}; //verilog中的拼接语法,每一个部分有三个量,拼接之后为6个,故为[5:0] 11 endmodule
Verilog语法之四:运算符 - 知乎 (zhihu.com)这一篇对于verilog的基础语法介绍挺好的,可以借此温习

浙公网安备 33010602011771号