Thank you for your valuable advice. I have done precisely that. Have
included the function inside a package and using it now. One more
thing, if i write another program and call the above one as a
component, should i be able to proceed? As since the one above doesnt
entirely use concurrent statements. Iam a beginner and hope these
aren't the kind of questions considered nonsensical.
Regards,
Kauser.
The code you originally posted contains what is called in VHDL an
"entity", which defines nothing more than the I/O of a black box that
you might want to instantiate at some point, along with an
"architecture", which tells a synthesizer or a simulator how to build
or model the black box. So as long as you realize that there are only
certain places where you are allowed to instantiate a component (never
inside a process or inside a function or subprogram body, for
example), then yes, you can re-use the entity/architecture code you
wrote.
Incidentally, the (or at least my) preferred way to instantiate the
"component" (which in this case is an entity) is *not* to write a
separate component declaration, the way many on-line examples are
written. This is archaic and is just extra work. There's usually no
need for a separate component declaration, just use the entity
directly. Instead, in the architecture of your higher level module,
just include the square root entity directly like so:
architecture example of something_bigger
....
begin
sqrt_1 : entity work.integer_squareroot port map (clk => top_clk, d=>
top_d, q => top_q, remainder => top_rem);
....
end architecture example;
to hook up to your top level signals. You can instantiate a pair of
these and build a module which computes x^(1/4) for example.
- Kenn