Altera_Forum
Honored Contributor
11 years agoNew to VHDL, problem with variables/signal?
I am new to VHDL but trying to learn. I would like to make an alarm clock, i decided to start with a mux, 4bit wide 2 to 1. I am using the DE1 board, for testing i want to conect the mux to the switches and show the output on the green leds based on the selector switch. I think that my problem is somehting with the variable scope. can anyone offer any input on the following code?
The error i get right now is: Error (10482): VHDL error at Lab1.vhd(49): object "S" is used but not declared Error (10482): VHDL error at Lab1.vhd(47): object "S" is used but not declared
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY lab1 IS
PORT (
SW : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
HEX0 : OUT STD_LOGIC_VECTOR(0 TO 6);
LEDR : OUT STD_LOGIC_VECTOR(9 DOWNTO 0);
LEDG : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
);
END lab1;
ARCHITECTURE Behavior OF lab1 IS
COMPONENT mux4bit2to1
PORT (
A, B, C, D : IN STD_LOGIC_VECTOR(1 DOWNTO 0); --MUX Inputs
W, X, Y, Z : OUT STD_LOGIC; --MUX Outputs
S : IN STD_LOGIC --Selector bit
);
END COMPONENT;
COMPONENT char7seg
PORT (
N : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
Display : OUT STD_LOGIC_VECTOR(0 TO 6)
);
END COMPONENT;
BEGIN
mux1 : mux4bit2to1 port map(
A(0) => SW(0),
A(1) => SW(5),
B(0) => SW(1),
B(1) => SW(6),
C(0) => SW(2),
C(1) => SW(7),
D(0) => SW(3),
D(1) => SW(8),
W => LEDG(0),
X => LEDG(1),
Y => LEDG(2),
Z => LEDG(3),
S => SW(9)
);
muxselect: PROCESS (S)
BEGIN
case S is
when '0' =>
W <= A(0);
X <= B(0);
Y <= C(0);
Z <= D(0);
when '1' =>
W <= A(1);
X <= B(1);
Y <= C(1);
Z <= D(1);
when OTHERS =>
W <= '0';
X <= '0';
Y <= '0';
Z <= '0';
END CASE;
END PROCESS;
LEDR <= SW;
END Behavior;