Prev Problem
Next Problem

45. Signed vs Unsigned Compare

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

/*Write your code here*/
module signed_thresh (
    input [7:0] sample , thresh ,
    output reg gt_unsigned , gt_signed 
);
always@(*)
begin
    if(sample > thresh)
    begin
        gt_unsigned  = 1 ;
        
    end
    if(sample < thresh)
    begin
        gt_unsigned  = 0 ;
        
    end
    if ($signed(sample) > $signed(thresh))
    begin
       gt_signed = 1;
    end
    if ($signed(sample) < $signed(thresh))
    begin
       gt_signed = 0;
    end
    
end 
endmodule

 

Was this helpful?
Upvote
Downvote