EmbDev.net

Forum: FPGA, VHDL & Verilog Syntax Help with Project


von Annon (Guest)


Rate this post
useful
not useful
1
--Baseball Scorekeeper
2
--STRIKES  
3
library IEEE; 
4
use ieee.std_logic_1164.all; 
5
6
entity strikes is
7
8
port     (button_press        : in std_logic; 
9
       reset                  : in  std_logic; 
10
       led_out            : out std_logic_vector (1 downto 0)
11
      
12
       ); 
13
       
14
end entity; 
15
architecture strikes_arch of strikes is 
16
signal tempLED : std_logic_vector (1 downto 0);
17
begin
18
19
  process ( button_press)
20
    begin 
21
    
22
    if reset='1' then tempLED <="00"; 
23
        elsif rising_edge(button_press) then
24
          
25
      
26
      case tempLED is 
27
      
28
      when "00" => tempLED <="01"; 
29
      when "01" => tempLED <="11"; 
30
      when "10" => tempLED <="00"; 
31
      when "11" => tempLED <="00"; 
32
      when others => tempLED <= "00"; 
33
        end case; 
34
    end if;   
35
  end process; 
36
led_out <= tempLED;
37
end strikes_arch;
38
    
39
40
--BALLS
41
library IEEE; 
42
use ieee.std_logic_1164.all; 
43
44
entity balls is
45
46
port     (button_press        : in std_logic; 
47
       reset             : in  std_logic; 
48
       led_out            : out std_logic_vector (2 downto 0)
49
      
50
       ); 
51
       
52
end entity; 
53
architecture balls_arch of balls is 
54
signal tempLED : std_logic_vector (2 downto 0);
55
begin
56
57
  process ( button_press)
58
    begin 
59
    
60
    if reset='1' then tempLED <="000"; 
61
        elsif rising_edge(button_press) then
62
          
63
      
64
      case tempLED is 
65
      
66
      
67
      when "000" => tempLED <="001"; 
68
      when "001" => tempLED <="011"; 
69
      when "010" => tempLED <="000"; 
70
      when "011" => tempLED <="111"; 
71
      when others => tempLED <= "000"; 
72
        end case;
73
    end if;   
74
  end process; 
75
led_out <= tempLED;
76
end balls_arch; 
77
78
79
library IEEE;
80
use ieee.std_logic_1164.all; 
81
82
entity Baseball is 
83
port   ( b1, b2, b3    : in std_logic;
84
      --mst_rst   : in std_logic; 
85
      strikes   : out std_logic_vector (1 downto 0); 
86
      balls    : out std_logic_vector (2 downto 0)
87
      
88
      ); 
89
90
end entity; 
91
92
architecture Baseball_arch of Baseball is 
93
--signal tempStrikes :  std_logic_vector (1 downto 0);
94
--signal tempBalls   :  std_logic_vector (2 downto 0); 
95
--signal temprst     : std_logic; 
96
97
component strikes is
98
99
port     (button_press        : in std_logic; 
100
       reset                  : in  std_logic; 
101
       led_out            : out std_logic_vector (1 downto 0)
102
      
103
       ); 
104
end component; 
105
106
component balls is
107
108
port     (button_press     : in std_logic; 
109
       reset             : in  std_logic; 
110
       led_out         : out std_logic_vector (2 downto 0)
111
      
112
       ); 
113
114
end component; 
115
116
begin
117
118
  UX0: port map strikes (button_press=> b1, reset=>b3, led_out=>strikes); 
119
  UX1: port map balls   (button_press=> b2, reset=>b3, led_out=>balls ); 
120
121
end Baseball_arch;

Error:
.
Error (10500): VHDL syntax error at Baseball.vhd(121) near text "port"; 
expecting "(", or an identifier ("port" is a reserved keyword), or a 
sequential statement
Error (10500): VHDL syntax error at Baseball.vhd(122) near text "port"; 
expecting "(", or an identifier ("port" is a reserved keyword), or a 
sequential statement

**The "port" it's referring to is in my port mapping section**
I'm not sure if it has something to do with the internal signals. 
Although, looking at my design on paper the only thing connecting the 
"strikes" and "balls" blocks together is my reset which is just tied to 
an external button (b3). Hmm..it's always something small. I'd 
appreciate a look.

Thanks.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
This will give a wrong simuslation due to a wrong sensitivity list:
1
 process ( button_press) begin
2
    if reset='1' then 
3
       tempLED <="00";
4
    elsif rising_edge(button_press) then
5
       ...
