Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is word_aligner function used for?

Status
Not open for further replies.

anhnha

Full Member level 6
Full Member level 6
Joined
Mar 8, 2012
Messages
322
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Visit site
Activity points
3,684
Hi all,
I have read this function in verilog:
Code:
module word_aligner (word_out, word_in);
  output		[7: 0]	word_out;
  input 		[7: 0]	word_in;
  assign word_out = aligned_word(word_in);	   // invoke function

  function 	[7: 0] 	aligned_word;	   // function declaration
    input 	[7: 0] 	word;
    begin
      aligned_word = word;
      if (aligned_word != 0)
        while (aligned_word[7] == 0) aligned_word = aligned_word << 1;
    end
  endfunction
endmodule
I understand every code line but the problem is that I really don't know where the code is used?
What is the purpose of the function?
 

Remove the unknown number of '0' in the MSBs.
Normally we are advised not to use while loops in RTL.
 

Remove the unknown number of '0' in the MSBs.
Normally we are advised not to use while loops in RTL.
Thank you,
Could you tell me what is the purpose of this function?
I know it remove the unknown number of '0' in the MSBs but why we need to do that?
And as in aligned_word = aligned_word << 1 it is not only remove number of '0' in the MSBs but also add number of '0' in the LSB.
 

Thank you,
Could you tell me what is the purpose of this function?
I know it remove the unknown number of '0' in the MSBs but why we need to do that?
And as in aligned_word = aligned_word << 1 it is not only remove number of '0' in the MSBs but also add number of '0' in the LSB.

Not sure where it's used though.. What's the context?
Could be that next stage want to use the full range of a variable.. or is it to maximize the amplitude before going to a transmitter if it were a wireless chip?
 

What's the context?
I found it in a slide on a web. They don't explain it any more. Only give it as an example using function.
 

I found it in a slide on a web. They don't explain it any more. Only give it as an example using function.

then keep it for future use, or skip it.. the function is very basic and you will see better implementations than that.

- - - Updated - - -

Thank you,
Could you tell me what is the purpose of this function?
I know it remove the unknown number of '0' in the MSBs but why we need to do that?
And as in aligned_word = aligned_word << 1 it is not only remove number of '0' in the MSBs but also add number of '0' in the LSB.

Another example such function may be useful.

When you receive an QAM (16 and above) modulated signal, the amplitude tend to vary with gain settings, that's a problem for demapping.
You try to normalize the amplitude of received symbols, then you can use this kind of function..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top