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 Parity
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif Using Assign
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : parity_using_assign
  3 // File Name   : parity_using_assign.sv
  4 // Function    : Parity using assign
  5 // Coder     : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module parity_using_assign (
  8 input   wire [7:0] data_in    , //  8 bit data in
  9 output  wire       parity_out   //  1 bit parity out
 10 );
 11 //--------------Code Starts Here----------------------- 
 12 assign parity_out =  (data_in[0] ^ data_in[1]) ^  
 13                      (data_in[2] ^ data_in[3]) ^ 
 14                      (data_in[4] ^ data_in[5]) ^  
 15                      (data_in[6] ^ data_in[7]);
 16 
 17 endmodule 
You could download file sv_examples here
   

space.gif

   

space.gif

  ../../images/main/bulllet_4dots_orange.gif Using function- I
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : parity_using_function
  3 // File Name   : parity_using_function.sv
  4 // Function    : Parity using function
  5 // Coder     : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module parity_using_function (
  8 input   wire [7:0] data_in    , //  8 bit data in
  9 output  wire       parity_out   //  1 bit parity out
 10 );
 11 //--------------Code Starts Here----------------------- 
 12 function  parity;
 13   input [31:0] data; 
 14   begin
 15     parity =  (data_in[0] ^ data_in[1]) ^  
 16               (data_in[2] ^ data_in[3]) ^ 
 17               (data_in[4] ^ data_in[5]) ^  
 18               (data_in[6] ^ data_in[7]);
 19   end 
 20 endfunction 
 21  
 22 assign parity_out = parity(data_in);
 23 
 24 endmodule
You could download file sv_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif Using function- II
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : parity_using_function2
  3 // File Name   : parity_using_function2.v
  4 // Function    : Parity using function
  5 // Coder      : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module parity_using_function2 (
  8 input   wire [31:0] data_in    , //  8 bit data in
  9 output  reg         parity_out   //  1 bit parity out
 10 );
 11 //--------------Code Starts Here----------------------- 
 12 function parity;
 13   input [31:0] data; 
 14   integer i; 
 15   begin 
 16     parity = 0; 
 17     for (i = 0; i < 32; i = i + 1) begin  
 18       parity = parity ^ data[i]; 
 19     end 
 20   end 
 21 endfunction 
 22 
 23 always_comb
 24 begin
 25   parity_out = parity(data_in);
 26 end
 27 
 28 endmodule
You could download file sv_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif And the Practical One
   

space.gif


  1 //-----------------------------------------------------
  2 // Design Name : parity_using_bitwise
  3 // File Name   : parity_using_bitwise.sv
  4 // Function    : Parity using bitwise xor
  5 // Coder     : Deepak Kumar Tala
  6 //-----------------------------------------------------
  7 module parity_using_bitwise (
  8 input   wire [7:0] data_in    , //  8 bit data in
  9 output  wire       parity_out   //  1 bit parity out
 10 );
 11 //--------------Code Starts Here----------------------- 
 12 assign parity_out = ^data_in; 
 13 
 14 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