-- This module integrates the lcd driver, menu state machine, -- message decoder and timer -- -- library ieee; use ieee.std_logic_1164.all; entity enchilada is port ( -- Interface with the lcd screen (through LCD driver) lcd_data_out: out std_logic_vector (7 downto 0); lcd_read_write: out std_logic; lcd_register_select: out std_logic; lcd_enable: out std_logic; -- Interface with the EEPROM (through message decoder) md_data_address: out std_logic_vector (12 downto 0); md_EEPROM_data: in std_logic_vector (7 downto 0); md_chip_enable_not: out std_logic; md_output_enable_not: out std_logic; -- Interface with the buttons (through the menu state machine) sm_push_button_inputs: in std_logic_vector (3 downto 0); --sm_clear_push_buttons: out std_logic_vector (3 downto 0); -- Interface with the Device Controller External circuitry dm_meter_moist: in std_logic_vector (7 downto 0); dm_water_status: out std_logic; dm_valve_on: buffer std_logic; -- Interface with the Device Controller (through the menu state machine) -- sm_user_set_water: out std_logic_vector (7 downto 0); -- sm_water_option_on: out std_logic; -- sm_water_start_hr: buffer std_logic_vector (7 downto 0); -- sm_water_start_m: buffer std_logic_vector (7 downto 0); -- sm_water_end_hr: buffer std_logic_vector (7 downto 0); -- sm_water_end_m: buffer std_logic_vector (7 downto 0); -- Interface with the Timer (normally wouldn't be here, but just want -- to know what the data is). -- tm_new_time: out std_logic; -- tm_new_hour: out std_logic_vector (4 downto 0); -- tm_new_minute: out std_logic_vector (5 downto 0); -- tm_hour: buffer std_logic_vector (4 downto 0); -- tm_minutes: out std_logic_vector (5 downto 0); -- tm_second_pulse: out std_logic; -- Other signals altera_clock, reset: in std_logic); end entity enchilada; architecture behaviour of enchilada is component time is generic (FREQUENCY: positive := 10000); port (clock, reset: in std_logic; new_time: in std_logic; new_hour: in std_logic_vector (4 downto 0); new_minute: in std_logic_vector (5 downto 0); hour: buffer std_logic_vector (4 downto 0); minutes: out std_logic_vector (5 downto 0); second_pulse: out std_logic); end component time; component lcd is port (data_in: in std_logic_vector (7 downto 0); ready_for_line, byte_request: out std_logic; new_line_request, byte_valid: in std_logic; clock, reset: in std_logic; data_out: out std_logic_vector (7 downto 0); read_write, register_select, enable: out std_logic); end component lcd; component message is port ( base_address: in std_logic_vector (12 downto 0); binary_data: in std_logic_vector (7 downto 0); ready_for_message: out std_logic; display_message: in std_logic; request_variable: out std_logic; variable_valid: in std_logic; data_address: out std_logic_vector (12 downto 0); EEPROM_data: in std_logic_vector (7 downto 0); chip_enable_not: out std_logic; output_enable_not: out std_logic; data_to_display: out std_logic_vector (7 downto 0); lcd_ready_for_line: in std_logic; new_line_ready: out std_logic; byte_requested: in std_logic; byte_valid: out std_logic; clock, reset: in std_logic); end component message; component menu_sm is port ( message_address: out std_logic_vector (12 downto 0); variable_data: out std_logic_vector (7 downto 0); decoder_ready: in std_logic; display_message: buffer std_logic; variable_requested: in std_logic; variable_valid: buffer std_logic; set_new_time: out std_logic; set_new_hour: out std_logic_vector (4 downto 0); set_new_minute: out std_logic_vector (5 downto 0); current_hour: in std_logic_vector (4 downto 0); current_minute: in std_logic_vector (5 downto 0); user_set_water: out std_logic_vector (7 downto 0); water_option_on: out std_logic; water_start_hr: buffer std_logic_vector (7 downto 0); water_start_m: buffer std_logic_vector (7 downto 0); water_end_hr: buffer std_logic_vector (7 downto 0); water_end_m: buffer std_logic_vector (7 downto 0); push_button_inputs: in std_logic_vector (3 downto 0); --clear_push_buttons: out std_logic_vector (3 downto 0); clock, reset: in std_logic); end component menu_sm; component device is port( clk : in std_logic; reset : in std_logic; hour : in std_logic_vector( 7 downto 0 ); minute : in std_logic_vector( 7 downto 0 ); second : in std_logic; --only using the LSB meter_moist : in std_logic_vector( 7 downto 0 ); var_moist : in std_logic_vector( 7 downto 0 ); water_session : in std_logic; moist_start_h : in std_logic_vector( 7 downto 0 ); moist_start_m : in std_logic_vector( 7 downto 0 ); moist_end_h : in std_logic_vector( 7 downto 0 ); moist_end_m : in std_logic_vector( 7 downto 0 ); water_status : out std_logic; valve_on : buffer std_logic ); end component device; component internal_clock is port (up1_clock: in std_logic; reset: in std_logic; eg_clock: out std_logic); end component internal_clock; -- Internal signals that will run between the modules -- Between the timer and menu state machine, and device controller signal s_new_time, s_second: std_logic; signal s_new_hour, s_hour: std_logic_vector (4 downto 0); signal s_new_minute, s_minute: std_logic_vector (5 downto 0); signal temp_hour, temp_minute: std_logic_vector (7 downto 0); -- Between the menu state machine and the message decoder signal s_message_address: std_logic_vector (12 downto 0); signal s_variable_data: std_logic_vector (7 downto 0); signal s_decoder_ready, s_display_message: std_logic; signal s_variable_requested, s_variable_valid: std_logic; -- Between the message decoder and lcd driver signal s_ui_data: std_logic_vector (7 downto 0); signal s_ready_for_line, s_byte_request: std_logic; signal s_new_line_request, s_byte_valid: std_logic; -- Between the menu state machine and device controller signal s_user_set_water: std_logic_vector (7 downto 0); signal s_water_option_on: std_logic; signal s_water_start_hr, s_water_start_m: std_logic_vector (7 downto 0); signal s_water_end_hr, s_water_end_m: std_logic_vector (7 downto 0); signal clock: std_logic; begin e_clock: component internal_clock port map (up1_clock => altera_clock, reset => reset, eg_clock => clock); e_time: component time port map ( clock => clock, reset => reset, new_time => s_new_time, -- all signals to the state machine new_hour => s_new_hour, new_minute => s_new_minute, hour => s_hour, minutes => s_minute, second_pulse => s_second); --tm_new_time <= s_new_time; --tm_new_hour <= s_new_hour; --tm_new_minute <= s_new_minute; --tm_minutes <= s_minute; --tm_hour <= s_hour; temp_hour <= "000" & s_hour; temp_minute <= "00" & s_minute; e_device: component device port map ( clk => clock, reset => reset, hour => temp_hour, minute => temp_minute, second => s_second, meter_moist => dm_meter_moist, var_moist => s_user_set_water, water_session => s_water_option_on, moist_start_h => s_water_start_hr, moist_start_m => s_water_start_m, moist_end_h => s_water_end_hr, moist_end_m => s_water_end_m, water_status => dm_water_status, valve_on => dm_valve_on); e_menu_sm: component menu_sm port map ( clock => clock, reset => reset, -- Signals to the message decoder message_address => s_message_address, variable_data => s_variable_data, decoder_ready => s_decoder_ready, display_message => s_display_message, variable_requested => s_variable_requested, variable_valid => s_variable_valid, -- Signals to the timer set_new_time => s_new_time, set_new_hour => s_new_hour, set_new_minute => s_new_minute, current_hour => s_hour, current_minute => s_minute, -- Signals to the Device Controller user_set_water => s_user_set_water, water_option_on => s_water_option_on, water_start_hr => s_water_start_hr, water_start_m => s_water_start_m, water_end_hr => s_water_end_hr, water_end_m => s_water_end_m, -- Signals to the push buttons push_button_inputs => sm_push_button_inputs); --clear_push_buttons => sm_clear_push_buttons); e_message_decoder: component message port map ( clock => clock, reset => reset, -- Signals to the state machine base_address => s_message_address, binary_data => s_variable_data, ready_for_message => s_decoder_ready, display_message => s_display_message, request_variable => s_variable_requested, variable_valid => s_variable_valid, -- Signals to the EEPROM data_address => md_data_address, EEPROM_data => md_EEPROM_data, chip_enable_not => md_chip_enable_not, output_enable_not => md_output_enable_not, -- Signals to the LCD Driver data_to_display => s_ui_data, lcd_ready_for_line => s_ready_for_line, new_line_ready => s_new_line_request, byte_requested => s_byte_request, byte_valid => s_byte_valid); e_lcd_driver: component lcd port map ( clock => clock, reset => reset, -- Signals to the message decoder data_in => s_ui_data, ready_for_line => s_ready_for_line, new_line_request => s_new_line_request, byte_request => s_byte_request, byte_valid => s_byte_valid, -- Signals to the LCD screen data_out => lcd_data_out, read_write => lcd_read_write, register_select => lcd_register_select, enable => lcd_enable); end architecture behaviour;