주어진 5개의 1-bit 신호를 XNOR
연산을 통해
주어진 그림과 같이 연산하여 25-bit의 출력으로 나타내는 문제이다.
항상 코드의 범용성과 가독성을 고려해서 작성하려고 노력하는 편이다.
이번에도 그렇게 짜려고 wire
을 일부러 선언하여 사용했다.
module top_module (
input a, b, c, d, e,
output [24:0] out );//
wire [4:0] w_abcde = {a, b, c, d, e};
wire [4:0] w_xnor_a = ~{5{a}} ^ w_abcde;
wire [4:0] w_xnor_b = ~{5{b}} ^ w_abcde;
wire [4:0] w_xnor_c = ~{5{c}} ^ w_abcde;
wire [4:0] w_xnor_d = ~{5{d}} ^ w_abcde;
wire [4:0] w_xnor_e = ~{5{e}} ^ w_abcde;
assign out = {w_xnor_a, w_xnor_b, w_xnor_c, w_xnor_d, w_xnor_e};
endmodule