------------------------------------------------------------------------
-- File: alterra.vhd
--
-- Group: Korrey Scott 237118
-- Milton Mah 341428
-- Mike Holden 346386
--
-- Course: EE 552
-- Project: ASM
-- Instructor: Dr. Duncan Elliott
-- Completed: April 2, 1998
------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
------------------------------------------------------------------------
-- Entity: alterra
--
-- Inputs: state_button: push button on Alterra board, used to change
-- the state of the display
-- hour_button: push button on Alterra board, used to increment
-- the hour
-- minute_button: push button on Alterra board, used to increment
-- the minute
-- revolution: pulse generated by the rotation of the wheel
--
-- clkpulse: 555 timer generated pulse with a frequency of 1kHz
--
-- reset: master reset switch of the entire system
--
-- Outputs: datalines: 8 bit ASCII code sent to the LCD
--
-- reg_select: signal to select either data or instruction
-- register of the LCD
-- lcd_enable: signal used by LCD to read the datalines
------------------------------------------------------------------------
entity alterra is
port( state_button, hour_button, minute_button: in std_logic;
clkpulse, revolution, reset: in std_logic;
litres_ml_pulse: in std_logic;
direct1: in std_logic_vector(2 downto 0);
data_lines: out std_logic_vector(7 downto 0);
reg_select: out std_logic;
lcd_enable: out std_logic
);
end alterra;
architecture behaviour of alterra is
signal top1 : std_logic_vector(7 downto 0);
signal top2 : std_logic_vector(7 downto 0);
signal top3 : std_logic_vector(7 downto 0);
signal top4 : std_logic_vector(7 downto 0);
signal top5 : std_logic_vector(7 downto 0);
signal top6 : std_logic_vector(7 downto 0);
signal top7 : std_logic_vector(7 downto 0);
signal top8 : std_logic_vector(7 downto 0);
signal bottom1 : std_logic_vector(7 downto 0);
signal bottom2 : std_logic_vector(7 downto 0);
signal bottom3 : std_logic_vector(7 downto 0);
signal bottom4 : std_logic_vector(7 downto 0);
signal bottom5 : std_logic_vector(7 downto 0);
signal state : std_logic_vector(2 downto 0);
signal data1_line : std_logic_vector(7 downto 0);
signal data2_line : std_logic_vector(3 downto 0);
signal direction_signal : std_logic_vector( 2 downto 0);
signal change_state_signal : std_logic;
signal seconds_pulse_A : std_logic;
signal hours_A : integer range 0 to 12;
signal minutes_A : integer range 0 to 59;
signal km_per_litre_A : integer range 0 to 127;
signal velocity_A : integer range 0 to 127;
component write_lcd
generic ( max_vector : positive := 7 );
port ( clkpulse : in std_logic;
top_line_col_1: in std_logic_vector (7 downto 0);
top_line_col_2: in std_logic_vector (7 downto 0);
top_line_col_3: in std_logic_vector (7 downto 0);
top_line_col_4: in std_logic_vector (7 downto 0);
top_line_col_5: in std_logic_vector (7 downto 0);
top_line_col_6: in std_logic_vector (7 downto 0);
top_line_col_7: in std_logic_vector (7 downto 0);
top_line_col_8: in std_logic_vector (7 downto 0);
bottom_line_col_1: in std_logic_vector (7 downto 0);
bottom_line_col_2: in std_logic_vector (7 downto 0);
bottom_line_col_3: in std_logic_vector (7 downto 0);
bottom_line_col_4: in std_logic_vector (7 downto 0);
bottom_line_col_5: in std_logic_vector (7 downto 0);
reset: in std_logic;
data_lines: out std_logic_vector(7 downto 0);
reg_select: out std_logic;
lcd_enable: out std_logic
);
end component;
component char_generator
generic ( max_vector : positive := 7 );
port ( state_vector : in std_logic_vector (2 downto 0);
data1: in std_logic_vector (7 downto 0);
data2: in std_logic_vector (3 downto 0);
direct2: in std_logic_vector (2 downto 0);
top_line_col_1: out std_logic_vector (7 downto 0);
top_line_col_2: out std_logic_vector (7 downto 0);
top_line_col_3: out std_logic_vector (7 downto 0);
top_line_col_4: out std_logic_vector (7 downto 0);
top_line_col_5: out std_logic_vector (7 downto 0);
top_line_col_6: out std_logic_vector (7 downto 0);
top_line_col_7: out std_logic_vector (7 downto 0);
top_line_col_8: out std_logic_vector (7 downto 0);
bottom_line_col_1: out std_logic_vector (7 downto 0);
bottom_line_col_2: out std_logic_vector (7 downto 0);
bottom_line_col_3: out std_logic_vector (7 downto 0);
bottom_line_col_4: out std_logic_vector (7 downto 0);
bottom_line_col_5: out std_logic_vector (7 downto 0)
);
end component;
component state_machine
port ( select_button,reset: in std_logic;
minutes: in integer range 0 to 59;
hours: in integer range 0 to 12;
km_per_litre: in integer range 0 to 127;
velocity : in integer range 0 to 127;
state_vector : out std_logic_vector ( 2 downto 0);
data1: out std_logic_vector ( 7 downto 0); -- transmits all data ( or hours if clock state)
data2: out std_logic_vector ( 3 downto 0) -- only used to transmit hours
);
end component;
component push_to_change_state
port ( state_button, clkpulse, reset : in std_logic;
change_state : buffer std_logic
);
end component;
component direction
port( direct1:in std_logic_vector(2 downto 0);
direct2:out std_logic_vector(2 downto 0)
);
end component;
component mileage
generic ( max_odometer: positive:= 1000;
max_mileage: positive := 127;
circumference : positive:=2);
port( litres_ml:in std_logic;
revolution, reset:in std_logic;
km_per_litre:out integer range 0 to max_mileage
);
end component;
component clockchip
port (
reset, clkpulse, hour_button, minute_button: in std_logic;
hour : out integer range 0 to 12;
minute : out integer range 0 to 59;
seconds_pulse : out std_logic
);
end component;
component speed
generic ( circumference:positive:=2;
max_distance:positive:=127;
max_dist_minus_circ:positive:=125);
port ( revolution, reset : in std_logic;
seconds_pulse : in std_logic;
velocity : out integer range 0 to max_distance
);
end component;
begin
writechipmatch: write_lcd port map(
clkpulse => clkpulse,
top_line_col_1 => top1,
top_line_col_2 => top2,
top_line_col_3 => top3,
top_line_col_4 => top4,
top_line_col_5 => top5,
top_line_col_6 => top6,
top_line_col_7 => top7,
top_line_col_8 => top8,
bottom_line_col_1 => bottom1,
bottom_line_col_2 => bottom2,
bottom_line_col_3 => bottom3,
bottom_line_col_4 => bottom4,
bottom_line_col_5 => bottom5,
reset => reset,
data_lines => data_lines,
reg_select => reg_select,
lcd_enable => lcd_enable
);
chargenchipmatch: char_generator port map(
state_vector => state,
data1 => data1_line,
data2 => data2_line,
direct2 => direction_signal,
top_line_col_1 => top1,
top_line_col_2 => top2,
top_line_col_3 => top3,
top_line_col_4 => top4,
top_line_col_5 => top5,
top_line_col_6 => top6,
top_line_col_7 => top7,
top_line_col_8 => top8,
bottom_line_col_1 => bottom1,
bottom_line_col_2 => bottom2,
bottom_line_col_3 => bottom3,
bottom_line_col_4 => bottom4,
bottom_line_col_5 => bottom5
);
displaychipmatch: state_machine port map(
select_button => change_state_signal,
reset => reset,
minutes => minutes_A,
hours => hours_A,
km_per_litre => km_per_litre_A,
velocity => velocity_A,
state_vector => state,
data1 => data1_line,
data2 => data2_line
);
statechange: push_to_change_state port map(
state_button => state_button,
clkpulse => clkpulse,
reset => reset,
change_state => change_state_signal
);
directionchipmatch: direction port map(
direct1 => direct1,
direct2 => direction_signal
);
mileagechipmatch: mileage port map(
litres_ml => litres_ml_pulse,
revolution => revolution,
reset => reset,
km_per_litre => km_per_litre_A
);
clockchipchipmatch: clockchip port map(
reset => reset,
clkpulse => clkpulse,
hour_button => hour_button,
minute_button => minute_button,
hour => hours_A,
minute => minutes_A,
seconds_pulse => seconds_pulse_A
);
speedchipmatch: speed port map(
revolution => revolution,
reset => reset,
seconds_pulse => seconds_pulse_A,
velocity => velocity_A
);
end behaviour;