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.

[SOLVED] error: can't defined "/" operator

Status
Not open for further replies.

fanwel

Full Member level 3
Joined
May 26, 2011
Messages
178
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,878
Hello everyone,

Here is my code where I want to add two values of a vector. For example, I have a vector (3,4) and I want to do like this;
(3+4)/2;

Package my_data_types is
Type vector is array (1 downto 0) of integer;
Type vector_next is array (0 downto 0) of integer;
End my_data_types;

LIBRARY ieee;
USE ieee.ALL;
USE work.my_data_types.all;

ENTITY adddiv IS
PORT (
Ra : IN vector;
clk : IN bit;
A : OUT vector_next
);
END adddiv;

ARCHITECTURE adddiv OF adddiv IS
BEGIN
Process(clk)
variable temp: vector_next;
BEGIN
If clk'event and clk = '1' Then
temp := ((Ra(0) + Ra(1))/2);
End if;
A <= temp(0 downto 0) after 20ns;
END PROCESS;
END adddiv;

But, this error occur:

Error (10327): VHDL error at adddiv.vhd(24): can't determine definition of operator ""/"" -- found 0 possible definitions

Can anyone help me..many thanks
 

kalyanasv

Full Member level 4
Joined
May 17, 2011
Messages
192
Helped
48
Reputation
96
Reaction score
46
Trophy points
1,308
Location
NY
Activity points
2,455
the problem with that is division is not readily synthesizable. So you have a couple of options:
Instead of doing a temp := ((Ra(0) + Ra(1))/2); you can shift right by 2 i.e. srl(Ra(0)+Ra(1)).

Or instead of division you can do multiple subtractions
**broken link removed**

or with synopsys use DW_Div

**broken link removed**

or well you can also use: sra (arthimetic right shift)
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,091
Helped
2,078
Reputation
4,175
Reaction score
2,035
Trophy points
1,393
Activity points
39,384
kaltanasv - you havent looked at the types! Plus "/" is very synthesisable, especially for 2^n.

fanwell - the problem is because there is no "/" operator for the vector_next type. try this instead:

temp(0) := ((Ra(0) + Ra(1))/2);

O also assume this is just a model, because
A <= temp(0 downto 0) after 20ns;

is not synthesisable - the delay will be ignored when you compile.
 
  • Like
Reactions: fanwel

    fanwel

    Points: 2
    Helpful Answer Positive Rating

fanwel

Full Member level 3
Joined
May 26, 2011
Messages
178
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,878
Hi kalyanasv,

It is same division operation with shifter operation?
Your link given above was expired, can you give back..
Thanks for reply

---------- Post added at 04:25 ---------- Previous post was at 03:57 ----------

Hi TrickyDicky,

I solve the problem with your help..Many thanks
 

kalyanasv

Full Member level 4
Joined
May 17, 2011
Messages
192
Helped
48
Reputation
96
Reaction score
46
Trophy points
1,308
Location
NY
Activity points
2,455
Hi,

Trickydicky: your right.

Fanwei: considering you only operating on integers and not std_logic_vectors you are better off using "/" operator as prescribed above.

you could also try sra, srl..which all pretty much give you the same thing.
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,091
Helped
2,078
Reputation
4,175
Reaction score
2,035
Trophy points
1,393
Activity points
39,384
But you cannot do sra and srl on integers.

Plus why would you do any arithmatic on std_logic_vectors? you need signed/unsigned for arithmatic
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top