Clocking inside an overloaded function

V

vhdl

Probably a simple issue again, but ...
We are trying to make a process execute vector additions and
multiplications etc., like

Q <= A + B;
Z <= D * E;

and want to stick to this simple notation (C-like) and not use
range-indicators or other details. Just the plain identifiers and
operators This makes a lot of logic, and because we dont have much
timing issues, the functions should ideally be broken down into shifts
and additions etc. Implementing especially the multiplication as a
bit-wise clocked function would be nice.

When implementing a function, fx. for addition like

impure function "+" (a, b : in my_t) return my_t is ... end function
"+";

we cannot seem to get it to work bit-wise. Is there any way of having a
CLOCK'EVENT work inside a function and only return after a number of
clocks, ie. after all bits have been manipulated ?
 
D

David R Brooks

Probably a simple issue again, but ...
We are trying to make a process execute vector additions and
multiplications etc., like

Q <= A + B;
Z <= D * E;

and want to stick to this simple notation (C-like) and not use
range-indicators or other details. Just the plain identifiers and
operators This makes a lot of logic, and because we dont have much
timing issues, the functions should ideally be broken down into shifts
and additions etc. Implementing especially the multiplication as a
bit-wise clocked function would be nice.

When implementing a function, fx. for addition like

impure function "+" (a, b : in my_t) return my_t is ... end function
"+";

we cannot seem to get it to work bit-wise. Is there any way of having a
CLOCK'EVENT work inside a function and only return after a number of
clocks, ie. after all bits have been manipulated ?
Functions are *defined* to be clockless: they execute in (notionally)
zero time.
You can do it with a procedure, but that can't overload an operator.
 
R

Ralf Hildebrandt

We are trying to make a process execute vector additions and
multiplications etc., like

Q <= A + B;
Z <= D * E;

and want to stick to this simple notation (C-like) and not use
range-indicators or other details.

These are just descriptions of plain combinational logic.

Just the plain identifiers and
operators This makes a lot of logic, and because we dont have much
timing issues, the functions should ideally be broken down into shifts
and additions etc. Implementing especially the multiplication as a
bit-wise clocked function would be nice.

You have to break it manually and model it in detail.

When implementing a function, fx. for addition like

impure function "+" (a, b : in my_t) return my_t is ... end function
"+";

we cannot seem to get it to work bit-wise.

It is not intended to do so.

Is there any way of having a
CLOCK'EVENT work inside a function and only return after a number of
clocks, ie. after all bits have been manipulated ?

The methodology is: Build something, that is synchronous to an 'event
and from there call a function if you want.

res2<=std_ulogic_vector( unsigned(A) + unsigned(B) );

process(reset,clock)
begin
if (reset='1') then
res1_ff<=(others=>'0');
elsif rising_edge(clock) then
res1_ff<=std_ulogic_vector( unsigned(A) + unsigned(B) );
-- this is just a parallel adder (pure combinational),
-- that's output is sampled at the rising_edge(clock)
res2_ff<=res2;
-- that is exactly the same (look to where res2 is written)
end if;
end process;

Ralf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top