Elevator logic, pins never gets setup

Joined
Dec 21, 2008
Messages
6
Reaction score
0
Hi, I'm doing some elevator logic for a school assignment. It is pretty basic with 4 floors and a button on each floor and some leds and a motor for the elevator to run (we have an elevator model here at school that we try our chips in).

So, I have done my elevator logic but my problem is that it looks good to me on papper but when I synthesize it in Warp6.0 the input never gets to any pins... I guess I don't assign them right somehow but I could really need some other persons prospective since I have tried to figure this out for a long time now...

Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;

entity elevator is 
	port(
	clock					: in	std_logic;
	floor_switch	:	in	std_logic_vector(0 to 3);
	floor_sensor	:	in	std_logic_vector(0 to 3);
--	light_inside	: out	std_logic_vector(0 to 3);
--	light_outside	: out	std_logic_vector(0 to 3);
	motor_power		: out	std_logic_vector(0 to 1)
	);
end entity elevator;

architecture elevator_arch of elevator is

type state is (floor_1, floor_2, floor_3, floor_4);
signal this_floor	:state := floor_1;
signal next_floor :state := floor_1;

begin

elevator_switch: process(clock, floor_switch, this_floor, next_floor)
begin
case this_floor is
	when floor_1 => case floor_switch is
				when "1011" => next_floor <= floor_2;
				when "1101" => next_floor <= floor_3;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_1;
			end case ;
	when floor_2 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1101" => next_floor <= floor_3;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_2;
			end case;	
	when floor_3 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1011" => next_floor <= floor_2;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_3;
				end case;
	when floor_4 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1011" => next_floor <= floor_2;
				when "1101" => next_floor <= floor_3;
				when others => next_floor <= floor_4;
				end case;
end case;
end process elevator_switch;

elevator_action: process(next_floor, this_floor)

variable floor_sensor_var :std_logic_vector(0 to 3) := floor_sensor;

begin
case next_floor is
	when floor_1 => case this_floor is
				when floor_1 =>
					motor_power <= "00";
				when others =>
					while (floor_sensor_var AND 1000) loop
						motor_power <= "10";
					end loop;
					motor_power <= "00";
			end case;
	when floor_2 => case this_floor is
				when floor_2 =>
					motor_power <= "00";
				when floor_1 =>
					while (floor_sensor_var AND 0100) loop
						motor_power <= "01";
					end loop;
					motor_power <= "00";
				when floor_3 =>
					while (floor_sensor_var AND 0100) loop
						motor_power <= "10";
					end loop;
					motor_power <= "00";
				when floor_4 =>
					while (floor_sensor_var AND 0100) loop
						motor_power <= "10";
					end loop;
					motor_power <= "00";
				end case;
	when floor_3 => case this_floor is
				when floor_3 =>
					motor_power <= "00";
				when floor_1 =>
					while (floor_sensor_var AND 0010) loop
						motor_power <= "01";
					end loop;
					motor_power <= "00";
				when floor_2 =>
					while (floor_sensor_var AND 0010) loop
						motor_power <= "01";
					end loop;
					motor_power <= "00";
				when floor_4 =>
					while (floor_sensor_var AND 0010) loop
						motor_power <= "10";
					end loop;
					motor_power <= "00";
				end case;
	when floor_4 => case this_floor is
				when floor_4 =>
					motor_power <= "00";
				when others =>
					while (floor_sensor_var AND 0001) loop
						motor_power <= "01";
					end loop;
					motor_power <= "00";
				end case;
end case;
end process elevator_action;

-- elevator_light: process(clock)

check_floor: process(floor_sensor)
begin
	case floor_sensor is
		when "0111" => this_floor <= floor_1;
		when "1011" => this_floor <= floor_2;
		when "1101" => this_floor <= floor_3;
		when "1110" => this_floor <= floor_4;
		when others => this_floor <= floor_1;
	end case;
end process check_floor;

end architecture elevator_arch;

When I have compiled the pinout looks like this in the report file:
Code:
PINOUT INFORMATION    (00:04:35)

Messages:
  Information: All signals pre-placed in user design.


                                 C22V10
                 __________________________________________
       not used *| 1|                                  |24|* not used       
       not used *| 2|                                  |23|* not used       
       not used *| 3|                                  |22|* not used       
       not used *| 4|                                  |21|* not used       
       not used *| 5|                                  |20|* not used       
       not used *| 6|                                  |19|= motor_power(1) 
       not used *| 7|                                  |18|= motor_power(0) 
       not used *| 8|                                  |17|* not used       
       not used *| 9|                                  |16|* not used       
       not used *|10|                                  |15|* not used       
       not used *|11|                                  |14|* not used       
       not used *|12|                                  |13|* not used       
                 __________________________________________

It feel that I have missed some basic assignment somewhere or something like that but I just can't see it... :/
 
