Question: Here is my code, attached are images of the error codes I am getting. The first error corresponds to the variable screenshot and the second

Here is my code, attached are images of the error codes I am getting. The first error corresponds to the variable screenshot and the second error is in the IF statement.
SUBDESIGN miniproject
(
clk, reset_n, SW9, SW0, KEY3, KEY2, KEY1, KEY0 : INPUT; -- Inputs
HEX5[6..0], HEX2[6..0], HEX1[6..0], HEX0[6..0] : OUTPUT; --7-segment display outputs
LEDR2, LEDR1, LEDR0, LEDR9 : OUTPUT -- LED outputs
)
VARIABLE
balance : UNSIGNED(8); -- Account balance, 8-bit
next_balance : UNSIGNED(8); -- Next state balance value
state : UNSIGNED(2); -- State machine variable
countdown_timer : UNSIGNED(4); -- Countdown timer (9-0)
sec_count : UNSIGNED(26); -- Counter for 1Hz clock
clk_1hz : NODE; --1Hz clock signal
BEGIN
RESET =0;
IDLE =1;
DEPOSIT =2;
WITHDRAW =3;
MAX_BALANCE =255;
ONE_SEC_COUNT =50000000;
-- Clock divider to generate 1Hz clock
sec_count.CLK = clk;
IF reset_n = GND THEN
sec_count =0;
ELSE
IF sec_count = ONE_SEC_COUNT -1 THEN
sec_count =0;
ELSE
sec_count = sec_count +1;
END IF;
END IF;
clk_1hz =(sec_count = ONE_SEC_COUNT -1);
-- State Machine Logic
state.CLK = clk;
CASE state IS
WHEN RESET =>
next_balance :=0;
IF reset_n = VCC THEN
state := IDLE;
END IF;
WHEN IDLE =>
IF SW9= VCC THEN
state := DEPOSIT;
ELSIF SW0= VCC THEN
state := WITHDRAW;
END IF;
WHEN DEPOSIT =>
IF (KEY3= GND AND (balance +1<= MAX_BALANCE)) THEN
next_balance := balance +1; -- Deposit $1
ELSIF (KEY2= GND AND (balance +10<= MAX_BALANCE)) THEN
next_balance := balance +10; -- Deposit $10
ELSIF (KEY1= GND AND (balance +100<= MAX_BALANCE)) THEN
next_balance := balance +100; -- Deposit $100
END IF;
state := IDLE;
WHEN WITHDRAW =>
IF (KEY3= GND AND balance >=1) THEN
next_balance := balance -1;
LEDR0= VCC; -- Withdraw $1, turn on LEDR0
ELSIF (KEY2= GND AND balance >=10) THEN
next_balance := balance -10;
LEDR1= VCC; -- Withdraw $10, turn on LEDR1
ELSIF (KEY1= GND AND balance >=100) THEN
next_balance := balance -100;
LEDR2= VCC; -- Withdraw $100, turn on LEDR2
ELSIF ((KEY3= GND AND balance <1) OR
(KEY2= GND AND balance <10) OR
(KEY1= GND AND balance <100)) THEN
LEDR9= VCC; -- Insufficient funds, turn on LEDR9
END IF;
state := IDLE;
END CASE;
balance := next_balance;
-- Countdown timer for 10 seconds
countdown_timer.CLK = clk_1hz;
IF reset_n = GND THEN
countdown_timer :=9;
ELSIF state = WITHDRAW AND countdown_timer >0 THEN
countdown_timer := countdown_timer -1;
END IF;
-- Countdown display on HEX5
WITH countdown_timer SELECT
HEX5="7B1000000" WHEN 0,
"7B1111001" WHEN 1,
"7B0100100" WHEN 2,
"7B0110000" WHEN 3,
"7B0011001" WHEN 4,
"7B0010010" WHEN 5,
"7B0000010" WHEN 6,
"7B1111000" WHEN 7,
"7B0000000" WHEN 8,
"7B0010000" WHEN 9,
"7B1111111" WHEN OTHERS;
-- Display on HEX2 and HEX0 based on balance
WITH balance[7..4] SELECT
HEX2="7B1000000" WHEN 0,
"7B1111001" WHEN 1,
"7B0100100" WHEN 2,
"7B0110000" WHEN 3,
"7B0011001" WHEN 4,
"7B0010010" WHEN 5,
"7B0000010" WHEN 6,
"7B1111000" WHEN 7,
"7B0000000" WHEN 8,
"7B0010000" WHEN 9,
"7B1111111" WHEN OTHERS;
WITH balance[3..0] SELECT
HEX0="7B1000000" WHEN 0,
"7B1111001" WHEN 1,
"7B0100100" WHEN 2,
"7B0110000" WHEN 3,
"7B0011001" WHEN 4,
"7B0010010" WHEN 5,
"7B0000010" WHEN 6,
"7B1111000" WHEN 7,
"7B0000000" WHEN 8,
"7B0010000" WHEN 9,
"7B1111111" WHEN OTHERS;
END miniproject; VARIABLE
```
balance : UNSIGNED(8);
next_balance : UNSIGNED(8); -- Next state balance value
state : UNSIGNED(2); -- State machine variable
countdown_timer : UNSIGNED(4); -- Countdown timer (9-0)
sec_count : UNSIGNED(26); -- Counter for 1Hz clock
clk_lhz : NODE; --1Hz clock signal
``````
-- Clock divider to generate 1Hz clock
sec_count.CLK = clk;
IF reset_n = GND THEN
sec_count =0;
ELSE
IF sec_count = ONE_SEC_COUNT -1 THEN
sec_count =0;
ELSE
sec_count = sec_count +1;
END IF;
END IF;
clk

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!