Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

fsm debuging

fsm debugging

Hi I started to check the fsm on real time and got some strange behaviors.

I tried working with SignalTap but I didn't like the way he display the waves and we didn't really get how to work with him.

So I went to ModelSim and created a test bench and got the next wave form

There is a lot of signals there but I can see that the logic is working, the only problem is that the pwm is not working (the signal in red) and I don't know why.

This design works when all the code is in the same file (without components)

I had the same thing with the encoder enable nut I succeeded in solving it by giving him a default value of '0'.

for another way to look were the program got stuck I used a 7 seg display

where at the commands bk,fd - 1,2 the fsm got stuck at state 15

and in the commands rt,lt - 3,4 the fsm got stuck at state 10

33 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    helo again,

    I think I found the reason why the robot didn't responed to the commands

    Can I inside a component create a constant and caculate its value from generics constans like this:

    generic (

    DC: time:= 17 ms;

    clock_period: time:= 20 ns;

    max_pulse: time:= 1 ms;

    min_pulse: time:= 2 ms;

    );

    constant duty_cycle: integer:= DC/clock_period; --850000

    constant min_cycle: integer:= min_pulse/clock_period; --50000 constant max_cycle: integer:= max_pulse/clock_period; -- 100000

    constant neutral_cycle: integer:= neutral_pulse/clock_period ; --75000

    and then ask

    if (Counter = duty_cycle) then

    I think I can't and that the value of the constant duty_cycle is zero

    thougts?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    Logic has no concept of time. VHDL can be of type time, but you can't expect anything to happen in logic after some number of ms, ns, etc...

    So change all your actions (duty_cycle, min_cycle, neutral_cycle) to be integer counters based on a ms timer count ( this timer count is based on a system clock, which I assume is 50 MHz. Count out ms using timers, then make decisions based on timer values.... you can't compile time into silicon.

    I think Tricky brings up a critical point of FPGA / ASIC design. In case this was too subtle:

    "Before you simulate, make sure your can synthesize the code."

    If you simulate something that can't become logic, it's obviously a waste of time.

    Jerry
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I need to think about that because I don't have a synthesize problem I am working on quartus all the time and only in the end before I am checking my code for real I am going to modelsim for simulation.

    The piace of pwm code I wrote does works when it stand by himself

    and there was no problem in using the time package then.

    More over I am still using it in the main entity because temporlly I have solved the problem by adding another port called duty_cycle tothe pwm component and he his calculated by the same generics...

    so I still don't see why it's a problem

    I can only agree that "logic has no concept of time"