Friday, August 1, 2014

Asynchronous FIFO Depth Calculation

Well, I was asked a very common interview question during my interview at product based MNC focusing on storage equipment development. I was not able to answer during interview so I did extensive research on FIFO depth calculation concept and requirement of necessary depth.

The logic behind FIFO depth calculations very simple. First I will explain it in a non technical way. Suppose there is a person Mr. A and Mr. B. Now Mr. A can throw 10 balls at an instant of time. But Mr. B can catch only 6 balls at the same amount of time. (the phrase written over here "same amount of time" is very important which will help us to calculate FIFO depth). So Mr. B cannot catch remaining 4 balls from Mr. A. So he require a bag of size 4. This is the funda behind the FIFO depth calculation.

In technical terms I will explain like let's

Assume sender as Mr. A

Assume Receiver as Mr. B.

Assume FIFO as a bag.

Sender is writing a data to FIFO and receiver is reading some data from FIFO. If sender writes 10 data in 't' time and receiver reads 6 data in the same 't' time then FIFO size is 10-6=4.

FIFO has two frequency one is sender frequency(fs) and the receiver frequency (fr).

fs=1/Ts;

fr=1/Tr;

Now sender wants to transmit M words of data (let's say a Burst of data). But FIFO can take only n words of data in Ts time.

So the time taken to transmit M words is M/n*Ts.

That is sender wants M/n*Ts time to write M words of data into FIFO.

But our receiver can receive/read 'p' words in Tr time interval. In Tr times receiver can read p words

So in M/n*Ts time how many words can receiver read.

It is (M/n*Ts*p)/Tr words the receiver can read.

Till now what did we do.

We calculated how much time we want to write M words of data into FIFO. In the same amount of time how much data can our FIFO read. so simply subtract the the data read from FIFO to the data written into the FIFO.

Here the data written into the FIFO is M words

Data read from the FIFO is (M/n*Ts*p)/Tr words.

So FIFO depth is = M-(M/n*Ts*p)/Tr

This is equivalent to our example 10 - 6 = 4.

Deduce this u will get

Fifo depth = M ( 1 - fr *p / (n *fs)  )

Where

M= Max number of bytes that the sender can send = Burst data

n = No of bytes that the sender sends per clock

fs= sender clock frequency

p= No of bytes that receiver can receive per clock

fr = receiver clock frequency

Let's have an real example.

Write side of FIFO:

Write clock frequency fs = 15 MHz (clk_wr)

Maximum size of the Burst = 100 bytes (burst_width)

Delay between writes in a burst = 1 clock cycle (wr_delay)


Read side of FIFO

Read clock Frequency fr = 10 MHz (clk_read)

Delay between reads = 2 clock cycles (rd_delay)



Step1:- FIFO Width = 8 (1 byte = 8 bits worth of data at each buffer location). @ each clk_wr 1 byte of data will be written in FIFO. so n = 1.

Step2:- Assume maximum size of the burst = 100. so M = 100.

Step3:- No of write clock cycles for writing 100 locations in FIFO = 100 @ clk_wr

Step4:- Time taken to write 100 locations = 100/(15*10^6) = 6.67 us

Step5:- No of reads during 6.67 us = (6.67 us) * 10 * 10^6 = 66.7 @ clk_read (approx 67)

Step6:- No of dead cycles between reads = 2, Means every 2 clk_rd actual number of read will be 1 byte. So every clk_rd , number of read will be 1/2 bytes. so p = 1/2.

So Depth of the FIFO = 100 – 66.7/2 = 100 – 33.35 = 66.65 = 67

Let's put all these values in our derived equation

Fifo depth = M * ( 1 - fr *p / (n *fs)  )

Depth of the FIFO = 100 * (1 – 10*(1/2) /(1* 15)  )= 100*(1-1/3) = 200/3 = 66.66 = 67

P.S. : - If you still any doubt regarding FIFO depth calculation drop me a mail at akghona_1989@yahoo.com
 


 
 

Wednesday, May 21, 2014

SOP(star of packet)_EOP(end of packet) various possible scenarios veirfication handling

//sop_eop_dut which passes input signals to output ports only. No operation is being performed on incoming packet

module sop_eop_dut(
input [7:0] data_in,
input clk,sop_in,eop_in,
output reg [7:0] data_out,
output reg sop_out,eop_out);
always@(posedge clk) begin
  data_out = data_in;
  sop_out  = sop_in;
  eop_out  = eop_in;
end
endmodule


//testbench having logic to tackle various sop_eop scenarios like.1) only sop 2) sop eop in the same clock_cycle 3) only eop. The message which is being sent through packet is in ASCII format.

module tb;
 
reg clk;
reg [7:0] data_in;
reg sop_in,eop_in;
wire [7:0] data;
wire sop,eop;
static int pkt_count = 0;
static int out_pkt_count = 0;
event mid_pkt;
reg sop_flag;
bit [7:0] q_data[$];
bit [7:0] out_q_data[$];
//---------------------------clock generator------------------------------//
initial clk = 0;
always #5 clk =~clk;
//------------------------------------------------------------------------//
//----------------------------DUT instantiation---------------------------//
sop_eop_dut IDUT(
.clk(clk),
.sop_in(sop_in),
.eop_in(eop_in),
.data_in(data_in),
.sop_out(sop),
.eop_out(eop),
.data_out(data));
//------------------------------------------------------------------------//
//--------------stimulus to DUT inputs sop_in,eop_in,data_in--------------//
initial
begin
   data_in = 0;
   sop_in = 0;
   eop_in = 0;
   sop_flag = 0;
@(posedge clk);    //packet 1 : sop -eop packet
begin
   data_in = 32;
   sop_in = 1;
   eop_in = 1;
end              
@(posedge clk);    //empty cycle stimulas
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
    end   
@(posedge clk);    //packet 2 : sop of the packet sent
begin
    data_in = 72;
    sop_in = 1;
    eop_in = 0;
  end
@(posedge clk);    //packet 2 : middle of the packet sent
begin
    data_in = 73;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 2 : eop of the packet sent
begin
    data_in = 32;
    sop_in = 0;
    eop_in = 1;
  end   
@(posedge clk);    //empty cycle stimulas 
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
  end  
@(posedge clk);    //packet 3 : sop of the packet sent
begin
    data_in = 71;
    sop_in = 1;
    eop_in = 0;
  end
@(posedge clk);    //packet 3 : middle of the packet sent
begin
    data_in = 79;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 3 : middle of the packet sent
begin
    data_in = 79;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 3 : middle of the packet sent
begin
    data_in = 68;
    sop_in = 0;
    eop_in = 1;
  end
@(posedge clk);    //packet 4 : sop of the packet sent
begin
    data_in = 77;
    sop_in = 1;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 : middle of the packet sent
begin
    data_in = 79;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 : middle of the packet sent
begin
    data_in = 82;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 : middle of the packet sent
begin
    data_in = 78;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 : middle of the packet sent
begin
    data_in = 73;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 : middle of the packet sent
begin
    data_in = 78;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 4 :eop of the packet sent
begin
    data_in = 71;
    sop_in = 0;
    eop_in = 1;
  end
@(posedge clk);    //empty cycle stimulas 
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //empty cycle stimulas 
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
  end  
@(posedge clk);    //packet 5 : sop of the packet sent
begin
    data_in = 68;
    sop_in = 1;
    eop_in = 0;
  end
@(posedge clk);    //packet 5 : middle of the packet sent
begin
    data_in = 73;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 5 : middle of the packet sent
begin
    data_in = 86;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 5 : middle of the packet sent
begin
    data_in = 89;
    sop_in = 0;
    eop_in = 0;
  end
@(posedge clk);    //packet 5 : eop of the packet sent
begin
    data_in = 65;
    sop_in = 0;
    eop_in = 1;
  end
@(posedge clk);    //empty cycle stimulas 
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
  end  
@(posedge clk);    //empty cycle stimulas 
begin
    data_in = 0;
    sop_in = 0;
    eop_in = 0;
  end       
 $stop;   
end

//-------------To store DUT output packet in "out_q_data" queue---------//
function void store_output(input bit [7:0] data_queue [$]);
 out_pkt_count = out_pkt_count +1;
 $display("time : %tns , Store_output function : Packet_count is : %d , Packet data is : %p ",$time(),out_pkt_count,data_queue);
 out_q_data = {};
endfunction
always @(posedge clk) begin
 if(sop == 1)begin
  out_q_data.push_front(data);
  if(eop != 1) begin
   #10;
   ->mid_pkt;
  end
  else if(eop == 1)
   store_output(out_q_data);
 end
end
always @(posedge clk) begin
  if(mid_pkt.triggered)
    if(sop != 1 && eop != 1) begin
     out_q_data.push_front(data);
     #10; 
     ->mid_pkt;
    end
end
always @(posedge eop) begin
  if(sop !=1) begin
   out_q_data.push_front(data);
   store_output(out_q_data);
  end
end
//----------------------------------------------------------------//
//------ model to store output packet in "q_data" queue based on sop_in,eop_in DUT input--------//
function void store_packet(input bit [7:0] data_queue [$]);
 pkt_count = pkt_count +1;
 $display("time : %tns , Store_packet function : Packet_count is : %d , Packet data is : %p ",$time(),pkt_count,data_queue);
 q_data = {};
endfunction
always @(posedge clk) begin
if(sop_in == 1 && eop_in == 1) begin
  q_data.push_front(data_in);
  sop_flag = 0;
  $display("time : %tns , sop - eop packet : data : %d , sop_flag : %d",$time(),data_in,sop_flag);
  store_packet(q_data);
end
else if(sop_in == 1 && eop_in != 1) begin
  q_data.push_front(data_in);
  sop_flag = 1;
  $display("time : %tns , sop of the packet : data : %d , sop_flag : %d",$time(),data_in,sop_flag);
end
else if(sop_in != 1 && eop_in != 1) begin
  if(sop_flag == 1) begin
   q_data.push_front(data_in);
   $display("time : %tns , middle of the packet : data : %d , sop_flag : %d",$time(),data_in,sop_flag);
   end
  else   
   $display("time : %tns , empty cycle : data : %d , sop_flag : %d",$time(),data_in,sop_flag);
end
else if (sop_in != 1 && eop_in == 1) begin
 if(sop_flag == 1) begin
   q_data.push_front(data_in);
   sop_flag = 0;
   $display("time : %tns , eop of the packet : data : %d , sop_flag : %d",$time(),data_in,sop_flag);
   store_packet(q_data);
  end
end
else begin
 sop_flag = 0;
 $display("time : %tns , else cond : No Condition Matched:  sop : %d , eop : %d  , data : %d , sop_flag: %d,",$time(),sop_in,eop_in,data_in,sop_flag);
 end
end
//-------------------------------------------------------------------------------------------------------------------//
endmodule



//Simulation log. Questa transcript

# Compile of sop_eop_dut.sv was successful.
# Compile of tb.sv was successful.
# 2 compiles, 0 failed with no errors.
vsim -voptargs=+acc work.tb
# vsim -voptargs=+acc work.tb
# Loading sv_std.std
# Loading work.tb(fast)
# Loading work.sop_eop_dut(fast)
do sop_eop.do
run -all
# time :   5ns , empty cycle : data :   0 , sop_flag : 0
# time :  15ns , sop - eop packet : data :  32 , sop_flag : 0
# time :  15ns , Store_packet function : Packet_count is :           1 , Packet data is : '{32}
# time :  25ns , Store_output function : Packet_count is :           1 , Packet data is : '{32}
# time :  25ns , empty cycle : data :   0 , sop_flag : 0
# time :  35ns , sop of the packet : data :  72 , sop_flag : 1
# time :  45ns , middle of the packet : data :  73 , sop_flag : 1
# time :  55ns , eop of the packet : data :  32 , sop_flag : 0
# time :  55ns , Store_packet function : Packet_count is :           2 , Packet data is : '{32, 73, 72}
# time :  55ns , Store_output function : Packet_count is :           2 , Packet data is : '{32, 73, 72}
# time :  65ns , empty cycle : data :   0 , sop_flag : 0
# time :  75ns , sop of the packet : data :  71 , sop_flag : 1
# time :  85ns , middle of the packet : data :  79 , sop_flag : 1
# time :  95ns , middle of the packet : data :  79 , sop_flag : 1
# time : 105ns , eop of the packet : data :  68 , sop_flag : 0
# time : 105ns , Store_packet function : Packet_count is :           3 , Packet data is : '{68, 79, 79, 71}
# time : 105ns , Store_output function : Packet_count is :           3 , Packet data is : '{68, 79, 79, 71}
# time : 115ns , sop of the packet : data :  77 , sop_flag : 1
# time : 125ns , middle of the packet : data :  79 , sop_flag : 1
# time : 135ns , middle of the packet : data :  82 , sop_flag : 1
# time : 145ns , middle of the packet : data :  78 , sop_flag : 1
# time : 155ns , middle of the packet : data :  73 , sop_flag : 1
# time : 165ns , middle of the packet : data :  78 , sop_flag : 1
# time : 175ns , eop of the packet : data :  71 , sop_flag : 0
# time : 175ns , Store_packet function : Packet_count is :4,Packet data is: '{71, 78, 73, 78, 82, 79, 77}
# time : 175ns , Store_output function : Packet_count is :4,Packet data is: '{71, 78, 73, 78, 82, 79, 77}
# time : 185ns , empty cycle : data :   0 , sop_flag : 0
# time : 195ns , empty cycle : data :   0 , sop_flag : 0
# time : 205ns , sop of the packet : data :  68 , sop_flag : 1
# time : 215ns , middle of the packet : data :  73 , sop_flag : 1
# time : 225ns , middle of the packet : data :  86 , sop_flag : 1
# time : 235ns , middle of the packet : data :  89 , sop_flag : 1
# time : 245ns , eop of the packet : data :  65 , sop_flag : 0
# time : 245ns , Store_packet function : Packet_count is :    5 , Packet data is : '{65, 89, 86, 73, 68}
# time : 245ns , Store_output function : Packet_count is :    5 , Packet data is : '{65, 89, 86, 73, 68}
# time : 255ns , empty cycle : data :   0 , sop_flag : 0
# Break in Module tb at /scratch/pnq_scratch/aghona/x120/tb.sv line 195

//waveform snapshot

 

Monday, September 9, 2013

Most frequently used UNIX commands : tar command

This article provides practical examples for most frequently used commands in UNIX.

tar command : 

In Unix, the name of the tar command is short for tape archiving, the storing of entire file systems onto magnetic tape, However, a more common use for tar is to simply combine a few files into a single file, for easy storage and distribution.                                                                 

Creating an archive using tar command
                 
Create a new tar archive :                  
 $ tar cvf archive_name.tar dirname/
Extract from an existing tar archive:
$ tar xvf archive_name.tar
View an existing tar archive:
$ tar tvf archive_name.tar
In the above command:
  • c – create a new archive.
  • v – verbosely list files which are processed.
  • f – following is the archive file name.
  • x – extract files from archive.

Creating a tar gzipped archive using option cvzf

The above tar cvf option, does not provide any compression. To use a gzip compression on the tar archive, use the z option as shown below.
$ tar cvzf archive_name.tar.gz dirname/
  • z – filter the archive through gzip.

Creating a bzipped tar archive using option cvjf

Create a bzip2 tar archive as shown below:
 $ tar cvfj archive_name.tar.bz2 dirname/
  • j – filter the archive through bzip2
gzip vs bzip2: bzip2 takes more time to compress and decompress than gzip. bzip2 archival size is less than gzip.

Extracting (untar) an archive using tar command

Extract a gzipped tar archive ( *.tar.gz ) using option xvzf

Use the option z for uncompressing a gzip tar archive.
$ tar xvfz archive_name.tar.gz

Extracting a bzipped tar archive ( *.tar.bz2 ) using option xvjf

Use the option j for uncompressing a bzip2 tar archive.
$ tar xvfj archive_name.tar.bz2

Listing an archive using tar command

View the tar archive file content without extracting using option tvf                                              

$ tar tvf archive_name.tar

View the *.tar.gz file content without extracting using option tvzf                                                      

$ tar tvfz archive_name.tar.gz

View the *.tar.bz2 file content without extracting using option tvjf                                                   

$ tar tvfj archive_name.tar.bz2

Extract a single file from tar, tar.gz, tar.bz2 file

To extract a specific file from a tar archive, specify the file name at the end of the tar xvf command as shown below. 
$ tar xvf archive_file.tar /path/to/file
Use the relevant option z or j according to the compression method gzip or bzip2 respectively as shown below.
$ tar xvfz archive_file.tar.gz /path/to/file 
 $ tar xvfj archive_file.tar.bz2 /path/to/file

Extract a single directory from tar, tar.gz, tar.bz2 file

To extract a single directory (along with it’s subdirectory and files) from a tar archive, specify the directory name at the end of the tar xvf command as shown below.
 $ tar xvf archive_file.tar /path/to/dir/
To extract multiple directories from a tar archive, specify those individual directory names at the end of the tar xvf command as shown below.
 $ tar xvf archive_file.tar /path/to/dir1/ /path/to/dir2/
Use the relevant option z or j according to the compression method gzip or bzip2 respectively as shown below.$ 
$ tar xvfz archive_file.tar.gz /path/to/dir/ 
$ tar xvfj archive_file.tar.bz2 /path/to/dir/

Extract group of files from tar, tar.gz, tar.bz2 archives using regular expression

To extract files matching a specified pattern. For example, following tar command extracts all the files with pl extension.
$ tar xvf archive_file.tar --wildcards '*.pl'
  • –wildcards *.pl – files with pl extension

Adding a file or directory to an existing archive using option -r

You can add additional files to an existing tar archive as shown below. 
$ tar rvf archive_name.tar newfile
This newfile will be added to the existing archive_name.tar. Adding a directory to the tar is also similar.
$ tar rvf archive_name.tar newdir/
Note: You cannot add file or directory to a compressed archive. If you try to do so, you will get “tar: Cannot update compressed archives” error as shown below.
$ tar rvfz archive_name.tgz newfile
tar: Cannot update compressed archives
Try `tar --help' or `tar --usage' for more information.

Estimate the tar archive size

The following command, estimates the tar file size ( in KB ) before you create the tar file.
$ tar -cf - /directory/to/archive/ | wc -c
20480
The following command, estimates the compressed tar file size ( in KB ) before you create the tar.gz, tar.bz2 files.
$ tar -czf - /directory/to/archive/ | wc -c
508
$ tar -cjf - /directory/to/archive/ | wc -c
428

Saturday, August 10, 2013

5 steps to compile and simulate "Hello world" with questasim10.0b

Use Questasim transcript window to run all below mentioned commands.

Step-1 : Download uvm-1.1a.tar.gz from http://www.accellera.org/downloads/standards/uvm


Step-2 : Extract that folder on to desktop and copy that whole folder into c:/questasim_10.0b


Step-3 : Now you have to set UVM_HOME environment variable path to locate uvm library which you have added. Go to C:/questasim_10.0b/ using cd command.


then give this command : setenv UVM_HOME uvm-1.1a. so that it will set your UVM_HOME environment variable.


Step-4 : Go to C:/questasim_10.0b/uvm-1.1a/examples/simple/hello_world using cd command.


Step-5 : Give this command : qverilog hello_world.sv
so it will compile,elaborate and simulate the design at one shot.


 You have successfully compiled and simulated "Hello world" of UVM.

Saturday, July 27, 2013

Specifications : quad_odd_1s_finder

Write a Verilog Code for a module "odd_1s_finder" to find out odd number of 1s in a 8 bit signal "data" it gets every clock "clk". 


Whenever data has odd 1s, an event called "odd event", two outputs change: odd_1s_found is true, and a 32 bit counter odd_1s_counter is incremented by 1. 

Example:
If in a given clock cycle, data[7:0]=8'b0100001, you notice it has 2 1s. Since 2 is even number, therefore there are even number of 1s, so your odd_1s_found signal should be False or 0.
Now if data[7:0]=8'b0100011, odd_1s_found signal should be True or 1, given there are 3 1s in the data.

Write a top level module "quad_odd_1s_finder" it create 4 instances of "odd_1s_finder", it comprise of 1 another 34 bit counter to count total number "odd events" from all 4 instance at each clock edge. 
    
For example in a given clock if 2 out of 4 instances had odd events, increment the top-level counter by 2, and if 3 odd events, increment it by 3 and so on. 

Thursday, July 25, 2013

tb_top.sv to verify quad_odd_1s_finder DUT

//tb_top.sv to verify quad_odd_1s_finder

module tb_top;

wire [33:0] total_odd_count;
reg [7:0] data1,data2,data3,data4;
reg clk,rst;

quad_odd_1s_finder uut(.total_odd_count(total_odd_count),.data1(data1),.data2(data2),.data3(data3),.data4(data4),.clk(clk),.rst(rst));


initial clk=1;
always #10 clk =~clk;

initial
 begin

   data1= 8'b0000_0000; data2= 8'b0000_0000; data3= 8'b0000_0000; data4= 8'b0000_0000; rst =1;

   @(posedge clk) rst=1;
 
   @(posedge clk) begin rst = 0;data1 = 8'b0000_0000; data2 = 8'b0000_0000; data3 = 8'b0000_0000; data4 = 8'b0000_0000;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1011; data2 = 8'b1010_1010; data3 = 8'b1010_1010; data4 = 8'b1010_1010;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1011; data2 = 8'b1010_1010; data3 = 8'b1010_1010; data4 = 8'b1010_1010;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1011; data2 = 8'b1010_1010; data3 = 8'b1010_1010; data4 = 8'b1010_1010;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1010; data2 = 8'b1010_1010; data3 = 8'b1010_1011; data4 = 8'b1010_1011;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1011; data2 = 8'b1010_1011; data3 = 8'b1010_1011; data4 = 8'b1010_1010;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1011; data2 = 8'b1010_1011; data3 = 8'b1010_1011; data4 = 8'b1010_1011;  end

   @(posedge clk) begin rst = 0;data1 = 8'b1010_1010; data2 = 8'b1010_1010; data3 = 8'b1010_1010; data4 = 8'b1010_1010;  end

  #100 $stop;

 end

endmodule

Quad_odd_1s_finder DUT

DUT .v files

//Quad_odd_1s_finder
module quad_odd_1s_finder(output reg [33:0] total_odd_count,input [7:0] data1,data2,data3,data4, input clk,rst);

wire [31:0] odd_count1,odd_count2,odd_count3,odd_count4;
wire [2:0] temp_total_odd_count;
wire od_f1,od_f2,od_f3,od_f4;

odd_1s_finder u1(.odd_count(odd_count1),.data(data1),.clk(clk),.rst(rst),.od_f(od_f1));
odd_1s_finder u2(.odd_count(odd_count2),.data(data2),.clk(clk),.rst(rst),.od_f(od_f2));
odd_1s_finder u3(.odd_count(odd_count3),.data(data3),.clk(clk),.rst(rst),.od_f(od_f3));
odd_1s_finder u4(.odd_count(odd_count4),.data(data4),.clk(clk),.rst(rst),.od_f(od_f4));

assign temp_total_odd_count = (odd_count1 || odd_count2 || odd_count3 || odd_count4)? (od_f1+od_f2+od_f3+od_f4):0;

always@(odd_count1 or odd_count2 or odd_count3 or odd_count4 or rst)
 if(rst)
  total_odd_count = 0;
 else
  total_odd_count = total_odd_count+temp_total_odd_count;

endmodule



//odd_1s_finder dut file
module odd_1s_finder(output reg od_f,output reg [31:0] odd_count,input [7:0 ]data,input clk,rst);
parameter TRUE=1'b1,FALSE=1'b0;
reg r;

always@(posedge clk)
  begin
   if(rst)
    begin
     r=0;
     odd_count=0;
    end
   else
     r=^data;
  end

always@(posedge clk)
  begin
   if(r==1)
    begin
     od_f=TRUE;
     odd_count=odd_count+1;
    end
   else
    begin
     od_f=FALSE;
     odd_count=odd_count;
    end
end

endmodule