Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Beginner Question on State Machine and Components

Reply
Thread Tools

Beginner Question on State Machine and Components

 
 
Brad Smallridge
Guest
Posts: n/a
 
      10-10-2004
Help!

I have a state machine on my top level for an SRAM controller. The states
are sram_state_read, sram_state_write, sram_state_idle, and
sram_state_reset. Presently the design is flat with no components. I want to
put the SRAM paths in a component by itself. Since the SRAM state machine
may influence other parts of the design, I want to have a separate component
for it, or leave it in the top level. Now it seems to me that one should be
able to pass these states down to to the SRAM paths' component using the
type that I decleare on the top level. However I have been unable to find
the syntax for doing this. I suppose I could "hard code" the states into
known patterns of 1s and 0s and pass the the info into the component using
std_logic_vector but this seems counter to high level language philosophy.
Can anybody help?

Thanks,
Brad Smallridge
b r a d @ a i v i s i o n. c o m



 
Reply With Quote
 
 
 
 
Pieter Hulshoff
Guest
Posts: n/a
 
      10-10-2004
Brad Smallridge wrote:
> I have a state machine on my top level for an SRAM controller. The states
> are sram_state_read, sram_state_write, sram_state_idle, and
> sram_state_reset. Presently the design is flat with no components. I want
> to
> put the SRAM paths in a component by itself. Since the SRAM state machine
> may influence other parts of the design, I want to have a separate
> component for it, or leave it in the top level. Now it seems to me that
> one should be able to pass these states down to to the SRAM paths'
> component using the
> type that I decleare on the top level. However I have been unable to find
> the syntax for doing this. I suppose I could "hard code" the states into
> known patterns of 1s and 0s and pass the the info into the component using
> std_logic_vector but this seems counter to high level language philosophy.


I assume you have these states defined in an enumerated type of some sort?
Just define that type within a package, and use that package in both your
FSM, and the level in which you wish to use that FSM. That way you can use
the enumerated type within your entity/component declarations, and for any
signals you want to use to connect that information from one unit to
another.

Regards,

Pieter Hulshoff

 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      10-10-2004
"Brad Smallridge" <> wrote in message news:<>...
> Help!
>
> I have a state machine on my top level for an SRAM controller. The states
> are sram_state_read, sram_state_write, sram_state_idle, and
> sram_state_reset. Presently the design is flat with no components.


What's wrong with that?
Consider enlarging or adding processes
until testing gets difficult. Unless you
have more than one designer involved, I
see no reason for multiple entities
in an SRAM controller.

> I want to
> put the SRAM paths in a component by itself. Since the SRAM state machine
> may influence other parts of the design, I want to have a separate component
> for it, or leave it in the top level.


Consider either a single level or
a top entity with only wires and instances.

> Now it seems to me that one should be
> able to pass these states down to to the SRAM paths' component using the
> type that I decleare on the top level. However I have been unable to find
> the syntax for doing this. I suppose I could "hard code" the states into
> known patterns of 1s and 0s and pass the the info into the component using
> std_logic_vector but this seems counter to high level language philosophy.


You can package constants to share, but
consider shooting for a single entity.
In VHDL synthesis code, the synchronous
process is most cpu-like environment.
You can put a lot into a single process and let
synthesis work out the parallel blocks.

If you like thinking in hardware,
you can write lots of hardware-like
entities and wire them up. Just don't
expect any "high level language"
feel to netlist style-code. Good luck.

-- Mike Treseler
 
Reply With Quote
 
Brad Smallridge
Guest
Posts: n/a
 
      10-11-2004

>> Presently the design is flat with no components.


> What's wrong with that?


That was my original style because I generally do think in hardware. I also
use to work on Atmel chips and found that flat, macroless hardware was
easier to control and understand. But I am learning VHDL for Xilinx now and
would like to understand the workings of the language. And also learn how to
simulate the components. The final design will be more than the SRAM
controller.

