A
Amal
Guest
How does one code the following VHDL function snippet, in Verilog2001/
SystemVerilog?
function mult( a : std_logic_vector; b : std_logic_vector )
return std_logic_vector is
variable result : std_logic_vector(a'length+b'length downto 0);
begin
result := a * b;
return result;
end function mult;
I thought of doing it this way first:
function bit[] mult( const bit [] a, const bit [] b )
bit [a.size+b.size:0] result;
result = a * b;
return result;
endfunction : mult;
But apparently this does not work!
Better yet, I do not think there is function overloading in
Verilog2001/SystemVerilog, then how can I define another function with
different arguments with the same name?
function mult( a : std_logic_vector; b : integer ) return
std_logic_vector;
I though Verilog/SystemVerilog added VHDL features that were missing!
It is a pity if these are not available. I might not be aware of how
to do the same thing in Verilog/SystemVerilog. It should be pretty
simple to do these simple things for Verilog2001/SystemVerilog fluent
coders hopefully.
Cheers,
-- Amal
SystemVerilog?
function mult( a : std_logic_vector; b : std_logic_vector )
return std_logic_vector is
variable result : std_logic_vector(a'length+b'length downto 0);
begin
result := a * b;
return result;
end function mult;
I thought of doing it this way first:
function bit[] mult( const bit [] a, const bit [] b )
bit [a.size+b.size:0] result;
result = a * b;
return result;
endfunction : mult;
But apparently this does not work!
Better yet, I do not think there is function overloading in
Verilog2001/SystemVerilog, then how can I define another function with
different arguments with the same name?
function mult( a : std_logic_vector; b : integer ) return
std_logic_vector;
I though Verilog/SystemVerilog added VHDL features that were missing!
It is a pity if these are not available. I might not be aware of how
to do the same thing in Verilog/SystemVerilog. It should be pretty
simple to do these simple things for Verilog2001/SystemVerilog fluent
coders hopefully.
Cheers,
-- Amal