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 b in the upper half of out_not (i.e., bits [5:3]), and the inverse of a in the lower half.
构建一个具有两个3位输入的电路,该电路计算两个向量的逐位“或”、两个矢量的逻辑“或”以及两个向量之间的逆(NOT)。将b的倒数放在out_not的上半部分(即bits[5:3]),将a的倒数放置在下半部分。
整体是不难的,主要注意按位或的运算符是 | 逻辑或的运算符是 ||
按位或,就例如 : 1010 | 0011 = 1 0 1 1;
逻辑或就是,只要两个数不都是纯0,就输出1
逆其实也有值得注意的地方
Verilog里面有逻辑非“ ! ”和按位非“ ~ ”,两种运算符
逻辑非就是,只要值不是纯0,就输出0。如果是纯0,就输出1。
按位非就是例如:~1100 = 0011
逻辑就是把数值视为一个整体来运算,按位就是一位一位去运算,逻辑的输出只有1或者0,是一位的,按位是输入n位就会产生n位的输出。
module top_module(
input [2:0] a,
input [2:0] b,
output [2:0] out_or_bitwise,
output out_or_logical,
output [5:0] out_not
);
assign out_or_bitwise = a | b;
assign out_or_logical = a || b;
assign out_not[5:3] = ~ b;
assign out_not[2:0] = ~ a;
endmodule