Joined
Mar 10, 2008
Messages
348
Reaction score
0
Just a hint!

The while loops inside your process will surely be hard to synthesize.
 
Joined
Dec 21, 2008
Messages
6
Reaction score
0
Well, tell my why? :S Is the problem that I never drive the clock? It feels I should drive the clock somewhere maybe? Or should I redo everything?
 
Joined
Jan 30, 2009
Messages
42
Reaction score
0
Elevator Logic

In the process "elevator_action", the variable "floor_sensor_var" is declared and given an initial assignment, but thereafter is never assigned a value. Instead of using a variable there you could use the signal "floor_sensor" itself. Not using the clock input will not necessarily keep your design from properly compiling, but it is considered good practice to use synchronous logic for most designs.

You do not have to redo everything to make your processes synchronous. The basic case statements will remain the same, but will nested within an "if rising_edge(clock) statement (if you prefer an single-process state machine structure).

Charles
 
Joined
Dec 21, 2008
Messages
6
Reaction score
0
Okey, that sounds promising! But the reason I used a variable was because I could not use the std_logic_vector to compare it with some value... I have tried to cast it with unsigned() and to cast the other number with std_logic_vector() but I can't get it to work.. Only get errors.. I want to either compare them with "floor_sensor /= floor_1" or "floor_sensor AND 1000", both give the same result but I can't get any of them to work.. I get
Code:
lab2.vhd (line 62, col 59):  (E101) Can't handle function call 'cmp_vv_us_bl' here
Or:
Code:
lab2.vhd (line 62, col 60):  (E101) Can't handle function call '"and"' here
Or:
Code:
lab2.vhd (line 72, col 32):  (E89) 'floor_sensor(0)' must be a CONSTANT or VARIABLE

My teacher can't help me either.. :/ Hm..
 
Joined
Mar 10, 2008
Messages
348
Reaction score
0
Well you should remember that VHDL a Hardware Describtion Language - and the way you use while loops only usefull for a computer program.

Study this solution:

Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity elavator is
	port(
	clock					: in	std_logic;
	floor_switch	:	in	std_logic_vector(0 to 3);
	floor_sensor	:	in	std_logic_vector(0 to 3);
--	light_inside	: out	std_logic_vector(0 to 3);
--	light_outside	: out	std_logic_vector(0 to 3);
	motor_power		: out	std_logic_vector(0 to 1)
	);
end elavator;

architecture elevator_arch of elavator is

type state is (floor_1, floor_2, floor_3, floor_4);
signal this_floor	:state := floor_1;
signal next_floor :state := floor_1;

begin

elevator_switch: process( floor_switch, this_floor)
begin
case this_floor is
	when floor_1 => case floor_switch is
				when "1011" => next_floor <= floor_2;
				when "1101" => next_floor <= floor_3;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_1;
			end case ;
	when floor_2 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1101" => next_floor <= floor_3;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_2;
			end case;	
	when floor_3 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1011" => next_floor <= floor_2;
				when "1110" => next_floor <= floor_4;
				when others => next_floor <= floor_3;
				end case;
	when floor_4 => case floor_switch is
				when "0111" => next_floor <= floor_1;
				when "1011" => next_floor <= floor_2;
				when "1101" => next_floor <= floor_3;
				when others => next_floor <= floor_4;
				end case;
end case;
end process elevator_switch;

elevator_action: process(next_floor, this_floor)
begin
case next_floor is
	when floor_1 => 
         case this_floor is
				when floor_1 =>
					motor_power <= "00";
				when others =>
					motor_power <= "10";
			end case;
	when floor_2 => case this_floor is
				when floor_2 =>
					motor_power <= "00";
				when floor_1 =>
					motor_power <= "01";
				when floor_3 | floor_4 =>
					motor_power <= "10";
				end case;
	when floor_3 => case this_floor is
				when floor_3 =>
					motor_power <= "00";
				when floor_1 | floor_2 =>
					motor_power <= "01";
				when floor_4  =>
					motor_power <= "10";
				end case;
	when floor_4 => case this_floor is
				when floor_4 =>
					motor_power <= "00";
				when others =>
					motor_power <= "01";
				end case;
end case;
end process elevator_action;

-- elevator_light: process(clock)

check_floor: process(floor_sensor)
begin
	case floor_sensor is
		when "0111" => this_floor <= floor_1;
		when "1011" => this_floor <= floor_2;
		when "1101" => this_floor <= floor_3;
		when "1110" => this_floor <= floor_4;
		when others => this_floor <= floor_1;
	end case;
end process check_floor;

end architecture elevator_arch;
 
Joined
Dec 21, 2008
Messages
6
Reaction score
0
Well, my elevator is finished now! To summarize our GAL22V10 is very small and the code had to be very optimized for that, I actually rewrote the whole thing and removed the part with states and used the inside and outside lights as inout to use them better.. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top