Prev Problem
Next Problem

45. Signed vs Unsigned Compare

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

We can explicitly cast the input into a signed part to calculate it.

 

 

Code

/*Write your code here*/
module signed_thresh (
    input  [7:0] sample,
    input  [7:0] thresh,
    output        gt_unsigned,
    output        gt_signed
);
    assign gt_unsigned = (sample > thresh);
    assign gt_signed = ($signed(sample) > $signed(thresh));
endmodule

 

Was this helpful?
Upvote
Downvote