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 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;
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.
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 ...?
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.