Prev Problem
Next Problem

67. Decoder

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

/*Write your code here*/
module decoder3to8 (input [2:0]s,output [7:0]y);
// assign y[0] = s==3'd0 ? 1'b1 : 1'b0;
// assign y[1] = s==3'd1 ? 1'b1 : 1'b0;
// assign y[2] = s==3'd2 ? 1'b1 : 1'b0;
// assign y[3] = s==3'd3 ? 1'b1 : 1'b0;
// assign y[4] = s==3'd4 ? 1'b1 : 1'b0;
// assign y[5] = s==3'd5 ? 1'b1 : 1'b0;
// assign y[6] = s==3'd6 ? 1'b1 : 1'b0;
// assign y[7] = s==3'd7 ? 1'b1 : 1'b0;
genvar i ;
generate 
    for(i=0;i<8;i=i+1) begin
        assign y[i] =(s == i)?1'b1:1'b0;
    end
endgenerate
endmodule

 

Was this helpful?
Upvote
Downvote