Thursday, March 14, 2013

ADDER USIGN DECODER



This code shows how full adder can be implemented using a decoder (3-to-8). I am using instantiation method to do this. I am instantiating the decoder (3_to_8) in the main module.  The code for the decoder is available in other posts..




module adder_using_decoder(
input a,b,c_in,
output sum,c_out
    );
           wire[7:0] sum_connector;              //declaring an intermediate wire

// instantiating the decoder
           decoder_3_to_8 dc (
    .i({a,b,c_in}), 
    .decoder_output(sum_connector)
    );

assign sum= { sum_connector[1] | sum_connector[2] | sum_connector[4] | sum_connector[7]};
assign c_out = {sum_connector[3]|sum_connector[5]|sum_connector[6]|sum_connector[7]};

endmodule



No comments: