\$\begingroup\$
\$\endgroup\$
2
I have a wire
to which I assign a complex right-hand-side expression with lots of bitwise operations. This right-hand-side expression is quickly becoming long and hard to maintain.
Is there a way I could replace the bitwise operations by if/else
or case
statements to help readability and maintability?
asked Apr 10, 2012 at 12:17
1 Answer 1
\$\begingroup\$
\$\endgroup\$
2
Sure you can, just use the always @(*)
construct (you need to make it a reg
). You can handle inout
ports easily too.
reg res;
assign inout_port = dir_out? res: 1'bz;
always @(*) begin
if (x == 42 && y != z)
res = 10;
else
res = y * 12;
end
answered Apr 10, 2012 at 12:19
-
\$\begingroup\$ The problem is that I cannot make it a
reg
because it is aninout
port. \$\endgroup\$Randomblue– Randomblue2012年04月10日 12:20:37 +00:00Commented Apr 10, 2012 at 12:20 -
\$\begingroup\$ I've edited. Note that you shouldn't be using
inout
ports for internal connections anyway. \$\endgroup\$avakar– avakar2012年04月10日 12:24:52 +00:00Commented Apr 10, 2012 at 12:24
lang-vhdl
?:
. \$\endgroup\$