题解 | #多位信号xnor#
`timescale 1ns/1ns module top_module( input a, b, c, d, e, output [24:0] out ); wire [24:0]t1,t2;//注意这里一定要标明位数 assign t1 = {{5{a}},{5{b}},{5{c}},{5{d}},{5{e}}};//位拼接运算符这一定要把5{a}放在{}这里面 assign t2 = {5{a,b,c,d,e}}; assign out = ~t1 ^ t2;//同或可以完成相同为一的功能,但要注意不能写成~(t1 ^ t2);也可用循环完成 endmodule /*循环完成`timescale 1ns/1nsmodule top_module(input a, b, c, d, e,output [24:0] out);wire [24:0] tmp0,tmp1;assign tmp0[24:0] = {{5{a}},{5{b}},{5{c}},{5{d}},{5{e}}};assign tmp1[24:0] = {5{a,b,c,d,e}};genvar i;generatefor(i = 0;i < 25;i = i + 1) beginassign out[i] = (tmp0[i] == tmp1[i]);endendgenerateendmodule*/