+ Post New Thread
Results 1 to 12 of 12

12th April 2019, 14:18 #1
 Join Date
 Apr 2019
 Posts
 13
 Helped
 0 / 0
 Points
 102
 Level
 1
Design to state position of first one from lsb every clock for parallel data coming
Can you please provide a design whose output will state the location of the first '1' from the LSB for an incoming parallel bit stream every clock?

12th April 2019, 14:34 #2
 Join Date
 Apr 2016
 Posts
 1,755
 Helped
 309 / 309
 Points
 8,339
 Level
 21
Re: Design to state position of first one from lsb every clock for parallel data comi
Is this a homework?
Really, I am not Sam.

Advertisement

12th April 2019, 14:36 #3
 Join Date
 Apr 2019
 Posts
 13
 Helped
 0 / 0
 Points
 102
 Level
 1

12th April 2019, 16:16 #4
 Join Date
 Sep 2013
 Location
 USA
 Posts
 7,085
 Helped
 1692 / 1692
 Points
 30,789
 Level
 42
Re: Design to state position of first one from lsb every clock for parallel data comi
You seem to have a misconception of what this forum is about. Members will help you with answering questions you may have on a variety of electronics related topics. They will assist you in resolving problems you may have in code or concepts. What members are unlikely to help with is: Doing your work for you.
You have an assignment or a need to have this circuit then do one or more of the following:
a) design it yourself
b) hire someone to design it, if you are not capable of designing such a circuit
c) try to design it and ask questions on the forum (showing what you have done) about any problems with your circuit that you can't figure out how to fix.
d) search the internet for your answer
Of the various options you will learn the most by doing either a or c.

12th April 2019, 22:18 #5
 Join Date
 Jul 2010
 Location
 Sweden
 Posts
 939
 Helped
 367 / 367
 Points
 7,121
 Level
 20

Advertisement

14th April 2019, 08:44 #6
 Join Date
 Feb 2015
 Posts
 1,003
 Helped
 284 / 284
 Points
 6,108
 Level
 18
Re: Design to state position of first one from lsb every clock for parallel data comi
There are 23 ways to code this. The obvious is a for loop from msb to lsb. This actually works when the synthesis tool understands and implements this in a good way. The fancy way uses "bitscan" with (x) & (x). This expression returns a onehot vector with the lowest 1 being the only bit set. The third method is manually generating the logic for a priority encoder.
There is also a priority encoder implementation that takes a 1hot vector and does the andor mapreduce with 10101010, 11001100, 11110000, etc...

14th April 2019, 11:49 #7
 Join Date
 Apr 2019
 Posts
 13
 Helped
 0 / 0
 Points
 102
 Level
 1
Re: Design to state position of first one from lsb every clock for parallel data comi

14th April 2019, 12:16 #8
 Join Date
 Jan 2008
 Location
 Bochum, Germany
 Posts
 44,932
 Helped
 13664 / 13664
 Points
 257,472
 Level
 100
Re: Design to state position of first one from lsb every clock for parallel data comi
What is x and what is x?
In my view, a behavioral description of the intended logic, typically using a for loop is a straightforward approach to synthesize it, as long as you don't have additional requirements, e.g. implementing pipelining or enforcing a specific hardware implementation like using carry chains to speed up the design.
Some synthesis tools have difficulties to implement nonarithmetic problems like priority encoder optimally following a behavioral description, but they are always able to implement it correctly.

15th April 2019, 18:53 #9
 Join Date
 Feb 2014
 Posts
 113
 Helped
 4 / 4
 Points
 1,470
 Level
 8
Re: Design to state position of first one from lsb every clock for parallel data comi
Code:for (i=0; i<WIDTH, i=i+1) begin if (input[i]) begin position = i; break; end end
1 members found this post helpful.

7th May 2019, 14:18 #10
 Join Date
 Apr 2019
 Posts
 13
 Helped
 0 / 0
 Points
 102
 Level
 1
Re: Design to state position of first one from lsb every clock for parallel data comi
Will not in non synthesizable due to this break inside the for loop as this break is stopping the loop to continue?
You stated that some synthesis tools have difficulty to implement nonarithmetic problems. You also wrote that they, the synthesis tools, are always to implement nonarithmetic problems correctly? How both can be valid? Did you intend to state something else by your above quoted statement then?

7th May 2019, 16:06 #11
 Join Date
 Sep 2013
 Location
 USA
 Posts
 7,085
 Helped
 1692 / 1692
 Points
 30,789
 Level
 42
Re: Design to state position of first one from lsb every clock for parallel data comi
It's clear that you are not fluent in English, hopefully breaking FvM's statement into individual concepts will help:
1) synthesis tools have difficulties implementing nonarithmetic problems like priority encoders.
2) difficult synthesis usually means you end up with nonoptimal synthesis results.
3) synthesis tools (unless they have a bug) should produce a result that is functionally correct, but may not be the optimal result (see 2).
1 members found this post helpful.

Advertisement

8th May 2019, 00:17 #12
 Join Date
 Aug 2016
 Posts
 446
 Helped
 70 / 70
 Points
 2,550
 Level
 11
Re: Design to state position of first one from lsb every clock for parallel data comi
Hi,
You can also code a priority encoder without using the forloop.
Whichever method you use, one thing you have to realize is that you have to feed the data into the priority encoder like so:
A code for a priority encoder can also be written with an IF/ELSIF/ELSE STATEMENT in a process that is not sensitive to clock but is sensitive to all other required inputs.
First of all make a priority encoder with the method of your choosing and then make the connections as in the attachment provided. Without interchanging the bit positions like in the attachments, the implementation will not be successful.Last edited by Akanimo; 8th May 2019 at 00:34.

Akanimo.
+ Post New Thread
Please login