ankit12345
Banned
- Joined
- Dec 27, 2005
- Messages
- 181
- Helped
- 10
- Reputation
- 20
- Reaction score
- 4
- Trophy points
- 1,298
- Location
- bangalore,India
- Activity points
- 0
verilog for loop
r not??????
r not??????
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
ankit12345 said:For(i=0,i< 10,i++)
I think this works.....
where as this......
For(i=0,i<k,i++)
where k is a variable.........changes during simulation.....
I dont think it will be synthesisable........
Comments please.....
ankit12345 said:r not??????
anilkumarv said:It is synthesizable but it is always advised that for loops are not to be used in RTL coding. This is because it consumes lot of resources (like area etc.etc) . However u can use it in behavioral coding becuse we do not synthesize behavioral codes.
begin
for(i=0;i<7;i=i+1)
begin
mem[i+1]=mem[i];
end
mem[7]=0;
end
FvM said:This is synthesisable, but not useful code when using blocking assignment. It has the effect of copying mem[0] to mem[1] .. mem[6] and zeroing mem[7]. A HDL loop is never "executed sequentially", it is evaluated sequentially but executed in parallel.
Using nonblocking "<=" assignment, the code would basically form a shift register, which sounds more meaningful to my opinion. Overwriting of mem[7] would still occur, however.
begin
output<=mem[0];
for(i=0;i<7;i=i+1)
begin
mem[i]<=mem[i+1]; //changed sides
end
mem[7]<=8'b00000000;
end