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.

RTL for linear search

Status
Not open for further replies.

sky_above

Member level 2
Joined
May 14, 2018
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
375
RTL for binary search

Can you please write a RTL which can do binary search on an input number of any width to search the position of that number in a memory where numbers are stored?
 
Last edited:

Hi,

you want someone to do your homework?

I assume there are informations missing, like: File format, how the numbers are stored, how the nubers are separated...
"of any width" is a bit vague...

Klaus
 

Hi,

you want someone to do your homework?

I assume there are informations missing, like: File format, how the numbers are stored, how the nubers are separated...
"of any width" is a bit vague...

Klaus

A RTL is wanted for the following block where the block has an input and an output. The block has a memory where numbers can be stored. At the input a number can come and the position of that number in the memory should be told by the output of the block by binary search algorithm. Can you please provide a RTL?

Hi,
I assume there are informations missing, like: File format, how the numbers are stored, how the nubers are separated...
"of any width" is a bit vague...
Klaus

You can assume a width. File format will be verilog file format. Numbers are strored as in a SRAM or other memories.
 

No one is doing your homework. You have the specs, what is stopping you from doing it? This is a rather simple algorithm.
 

No one is doing your homework. You have the specs, what is stopping you from doing it? This is a rather simple algorithm.

This is not home work. Can you please provide the rtl?
 

Can you please provide the rtl?
I am pretty much sure no one will provide.

But.............if you have tried writing the RTL and have problems, then that can be helped!
 

This is not home work. Can you please provide the rtl?

You are entirely missing the point. Edaboard is not a free consulting web site to get someone to do your JOB for you.

If you are not capable of doing this task you should go to your manager and tell them you are not capable of doing this job and need help.

If you are learning on your own, then read, read, read, read, read, read, learn, learn, learn, learn, do, do, do, do, ....then ask specific question on what you don't understand. Don't just ask someone to write your code for you, that just makes you look lazy and not worth anyone's time to help.
 

This is not home work. Can you please provide the rtl?

If this is not homework, then what is it? This is not the type of question an engineer would ask, even if you were the junior most employee of the company.
 

If this is not homework, then what is it? This is not the type of question an engineer would ask, even if you were the junior most employee of the company.

You're assuming they graduated from a university that actually cares about graduating students that know something. I've interviewed (final year) interns with no grasp of ohms law, not exactly sure how they got into a US university master's program.
 

I am pretty much sure no one will provide.

But.............if you have tried writing the RTL and have problems, then that can be helped!

Can anybody please see while the following rtl will be synthesizable or not and while this rtl can do the binary search or not ? This will synthesize to combinational blocks only. There is no simulator/synthesis tool here. Can anybody please do a syntax check in a synthesis tool to check it synthesizability and syntax issues?


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module (m,ou);
 
parameter n=6;
parameter d=8;
input [n-1 : 0] m;
ouput [n-1 : 0] ou;
reg [n-1 : 0] ou;
reg [d-1,0]stor[n-1, 0];
integer i,s,t;
 
assign s=0;
assign t=(n-1)/2;
 
always @(m)
 
for (i=0, i<=n/2 , i++)
 
if (m < mem[(s+n)/2])
 
n= (s+n)/2 -1;
 
else if ( m > mem[(s+n)/2])
 
s= (s+n)/2 -1;
 
else
ou = (s+n)/2 ;
i=n\2;
 
endmodule




Will the following code also do the binary search and will be synthesizable? It will synthesize to sequential logic. There is no simulator/synthesis tool here. Can anybody please do a syntax check in a synthesis tool to check it synthesizability and syntax issues?


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module (m,ou, clk, rest);
 
parameter n=6;
parameter d=8;
 
input [n-1 : 0] m;
input clk, rest;
ouput [n-1 : 0] ou;
reg [n-1 : 0] ou;
reg [d-1,0]stor[n-1, 0];
integer i,s,t;
 
assign s=0;
assign t=(n-1)/2;
 
while (i <n\2)
 
always @(posedgle clk or negedge rest)
 
if (rest == 1'b0)
 
ou <= 0;
 
else
 
if (m < mem[(s+n)/2])
 
n= (s+n)/2 -1;
 
else if ( m > mem[(s+n)/2])
 
s= (s+n)/2 -1;
 
else
ou = (s+n)/2 ;
i=n\2;
 
endmodule

 
Last edited:

Can you please see while the following rtl will be synthesizable

This code would not even be compilable since there is a syntax error. I leave it to you to find out, or at least to compile (which is the minimum effort expected of you).
 

This code would not even be compilable since there is a syntax error. I leave it to you to find out, or at least to compile (which is the minimum effort expected of you).

As I wrote there is no tool here even not a compiler. If there was a compiler, then definitely it would have been compiled before posting here.

Regards

- - - Updated - - -

Can anybody name a good book where RTL s are written from algorithms including the algorithm for binary search?
 

As I wrote there is no tool here even not a compiler. If there was a compiler, then definitely it would have been compiled before posting here.

So you are doing the things in the wrong order; First be prepared with the tools you need, then review the available examples and online language tutorials, and then make experiments by yourself, and finally get help if the previous steps were not enough to help you.
 

So you are doing the things in the wrong order; First be prepared with the tools you need, then review the available examples and online language tutorials, and then make experiments by yourself, and finally get help if the previous steps were not enough to help you.

Not possible to get tools now.
 

Not possible to get tools now.

I'm afraid to ask why, but I'm sure that as soon as you can get them, people will be glad to help you as long you bring the posts with real issues rather bare requests; read above posts, you were already warned on how things works on forums.
 

Go play with FPGAs then. Tools are not a problem.

That is also not possible.


No proper solution is obtained till now from anybody for the code. Can anybody comment whether the code is right or not ? Small mistakes like module name missing , ; present can be ignored,but please state the major problems in this code if any.

Can anybody suggest the name of a good book where examples to write RTLs for different algorithms are taught ?
 

Can anybody comment whether the code is right or not ?
A good start would be to look at the syntaxhighlighter itself in the code you posted above, and see that there is a blatant error. I still let this task for you.

That is also not possible.

As for the impediment to use any tool, as a sign of commitment on your side, one would expect to hear you explain why, but whatever; There are online tools with which you could evaluate your code, and in the course of that time would be to suppose that you had already looked for them, if not, follow one of them, have fun:

https://www.edaplayground.com/

Can anybody suggest the name of a good book

Each one has his preference, and currently there is nothing better than online tutorials, being this one perhaps the most recommended for beginners:

https://www.asic-world.com/verilog/index.html

But if you insist on a printed version, there make a search on the free to use PDFs available by universitie's websites which are very detailed and suited for those who want to take the fundamentals.

No proper solution is obtained till now from anybody for the code

However, if you still expect someone to compile and make tests with the above code for you, this would be a sign of little effort on your part, a strong demotivator for giving you any help.
 

I think it is time to close this topic. OP is clearly looking for someone to do his job.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top