Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

"+" operation with odd number

Altera_Forum
Honored Contributor II
1,879 Views

hi, everyone, I'm new to verilog. I got a problem when I try to use "+" operator. 

I was doing a accumulate sum by add new result to old result. The simulation gives me correct result everytime, but the actual result from FPGA output looks like this: 

 

Current Result: 1 16 7 8 2 5 

Previous Result: 0 0 16 22 30 32 

Final Result 0 16 22 30 32 36 

 

It is clearly that something wrong with the odd numbers. Here is my code about this three data. 

 

reg final_result; reg previous_result; reg counter; always @ (*) begin case(fsm_cs) FSM_START: begin counter <= 0; final_result <= 0; (to FSN_1) end FSM_1: begin previous_result <= final_result; (begin some calculation) end .......... FSM: begin counter <= w_result; final_result <= w_result + previous_result; (back to FSM_1) end  

 

If anyone knows what's wrong or I have confused you please let me know.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
1,238 Views

Is that all your codes? what is the ........ ?  

How is your w_result get assigned? and did you declare your w_result?
0 Kudos
Altera_Forum
Honored Contributor II
1,238 Views

I more the code is asynchronous. Where do all of the inputs come from? Why I'd this design not synchronous?

0 Kudos
Reply