Altera_Forum
Honored Contributor
16 years agoError 10327: Can't determine definition of operator "+"
Hi there everyone,
I'm new to VHDL and the Quartus software, and right now I have a project in which I need to detect the velocity and acceleration of a toy car that passes through 2 infrared LED detectors, which is all connected to the Altera DE2 board. Now my friend and I wrote the code count the time for the car's body to pass through the first LED (sensor1) and the second LED (sensor2). Since we know the car's body length, and we know the time that the LED's are blocked, we can calculate the velocity of the car. We get 2 data: initial and final velocity. Also we calculate the acceleration by subtracting the final velocity by the initial, then dividing it by the total it takes to go from 1st sensor to the 2nd. The problem occurs when we compile it. The problem is when I want to make SecTmp1 : SecTmp1 + 2**i (exponent), which is basically converting from binary to decimal because t1 (the time the 1st sensor is blocked by the car) is stored in an array. I've seen in this forum that Error 10327 occurs when a STD_LOGIC_VECTOR is added using '+', but in this case SecTmp1 is an integer, not an array... so I'm not sure how to tackle this problem. Thanks for the help! Here's the body of the code: LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; USE ieee.std_logic_unsigned.all; ENTITY photosensei IS PORT( a50MHz_clk, wipe_on1, wipe_on2 : IN STD_LOGIC; wipe_off : OUT STD_LOGIC); END photosensei; ARCHITECTURE way OF photosensor IS SIGNAL a2MHz_clk_count: std_logic_vector(19 downto 0); SIGNAL a2MHz_clk : std_logic; SIGNAL t1, t2, tt : std_logic_vector(19 downto 0); VARIABLE seconds1, seconds2, secondst : REAL; VARIABLE v1, v2, a : REAL; --TYPE distance IS RANGE 0 TO 1000000 --UNITS --mm; --cm = 10 mm; --m = 100 cm; --km = 1000 m; --END UNITS distance; CONSTANT track_length : REAL := 0.038; BEGIN PROCESS --2MHz clock BEGIN WAIT UNTIL a50MHz_clk'EVENT AND a50MHz_clk = '1'; IF a2MHz_clk_count < X"19" THEN a2MHz_clk_count <= a2MHz_clk_count + 1; ELSE a2MHz_clk_count <= X"00000"; a2MHz_clk <= NOT a2MHz_clk; END IF; END PROCESS; PROCESS --time_1 and velocity_1 for when sensor 1 is blocked VARIABLE SecTmp1 : REAL; BEGIN WAIT UNTIL wipe_on1'EVENT AND wipe_on1 = '1';--indicates when sensor1 is blocked and gives a 'high signal'. loop_t1 : WHILE wipe_on1 = '1' loop WAIT UNTIL a2MHz_clk'EVENT AND a2MHz_clk = '1'; t1 <= t1 + 1; END LOOP loop_t1; SecTmp1 := 0.0; FOR i IN 0 TO 19 LOOP IF t1(i) = '1' THEN SecTmp1 := SecTmp1 + 2.0**i; - ERROR HERE END IF; seconds1 := SecTmp1; v1 := track_length/seconds1; END LOOP; END PROCESS; PROCESS --time_2 and velocity_2 for when sensor 2 is on VARIABLE SecTmp2 : REAL; BEGIN WAIT UNTIL wipe_on2'EVENT AND wipe_on2 = '1'; --indicates when sensor2 is blocked and gives a 'high signal'. loop_t2 : WHILE wipe_on2 = '1' loop WAIT UNTIL a2MHz_clk'EVENT AND a2MHz_clk = '1'; t2 <= t2 + 1; END LOOP loop_t2; SecTmp2 := 0.0; FOR i IN 0 TO 19 LOOP IF t2(i) = '1' THEN SecTmp2 := SecTmp2 + 2.0**i; END IF; seconds2 := SecTmp2; v2 := track_length/seconds2; END LOOP; END PROCESS; PROCESS --total time from sensei 1 to sensei 2 VARIABLE SecTmpt : REAL; BEGIN WAIT UNTIL wipe_on1'EVENT AND wipe_on1 = '1'; loop_tt : WHILE wipe_on2 = '0' loop WAIT UNTIL a2MHz_clk'EVENT AND a2MHz_clk = '1'; tt <= tt + 1; END LOOP loop_tt; SecTmpt := 0.0; FOR i IN 0 TO 19 LOOP IF tt(i) = '1' THEN SecTmpt := SecTmpt + 2.0**i; END IF; secondst := SecTmpt; END LOOP; END PROCESS; PROCESS (v1, v2, secondst) --acceleration BEGIN a := (v2-v1)/secondst; END PROCESS; END way;