I am communicating with another chip. To setup the other chip I need
to make a reset signal of 20ms and then set some registers.
For the communication I need to make a /IOWR pin low for 60ns and high
for at least 100ns. My result were the two main processes listed in my
previous post.
I have no idea to make it more beautiful and would love to hear some
suggestions of how my betters are doing this
This is quite a common problem, and as you have already discovered,
the solution as a classic state machine is likely to be ugly.
Other advice you've received is sound and well worth considering,
but there's another possible approach that may be interesting.
Even for such a simple problem as this, I would consider using
some kind of programmable processor. It can be incredibly simple:
the instructions could be as crude as
DRIVE_RESET:
needs "time" argument (number of clocks to assert reset)
WRITE_REG:
needs "address" and "data" arguments
STOP:
asserts a signal that says "done" to the
rest of the system
Now you implement a state machine that:
- reads an opcode word from a memory block (a little on-chip ROM)
- performs the instruction, feeding argument values into the
right bits of hardware at the right time
- increments an opcode word pointer ready for the next fetch
If you're targeting an FPGA, the vendors offer tiny CPU cores
that are well-suited for exactly this kind of thing. But for
your example, it's easy enough to do from scratch. Of course,
it burns up a little extra hardware - but the improved structure
of your design is probably well worth it. For example, if you
need to change the sequence of register writes to suit a slightly
different version of the external chip (or to fix a bug - surely
not
) you need only change the ROM contents - the state
mahine design is untouched. Your "procedures" model is
effectively implemented by the tiny processor.
Designing competent CPUs for good performance is really hard.
But designing a little programmable sequence controller,
with no special performance requirements, is rather simple.
For example, if it makes things simpler to add an idle cycle
between fetching the instruction and starting to execute it,
then go ahead and add that idle cycle. After all, this is
being done to set up control registers - it happens very
infrequently, so performance isn't an issue.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
[email protected]
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.