[VHDL] Beginner: "Syntax error near use "

OP #2301294
Rate this post
• ▲ useful
▼ not useful
Hello All,

As a beginner, I am trying to simulate an XOR gate using AND gates and 
OR gate that I created in vhdl modules and_gate and or_gate 
respectively.

I have a syntax error ("Syntax error near use") on line 62  (marked 
"--Error--") of the testbench file which I am unable to resolve.

Can anyone spot the mistake?

TESTBENCH FILE
---------------

Here is the code:
--X--
1
entity tb_xor_gate is
2
end tb_xor_gate;
3

4
architecture Behavioral of tb_xor_gate is
5
  component xor_gate
6
    port (output: out bit; 
7
        input_a, input_b: in bit);
8
  end component;
9
  
10
  signal signal_a, signal_b, output: bit;
11
begin
12
  XG1: xor_gate port map (input_a => signal_a, input_b => signal_b, 
13
                  output => output);
14
  
15
  DUT: process
16
    begin
17
    signal_a <= '0'; signal_b <= '0';
18
    wait for 10 ns;
19
    signal_a <= '0'; signal_b <= '1';
20
    wait for 10 ns;
21
    signal_a <= '1'; signal_b <= '0';
22
    wait for 10 ns;
23
    signal_a <= '1'; signal_b <= '1';
24
    wait for 10 ns;
25
  end process DUT;
26
end Behavioral;
27

28
configuration cfg_tb_xor_gate of tb_xor_gate is
29
  for Behavioral
30
    for DUT:
31
      use entity work.xor_gate(Behavioral2); --Error--
32
    end for;
33
  end for;
34
end cfg_tb_xor_gate;
--X--

Here is my .vhd File for xor_gate that compiles successfully. The AND 
gates and OR gates also compile without any issues.
--X--
1
entity xor_gate is
2
  port(output: out bit; 
3
      input_a, input_b: in bit);
4
end xor_gate;
5

6
architecture Behavioral2 of xor_gate is
7
  component or_gate 
8
    port (output: out bit; 
9
        input_a, input_b: in bit);
10
  end component;
11
  
12
  component and_gate 
13
    port (output: out bit; 
14
        input_a, input_b: in bit);
15
  end component;
16
  
17
  signal a_not_b, b_not_a: bit;
18
  signal not_inp_a, not_inp_b: bit;
19
begin
20
  not_inp_a <= not input_a;
21
  not_inp_b <= not input_b;
22
  
23
  G1: and_gate port map(a_not_b, input_a, not_inp_b);
24
  G2: and_gate port map(b_not_a, input_b, not_inp_a);
25
  G3: or_gate port map(output, a_not_b, b_not_a);
26
end Behavioral2;
27

28
configuration cfg_xor_gate of xor_gate is
29
  for Behavioral2
30
    for G1: and_gate
31
      use entity work.and_gate(Behavioral);
32
    end for;
33
    
34
    for G2: and_gate 
35
      use entity work.and_gate(Behavioral);
36
    end for;
37
    
38
    for G3: or_gate
39
      use entity work.or_gate(Behavioral);
40
    end for;
41
  end for;
42
end configuration;
--X--

Thanks
OP #2302756
Rate this post
• ▲ useful
▼ not useful
Hello All,

I spotted the mistake.

The "configuration" block in test bench is completely wrong. I am trying 
to assign a configuration of an xor gate for an xor gate used in block 
DUT.

But DUT is a process in testbench with no xor gate. Hence, I retyped the 
configuration block in the testbench file as:

------------------------------------------------
1
configuration cfg_tb_xor_gate of tb_xor_gate is
2
  for Behavioral
3
    for XG1:xor_gate
4
      use entity work.xor_gate(Behavioral2);
5
    end for;
6
  end for;
7
end cfg_tb_xor_gate;
------------------------------------------------

The code now compiles.

Regards,

Edwards

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.