And additionally: a button is never(!!!) a clock source. But you will 
see that in real life later on...

But your actual problem is as reported here:
  UX0: port map strikes (
And there:
  UX1: port map balls   (
Check the order of "port map" and "strikes", as well as "port map" and 
"balls"...

: Edited by Moderator
von Jay J. (jboss10)


Rate this post
useful
not useful
Thank you Lothar. You are always willing to help. I figured out what was 
wrong and was able to compile. I do understand, in a real-world 
application this should/would never be done, but for the sake of my 
project it suffices.

Question..I'm trying to figure out how to make this work so when the 
baseball count is, let's say, 3-balls and 1-strike. If the next ball is 
thrown is a "ball" then both the strikes and balls LEDs get reset back 
to "00" and "000", respectively.

Do I create another process? Or another entity entirely? I've done it 
almost 10 different ways and none of which have worked or compiled. It's 
tricky trying to get both balls and strikes to get reset when they are 
in totally different processes. I've only been coding in VHDL for maybe 
two months so bare with me.

I appreciate your help. Enjoy the holidays.

**Corrected Code:
1
--STRIKES  
2
library IEEE; 
3
use ieee.std_logic_1164.all; 
4
5
entity strike is
6
7
port     (button_press        : in std_logic; 
8
       reset                  : in  std_logic; 
9
       led_out            : out std_logic_vector (1 downto 0)
10
      
11
       ); 
12
       
13
end entity; 
14
architecture strike_arch of strike is 
15
signal tempLED : std_logic_vector (1 downto 0);
16
begin
17
18
  process ( button_press)
19
    begin 
20
    
21
    if reset='1' then tempLED <="00"; 
22
        elsif rising_edge(button_press) then
23
          
24
      
25
      case tempLED is 
26
      
27
      when "00" => tempLED <="01"; 
28
      when "01" => tempLED <="11"; 
29
      when "10" => tempLED <="00"; 
30
      when "11" => tempLED <="00"; 
31
      when others => tempLED <= "00"; 
32
        end case; 
33
    end if;   
34
  end process; 
35
led_out <= tempLED;
36
37
end strike_arch;
38
    
39
40
--BALLS
41
library IEEE; 
42
use ieee.std_logic_1164.all; 
43
44
entity ball is
45
46
port     (button_press        : in std_logic; 
47
       reset             : in  std_logic; 
48
       led_out            : out std_logic_vector (2 downto 0)
49
      
50
       ); 
51
       
52
end entity; 
53
architecture ball_arch of ball is 
54
signal tempLED : std_logic_vector (2 downto 0);
55
begin
56
57
  process ( button_press)
58
    begin 
59
    
60
    if reset='1' then tempLED <="000"; 
61
        elsif rising_edge(button_press) then
62
          
63
      
64
      case tempLED is 
65
      
66
      
67
      when "000" => tempLED <="001"; 
68
      when "001" => tempLED <="011"; 
69
      when "010" => tempLED <="000"; 
70
      when "011" => tempLED <="111"; 
71
      when others => tempLED <= "000"; 
72
        end case;
73
    end if;   
74
  end process; 
75
led_out <= tempLED;
76
end ball_arch; 
77
78
79
80
81
library IEEE;
82
use ieee.std_logic_1164.all; 
83
84
entity Baseball is 
85
port   ( b1_strikes, b2_balls, b3_hit    : in std_logic;
86
      strikes   : out std_logic_vector (1 downto 0); 
87
      balls    : out std_logic_vector (2 downto 0)
88
      
89
      ); 
90
91
end entity; 
92
93
architecture Baseball_arch of Baseball is 
94
--signal tempStrikes :  std_logic_vector (1 downto 0);
95
--signal tempBalls   :  std_logic_vector (2 downto 0); 
96
--signal temprst     : std_logic; 
97
98
99
  
100
component strike is
101
102
port     (button_press        : in std_logic; 
103
       reset                  : in  std_logic; 
104
       led_out            : out std_logic_vector (1 downto 0)
105
      
106
       ); 
107
end component; 
108
109
component ball is
110
111
port     (button_press     : in std_logic; 
112
       reset             : in  std_logic; 
113
       led_out         : out std_logic_vector (2 downto 0)
114
      
115
       ); 
116
117
end component; 
118
119
begin
120
121
  UX0: strike port map  (button_press=> b1_strikes, reset=>b3_hit, led_out=>strikes); 
122
  UX1: ball port map    (button_press=> b2_balls, reset=>b3_hit, led_out=>balls); 
123
124
end Baseball_arch;

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.