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.

[SOLVED] Can't read operator ""-""

Status
Not open for further replies.

rg350dxlover

Member level 1
Joined
Jul 15, 2008
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Malaysia
Activity points
1,566
Hi guys. Can anybody tell me what's wrong with this code? Is it because of the floating point? Because I tried changing it but I still get the same error. It says - can't determine definition of operator ""-"" -- found 0 possible definitions

Code:
process (timeSTP)
	begin
		if (timeSTP = '0') then
			Np <= (1.00 + (Nin - Nout)*0.25);
		else
			P <= (1.50 + (Nin - Nout)*0.25);
		end if;

Thanks.
 

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
 

thanks treqer but the same error still occurs. here's my full code.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;

entity fare_calculator is
port (
timeSTP : in std_logic;
Nin, Nout : in std_logic;
Np, P : out std_logic
);
end fare_calculator;

architecture rtl of fare_calculator is
begin
process (timeSTP)
begin
if (timeSTP = '0') then
Np <= (1.00 + (Nin - Nout)*0.25);
else
P <= (1.50 + (Nin - Nout)*0.25);
end if;
end process;
end rtl;
 

What are you trying to do?. I believe std_logic types cannot be forced to do arithmetic. Correct me if I am wrong.

try instead
converting to std_logic_vector or
use unsigned ('0' & Nin) - unsigned ('0' & Nout)
 

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

NO. Apart from them being non-standard libraries, they wont help in this case.

You cant do maths with std_logic and real type. Fir a start, you cant synthesise real types.
 

Yep you are right. std_logic types can't perform arithmetic. I have fixed that part.
Well, what I'm trying to do is when timeSTP is 0, the output gives Np, otherwise when timeSTP = 1, the output is P.

use unsigned ('0' & Nin) - unsigned ('0' & Nout)

I don't get this part. Where do I include that in the code?
 

Hi rg350dxlover,

On the above code you given the type of Np and P as std_logic. But the value you are trying to assign those output are not std_logic (1.50, 1.00... etc), am i right ...?
 
I don't get this part. Where do I include that in the code?

You cannot do arith in std_logic as I said. Whenever you need to do arith with bit type, then either use truth table or concatenate one more bit and be sure to perform operation as unsigned\signed. however with single bit logic, you wont be needing that. Use truth table logic.

Sub lut:
A B Y
0 0 0
1 0 1
0 1 1
1 1 0
this is xor equivalent. hence

Nres <= Nin XOR Nout;

so, redesign your formula something like

Np <= (1.00 + (Nres)*0.25);

But before that make sure you use proper notation for fixed point representation for this 0.25. Tool doesn't know what is 0.25....
I'd advice you convert 0.25,Nres,any integers such as 1.00 into fixed point notation and then calculate the formula.
you cannot directly substitute.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top