Signal assignments in clocked processes almost always become registers,
unless they are assigned from a variable (or expression of variables),
after the final "end if;" in which case they will not be registers.
(This is a useful trick, BTW.)
Variables assignments in clocked process by themselves do not determine
register or combinatorial logic. The relative order of assignment to
each reference determines whether each reference is a registered or
combinatorial value. If the variable is assigned, within the same clock
cycle execution of the process, prior to the reference, then the
reference is to a combinatorial value of the variable. If on the other
hand, the most recent assignment to a variable prior to reference was
from a previous clock cycle, then the reference is to a registered
value of the variable.
You might even have a case where the previous assignment may or may not
have happened in the same clock cycle. In this case the synthesis tool
includes a mux, to select between the combinatorial or registered
value, controlled by the same logic that determined whether the
previous assignment happened in the same clock or not.
Just write it out, and read it like software. If the simulator would
have to remember the variables value from a previous clock, then that
reference is to a registered value.
The synthesis tool's job is to give you a circuit that behaves just
like the simulation, or warn you that it could not do so.
Andy
Murph wrote:
> Paul Uiterlinden wrote:
> > Murph wrote:
> >
> > > Hello!
> > > I'm trying to implement a game in VHDL, for simulation on a
> > > Spartan-3 board (through Xilinx WebPack if it matters).
> > >
> > > I need to have a 200-bit array to store the current "state" of the
> > > game board (marking each location as either taken or not), and I
> > > need to store a four-element array of locations on that board that
> > > represent the "current piece" (which isn't accounted for in the 200
> > > bits).
> > >
> > > Would this work?
> >
> > What have you tried, what are the error messages and which error
> > message is it that you do not understand?
> >
> > First think, then try to simulate it, then think again and then if
> > you're stuck, then post your question here with the code and error
> > messages or behavior and expected behavior.
>
> Thanks - I'll try this. I have to write a decent chunk of my project
> before I can really tell if it actually works beyond passing the syntax
> checker, so I wanted to make sure I wasn't making a stupid mistake /
> would have to write it all somehow differently.
>
> > > subtype boardSize is integer range 0 to 199;
> > > type boardArray is array (natural range <>) of bit;
> > > type boardLocation is array (natural range <>) of boardSize;
> > > signal boardState : boardArray(boardSize);
> > > signal pieceLocations : boardLocation(0 to 3);
> > >
> > > Or do you have any better idea / advice? 
> > > Thanks,
> > > --Murph
> > >
> > > PS - Would I be able to address something like
> > > boardArray(boardLocation("1"))?
> >
> > No, but boardArray(boardLocation(1)) would work.
> > It's just a matter of evaluating the expressions and consider the
> > types. boardLocation is an array of integers (or rather a sybtype of
> > integers), so boardLocation(1) (the index must be a natural, which
> > "1" is not) gives an integer (subtype). The index of boardArray is
> > another integer subtype (natural), so your expression is OK.
>
> That make sense
Thanks
>
> > For the rest, given the information available, your approach seems OK.
> > Personally, I would use variables in stead of signals. Signals are
> > only needed for communication between processes. Using synchronous
> > design, I don't see reasons to have boardState or pieceLocations
> > visible in more than one process.
>
> I can do that? We were told that signals would synthesize into
> flip-flops / latches, but variables wouldn't retain their values, so
> they were only good for temporary information. woah 
>
> Thanks for the help / I'll write back if things don't work out, but it
> sounds like I'm starting to understand things better, so hopefully I
> won't have too many questions.
>
> --Murph