I have been able to write the package for this type definition. The Xilinx
component/instantiation tool doesn't seem to understand type in the entities
so one must write your own. Everything seems fine with the state machine
however the synthesize tool seems to want to throw away my bidirection data
ports.

Thanks for the help.


 
Reply With Quote
 
rickman
Guest
Posts: n/a
 
      10-11-2004
Brad Smallridge wrote:
>
> >> Presently the design is flat with no components.

>
> > What's wrong with that?

>
> That was my original style because I generally do think in hardware. I also
> use to work on Atmel chips and found that flat, macroless hardware was
> easier to control and understand. But I am learning VHDL for Xilinx now and
> would like to understand the workings of the language. And also learn how to
> simulate the components. The final design will be more than the SRAM
> controller.
>
> I have been able to write the package for this type definition. The Xilinx
> component/instantiation tool doesn't seem to understand type in the entities
> so one must write your own. Everything seems fine with the state machine
> however the synthesize tool seems to want to throw away my bidirection data
> ports.


I'm not sure why anyone would suggest that a flat design is better.
Using instantiation of components is not hard to learn and is a good way
to decompose a design so that you have independently testable and
reusable modules.

Did you get an answer to your question on how to pass the state machine
signal through the heirarchy?

I would suggest that you consider a tool of software design, information
hiding. I typically think of a state machine as a black box with inputs
and outputs and code my state machine module accordingly. This can be a
bit messy since there can be a lot of signals to pass in and out. But
all the decisions about how to construct and code the FSM are "hidden"
in the module. No need to change any other modules if a detail of the
FSM changes (like a bug fix).

To handle the complexity that comes from a large number of outputs to
other modules, I often define busses for control signals. They are just
indexed slvs, but I use named constants as the indicies which gives me
useful names to work with. Here is an example


PORT (
DatTopReg: IN DataPathSLV;
DatSecReg: IN DataPathSLV;
ALUCntlSel: IN ALUCntlSLV;
SysClk: IN STD_LOGIC;
Reset: IN STD_LOGIC;
ALULogBus: OUT DataPathSLV;
);
END ALU;

ARCHITECTURE behavior OF ALU IS

constant DataWidth : integer := DATA_WIDTH;
SUBTYPE AdderBus IS STD_LOGIC_VECTOR(DataWidth+1 DOWNTO 0);

SIGNAL ALULogRes: DataPathSLV;

BEGIN

with ALUCntlSel(AluLogBit1 downto AluLogBit0) select
ALULogRes <=
DatSecReg AND DatTopReg when ALUAND,
DatSecReg OR DatTopReg when ALUOR,
DatSecReg XOR DatTopReg when ALUXOR,
DatSecReg when ALUPASS,
DataPathSLV'(others=>'X') when others;


The control bus is ALUCntlSel and in this example is indexed with
AluLogBit1 and AluLogBit0. In the module with the FSM that assigns
these values, I use named constants to assign all 7 bits in the bus at
once... very tidy. The control module has some 8 or 9 of these
control/input busses. This is much cleaner than the dozens of
individual signals it would otherwise require.

--

Rick "rickman" Collins


Ignore the reply address. To email me use the above address with the XY
removed.

Arius - A Signal Processing Solutions Company
Specializing in DSP and FPGA design URL http://www.arius.com
4 King Ave 301-682-7772 Voice
Frederick, MD 21701-3110 301-682-7666 FAX
 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      10-12-2004
rickman wrote:

> I'm not sure why anyone would suggest that a flat design is better.


Not better. Just an alternative that should
not be immediately ruled out for a simple design.

-- Mike Treseler
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
State machine - Vending machine - strange behaviour fenster VHDL 3 12-23-2011 09:53 AM
State machine outputs and tri-state Grumps VHDL 2 02-13-2008 11:26 PM
SWING components adjustment in different resolutions - Should show scrollbars less than 800X600 and expand components over this resolution Bluetears76 Java 1 07-01-2004 09:01 PM
Can Choice components respond to keyboard input like HTML Choice components? Mickey Segal Java 0 02-02-2004 10:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57