quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../../images/main/bullet_green_ball.gif Decoders
   

space.gif

   

space.gif

  ../../images/main/bulllet_4dots_orange.gif Decoder - Using case Statement
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : decoder_using_case
  3 // File Name   : decoder_using_case.sv
  4 // Function    : decoder using case
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module decoder_using_case (
  8 input  wire [3:0]  binary_in   , //  4 bit binary input
  9 output reg  [15:0] decoder_out , //  16-bit out 
 10 input  wire        enable        //  Enable for the decoder
 11 );
 12 
 13 always_comb
 14 begin
 15   decoder_out = 0;
 16   if (enable) begin
 17     case (binary_in)
 18       4'h0 : decoder_out = 16'h0001;
 19       4'h1 : decoder_out = 16'h0002;
 20       4'h2 : decoder_out = 16'h0004;
 21       4'h3 : decoder_out = 16'h0008;
 22       4'h4 : decoder_out = 16'h0010;
 23       4'h5 : decoder_out = 16'h0020;
 24       4'h6 : decoder_out = 16'h0040;
 25       4'h7 : decoder_out = 16'h0080;
 26       4'h8 : decoder_out = 16'h0100;
 27       4'h9 : decoder_out = 16'h0200;
 28       4'hA : decoder_out = 16'h0400;
 29       4'hB : decoder_out = 16'h0800;
 30       4'hC : decoder_out = 16'h1000;
 31       4'hD : decoder_out = 16'h2000;
 32       4'hE : decoder_out = 16'h4000;
 33       4'hF : decoder_out = 16'h8000;
 34     endcase
 35   end
 36 end
 37 
 38 endmodule
You could download file sv_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif Decoder - Using assign Statement
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : decoder_using_assign
  3 // File Name   : decoder_using_assign.sv
  4 // Function    : decoder using assign
  5 // Coder       : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module decoder_using_assign (
  8 input  wire [3:0]  binary_in   , //  4 bit binary input
  9 output wire [15:0] decoder_out , //  16-bit out 
 10 input  wire        enable        //  Enable for the decoder
 11 );
 12 //--------------Code Starts Here----------------------- 
 13 assign decoder_out = (enable) ? (1 << binary_in) : 16'b0 ;
 14 
 15 endmodule
You could download file sv_examples here
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com