This interview question is simple. You are asked to guess the functionality of this module. I think the question is very simple. It is designed to check your attitude and approach to solve a problem. It is checking your grit. Give it a try.
module Guess (
input [3:0] data,
output [2:0] guess,
);
logic a,b,c,d;
assign {a,b,c,d} = data[3:0];
assign guess[0] = ^data;
assign guess[1] = ((a ^ b) & (c | d)) |
((a ^ c) & (b | d)) |
((a ^ d) & (b | c)) |
((b ^ c) & (a | d)) |
((b ^ d) & (a | c)) |
((c ^ d) & (a | b)) ;
assign guess[2] = &data;
endmodule
1 comment:
Looking at the logic confused me for quite a while. I started out first trying to determine g[2:0] for each combination of data but that would have been very tedious. Then I just started at the interface for a second. A 4-bit input is coming in and the output is 3-bit. That gave me a hint. This module computes the sum of the 4-bit vector or to put in other words, the count of 1s in the incoming vector. The maximum sum can be 4 (if data=1111).
Post a Comment