Use of multiple processes in one source

I

illogical

Relative new guy to VHDL here, trying to get my head around it (coming
from a procedural/OO background).

Trying to implement a basic ALU, 5 operations with 5 individual input
gates to indicate they are selected.

I was aiming to use 5 PROCESS statements to 'trigger' when one of the
bits is set high, is this feasible in VHDL? (example below).

architecture Behavioral of alu is
begin
do_add: process (data_a, data_b, op_add) -- add
begin
if op_add = '1' then
y <= data_a + data_b;
end if; end process do_add;

do_sub: process (data_a, data_b, op_comp) -- complement
begin
if op_sub = '1' then
y <= not(data_a)
end if;
end process do_sub;

... and so on.


Or is it 'better practice' to do with multiple if then else statements?
The result is a combinational circuit ether way, but I'm unfamiliar with
the ins and outs of VHDL just yet.

P.S Can't change the way the operation is specified, i.e. must 5
seperate signals rather than one "op code" signal.
 
I

illogical

illogical said:
do_sub: process (data_a, data_b, op_comp) -- complement
begin
if op_sub = '1' then
y <= not(data_a)
end if;
end process do_sub;

.. and so on.

Ugh, obviously stuffed up the copy/paste: should be the complement
operation

do_comp: process (data_a, data_b, op_comp) -- complement
begin
if op_comp = '1' then
y <= not(data_a)
end if;
end process do_comp;
 
E

EvilTche

You've a multi-source problem with your design, you should use only one
single process to assign value to the y signal.

process(data_a, data_b, op_comp)
begin
if cond1 then
y <= something;
elsif cond2 then
y <= otherthing;
...
end if;
end process;
 
E

EvilTche

You'd also consider describing syncronous designs, if you're not
familiar with digital circuits designs, I strongly recommend you start
studying.
 
B

Brian Drummond

Relative new guy to VHDL here, trying to get my head around it (coming
from a procedural/OO background).

Trying to implement a basic ALU, 5 operations with 5 individual input
gates to indicate they are selected.

I was aiming to use 5 PROCESS statements to 'trigger' when one of the
bits is set high, is this feasible in VHDL? (example below).

This creates 5 separate drivers for the "y" signal - unless "y" is a
specific resolved type, all 5 outputs are effectively shorted together.
There are circumstances when you might want to do this, but an ALU is
not typically one of them.
architecture Behavioral of alu is
begin
do_add: process (data_a, data_b, op_add) -- add
begin
if op_add = '1' then
y <= data_a + data_b;
end if; end process do_add;

do_sub: process (data_a, data_b, op_comp) -- complement
begin
if op_sub = '1' then
y <= not(data_a)
end if;
end process do_sub;

.. and so on.


Or is it 'better practice' to do with multiple if then else statements?
The result is a combinational circuit ether way, but I'm unfamiliar with
the ins and outs of VHDL just yet.

Good practice is to state your intent as clearly as you can.

If the intent is to produce one ALU reacting to only one op out of a set
of ops at any time, code it that way - a single process implementing a
"case" statement on the set of ops. A sequence of "if" statements works
too, but encodes priority differently, if (e.g) more than one op is
asserted.

It'll be clearer and smaller that way too. And more familiar to a
procedural programmer.

If the intent is to increase parallelism, e.g. to issue "add" and "sub"
ops simultaneously, and use the separate outputs independently of each
other, you need separate output signals (e.g. y_add, y_sub etc) for each
process. Then separate processes will work just fine, but so will
separate outputs (e.g. from separate "if" statements) within the same
process. This is where you start to think HDL rather than procedurally.
P.S Can't change the way the operation is specified, i.e. must 5
seperate signals rather than one "op code" signal.

They can however be aggregated into one signal

op <= op_add & op_sub & ... ;

Which doesn't prevent the ALU's user asserting more than one.
If he does, what does he expect to happen? That is crucial information
to determine how you should implement the ALU.

Note that the case statement provides a "when others" clause to cover
the defaults and unspecified cases.

- Brian
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top