- #1
Number2Pencil
- 208
- 1
This is my first time trying to program a GAL22V10 w/ VHDL and I'm having troubles. I'm trying to make a password system with a storing mode and a testing mode, and LEDs to tell you which mode you're in. The user inputs are a reset switch, a test-mode switch, and store-mode switch, 3 switches to represent your password, and an enter button. There's also a time-out input which will take you out of your mode if you take too long to do anything (called "16 count"). The outputs are 3 LEDs, a "Wrong" pin, and a "Correct" pin.
I've attached a block diagram of how I want the processes to work. The code is also attached because it's hard to read on as posted
The problem is I think one GAL should be enough to execute this, as it has enough inputs, outputs and flip-flops, yet the only way I could get it to fit is to use a GAL for EACH process (total of 3). Why is this, and what can I do about it?
Now for some Code:
Architecture PasswordSystem of GAL is
signal memory: std_logic_vector(2 downto 0);
signal test_mode: std_logic;
signal store_mode: std_logic;
signal password_attempted: std_logic;
signal password_set: std_logic;
begin
Mode: Process (test_input, store_input, sixteen_count, password_attempted, password_set, reset)
begin
if (reset = '1' or sixteen_count = '0' or password_attempted = '1' or password_set = '1') then
test_mode <= '0';
store_mode <= '0';
elsif (store_input = '1' and test_input = '0') then
test_mode <= '0';
store_mode <= '1';
elsif (store_input = '0' and test_input = '1') then
test_mode <= '1';
store_mode <= '0';
end if;
end process;
testingLED <= test_mode;
storingLED <= store_mode;
ten_secondsLED <= store_mode or test_mode;
Store: Process (enter, reset)
begin
if (reset = '1') then
memory <= "000";
password_set <= '0';
elsif (rising_edge(enter)) then
if (store_mode = '1') then
memory <= password_inputs;
password_set <= '1'; --password is set, takes out of mode
end if;
end if;
end process;
Test: Process (enter, reset)
begin
if (reset = '1') then
wrong <= '0';
correct <= '0';
elsif (rising_edge(enter)) then
if (test_mode = '1') then
if (inputs = memory) then --correct
password_attempted <= '1';
correct <= '1';
wrong <= '0';
else --wrong
password_attempted <= '1';
correct <= '0';
wrong <= '1';
end if;
end if;
end if;
end process;
I've attached a block diagram of how I want the processes to work. The code is also attached because it's hard to read on as posted
The problem is I think one GAL should be enough to execute this, as it has enough inputs, outputs and flip-flops, yet the only way I could get it to fit is to use a GAL for EACH process (total of 3). Why is this, and what can I do about it?
Now for some Code:
Architecture PasswordSystem of GAL is
signal memory: std_logic_vector(2 downto 0);
signal test_mode: std_logic;
signal store_mode: std_logic;
signal password_attempted: std_logic;
signal password_set: std_logic;
begin
Mode: Process (test_input, store_input, sixteen_count, password_attempted, password_set, reset)
begin
if (reset = '1' or sixteen_count = '0' or password_attempted = '1' or password_set = '1') then
test_mode <= '0';
store_mode <= '0';
elsif (store_input = '1' and test_input = '0') then
test_mode <= '0';
store_mode <= '1';
elsif (store_input = '0' and test_input = '1') then
test_mode <= '1';
store_mode <= '0';
end if;
end process;
testingLED <= test_mode;
storingLED <= store_mode;
ten_secondsLED <= store_mode or test_mode;
Store: Process (enter, reset)
begin
if (reset = '1') then
memory <= "000";
password_set <= '0';
elsif (rising_edge(enter)) then
if (store_mode = '1') then
memory <= password_inputs;
password_set <= '1'; --password is set, takes out of mode
end if;
end if;
end process;
Test: Process (enter, reset)
begin
if (reset = '1') then
wrong <= '0';
correct <= '0';
elsif (rising_edge(enter)) then
if (test_mode = '1') then
if (inputs = memory) then --correct
password_attempted <= '1';
correct <= '1';
wrong <= '0';
else --wrong
password_attempted <= '1';
correct <= '0';
wrong <= '1';
end if;
end if;
end if;
end process;
Attachments
Last edited: