- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hai ,
How to write looping constructs like while loop in Altera NIOS? It is giving some error in while statement . The code is always @(posedge clk) begin while (count<=10) begin @(posedge clk) k=k+1; count=count-1; end end In Leonardo Spec it is working, but it is not working in Altera. I gave the EDIF generated from Leon spec to Altera, it worked ? Will it really work well after fusing into FPGA?Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You code isn't able to be synthesised.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by mohana sundaram.s.v+aug 11 2005, 07:47 am--><div class='quotetop'>quote (mohana sundaram.s.v @ aug 11 2005, 07:47 am)</div>
--- quote start ---
in leonardo spec it is working, but it is not working in altera.[/b]
--- quote end ---
it's valid simulation code, but not well-designed synthesis code.
<!--quotebegin-mohana sundaram.s.v@Aug 11 2005, 07:47 AM i gave the edif generated from leon spec to altera, it worked ? --- Quote End --- You have to wonder what was actually synthesized. I didn't see the types of "count" and "k" declared in there, so I assume it's manufacturing "int" variables (as opposed to "reg" variables) for you and initializing them to 0. The "count = count - 1" doesn't seem to make sense in that case, though. --- Quote Start --- originally posted by mohana sundaram.s.v@Aug 11 2005, 07:47 AM will it really work well after fusing into fpga? --- Quote End --- Only way to be sure would be to build the chip and run it through the Altera simulator. I wonder what you're trying to create here. It looks like a counter, which would be just:
reg count;
always @(posedge clk, posedge reset)
if(reset)
count <= 0;
else if(count <= 10)
count <= count + 1;
In general, you should only have @ events show up once after "always" and never within the begin...end block. Bear in mind that Verilog started life as a simulation language, not a synthesis language, and because of that it looks too much like a sequential programming language like C, which tends to lose the simultaneity of hardware design. I recommend you obtain the book advanced digital design with the verilog hdl, ISBN 0-13-089161-4.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page