Forum Discussion

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

How to initialize a signal without any loops

Hi, I'm very new at learning VHDL and have some trouble dealing with unwanted results of the project I've been working on.

I'm designing a state machine for my school project. What I want to make is an accumulator that can accumulate points and reserve it.

For example, if you choose an item that gives you 1 point, it adds that up to your current point remaining(3) and go back to the

first screen of choosing other items. (my current point becomes 4)

So essentially, it should look like:

my_point_new <= my_point + item_point;

my_point <= my_point_new; (I also learned that this style of code does't work either)

The actual project is much more complicated than this, but I only have problem with this part (jumping from one state to another works fine.)

Inside the 7 bit adder port I put the signal mypoint_add as an input and used tri-state buffers to avoid infinite loop.

I assigned En1 and En2 to be (1,0) or (0,1) respectively for certain states, also assigned an initial value to the signal mypoint_add as "0000000"

Still, whenever I run a vector waveform simulation it shows that mypoint_add is always Z.

Is there any way I can make the initial value of signal mypoint_add to "0000000"?

Best regards,

Erik

3 Replies

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

    Initial value could be achived via signal that perfom reset/clear function.

    Can you draw ASM chart for project and compare it with code.

    Usually you create design starting from ASM chart, then you write code, you allow to compile it and compare your desires (ASM chart) with results (state machine transition, hardware structure, modeling in sims)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The reason you're getting Z output is that you have the en2 almost always 0, giving mypoint_add 'Z'. I see uyou are also trying to drive 000 to it? why are you using tri-states at all? are you trying to connect to some off chip devices?

    I also noticed there are signals missing from the process sensitivity list, this may affect the simulation behaviour.

    There is no way you can initialise mypoint_add because it is just a wire.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Tricky made plenty analysis as usual.

    it is school project, perhaps such structure is described in task. We don't know.

    I see 7bit adder without reset, I see 2 components with tri-state when you can make multiplexer if they really have the same outputs.

    I see output signals from FSM not defined in each state. Better to move them out and make selected assignments some kind of decoder.

    really it is difficult to say that one has FSM with output signal for control only.

    be as much simple as you can until you get wire when you await register.