Forum Discussion

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

one wire fsm

hi,

i'm trying to write a FSM for ibuttton ds1990a using one wire protocol.

after a lot of trys i dont know what is the problem.

if any one could telm me what the problem is i will be very heppy.

thanks...

4 Replies

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

    I am unfamiliar with the protocol, but at first glance it seems all right, but for the clk_count_write variable. You use this without initialisation.

    And another point, why do you choose your state machine to be fully clock dependent? I was tought to make a combinatorial state machine, but to handle the state assignment under a clock edge.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I am unfamiliar with the protocol, but at first glance it seems all right, but for the clk_count_write variable. You use this without initialisation.

    And another point, why do you choose your state machine to be fully clock dependent? I was tought to make a combinatorial state machine, but to handle the state assignment under a clock edge.

    --- Quote End ---

    clk_count_write is defined as an integer range 0 to 183, therefore it initialises to 0. All signals/variables initialise to their leftmost value, unless specified otherwise, hence why std_logic always defaults to 'U'.

    A single process state machine is definiately the way to go. The 2 process method can be prone to errors when engineers forget signals in the sentivity lists, or forget to assign signals in every case. So for most people the single process (under a single clock as you put it) is a very very good idea. With a single process you only need clk (and maybe reset) in the sensitivity list, and every output is registered, so you are not going to get missmatches between simulation and the hardware, and no latches can be created inadvertently.

    To the OP: I dont know enough about single wire interface. But from your code, you didnt post a testbench. How does it work in simulation? can you recreate the problems in a simulation to help debug the problem?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    To the OP: I dont know enough about single wire interface. But from your code, you didnt post a testbench. How does it work in simulation? can you recreate the problems in a simulation to help debug the problem?

    --- Quote End ---

    If you wrote the code from the scratch, it's unlikely that it has no errors at all. So a regular debugging phase should be planned for the project.

    I must confess that I'm not motivated to check your code against the OW specification or design a testbench for it. That's definitely your job.

    If you try to avoid writing a testbnch, you can check the basic design functionality in SignalTap. But due to the large delays needed for OW interface, it's not very comfortable.