Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Elevator logic, pins never gets setup

Reply
Thread Tools

Elevator logic, pins never gets setup

 
 
Scorpiion Scorpiion is offline
Junior Member
Join Date: Dec 2008
Posts: 6
 
      11-30-2009
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... :/
 
Reply With Quote
 
 
 
 
jeppe jeppe is offline
Senior Member
Join Date: Mar 2008
Location: Denmark
Posts: 348
 
      12-01-2009
Just a hint!

The while loops inside your process will surely be hard to synthesize.
 
Reply With Quote
 
 
 
 
Scorpiion Scorpiion is offline
Junior Member
Join Date: Dec 2008
Posts: 6
 
      12-01-2009
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?
 
Reply With Quote
 
eliascm eliascm is offline
Member
Join Date: Jan 2009
Posts: 42
 
      12-01-2009
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
 
Reply With Quote
 
Scorpiion Scorpiion is offline
Junior Member
Join Date: Dec 2008
Posts: 6
 
      12-01-2009
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..
 
Reply With Quote
 
jeppe jeppe is offline
Senior Member
Join Date: Mar 2008
Location: Denmark
Posts: 348
 
      12-01-2009
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;
 
Reply With Quote
 
Scorpiion Scorpiion is offline
Junior Member
Join Date: Dec 2008
Posts: 6
 
      12-03-2009
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..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The elevator simulation whitehatmiracle@gmail.com C++ 6 10-16-2007 01:37 AM
The classic elevator simulation problem whitehatmiracle@gmail.com C++ 14 07-02-2007 01:37 AM
DVD Verdict reviews: CAPOTE, ELEVATOR TO THE GALLOWS: CRITERION COLLECTION, and more! DVD Verdict DVD Video 0 04-24-2006 08:24 AM
XML Schema never-never occurence of declared elements / attributes Soren Kuula XML 1 12-01-2005 01:27 PM



Advertisments