Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

verilog signed type conversion

Status
Not open for further replies.

Alka Arora

Newbie level 6
Joined
Jan 30, 2009
Messages
12
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,354
Hi ,

In VHDL we have a function to convert std_logic_vector to signed data type.Do we have anything like that in verilog to convert in to signed type in verilog.

for example i have wire [8:0] diff;

I want to convert it into absolute value.

Thanks
Alka
 

It's very easy for verilog.

Code:
module abs_test(da_in,da_out);
input[8:0] da_in;
output[8:0] da_out;
assign da_out=(da_in[8])? (0-da_in):da_in;
endmodule
 

Thanks so much.I have a VHDL function

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
FUNCTION "-"   (L: STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR IS
  BEGIN
    RETURN - SIGNED(L);
  END;
 
  FUNCTION "ABs" (L: STD_LOGIC_VECTOR) RETURN STD_LOGIC_VECTOR IS
  BEGIN
    RETURN ABs (SIGNED(L));
  END;


I want to generate similiar logic in verilog but I am noot able to do that .

Thanks
Alka
 
Last edited by a moderator:

In Verilog, you can cast a signal to signed by using $signed function. e.g. $signed(diff).


Hi ,

In VHDL we have a function to convert std_logic_vector to signed data type.Do we have anything like that in verilog to convert in to signed type in verilog.

for example i have wire [8:0] diff;

I want to convert it into absolute value.

Thanks
Alka
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top