Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Using numbers in if statement

Status
Not open for further replies.

salim.alam2

Junior Member level 3
Joined
May 8, 2016
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
246
Hi,
I was trying to set an if statement like below:

Code:
if (HORIZONTAL_WIDTH = "1280" and  VERTICAL_LENGTH = "720")then

and I got errors with the numbers in the if condition
Capture.PNG

could you please help me.

Thanks in advance.

Salim
 

Hi,
Thank you for your reply,
Actually you are right that was my bad I solved it but still have a problem:
Capture.PNG
 

The problem is that "1280" and "720" are strings. 1280 and 720 are integer literals. They dont need to be defined, they exist as part of the langauge.

To the OP - it is difficult, with such a small snippet what the problem is, please post ALL of the code. Or at least a COMPLETE example showing the same problems
 
Last edited by a moderator:

Okay, this is a copy of the code



Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
entity Video_Gererater is
Generic (
    constant HORIZONTAL_WIDTH   : integer ;
    --constant VERTICAL_WIDTH   : integer ;
    --constant HORIZONTAL_LENGTH    : integer ;
    constant VERTICAL_LENGTH    : integer 
    );
   port( 
     HREF: in std_logic;
     VSYNC: in std_logic;
     PCLK: in std_logic;
     RESET: in std_logic;
     DATA_IN: in std_logic_vector (7 downto 0);
     DATA_OUT: out std_logic_vector (7 downto 0);
     HORIZONTAL: out std_logic_vector(11 downto 0);
     VERTICAL: out std_logic_vector(10 downto 0);
     FRAME : out std_logic);
end Video_Gererater;
 
architecture Behavioral of Video_Gererater is
   signal H_ROW : std_logic_vector (11 downto 0);
   signal V_LINE : std_logic_vector (10 downto 0);
  
begin   process(PCLK,RESET)
begin
 
if RESET='1' then
         H_ROW <= "000000000000";
         V_LINE <= "00000000000";
 
elsif(rising_edge(PCLK)) then
     if (HREF = '0' and VSYNC = '0')then
 
        if (HORIZONTAL_WIDTH := 1280 and  VERTICAL_LENGTH := 720)then
            if  V_LINE = "0101101000" then
                FRAME = '1';
                H_ROW <= "000000000000";
                V_LINE <= "00000000000";
            elsif   H_ROW = "010100000000" then
                    H_ROW <= "000000000000";
                    V_LINE <= V_LINE + 1;
            else
                H_ROW <= H_ROW + 1;
            end if;
        end if;
 
        if (HORIZONTAL_WIDTH := 1920 and  VERTICAL_LENGTH := 1080)then
            if  V_LINE = "10000111000" then
                FRAME = '1';
                H_ROW <= "000000000000";
                V_LINE <= "00000000000";
            elsif   H_ROW = "011110000000" then
                    H_ROW <= "000000000000";
                    V_LINE <= V_LINE + 1;
            else
                H_ROW <= H_ROW + 1;
            end if;
        end if;
        
 
        if (HORIZONTAL_WIDTH := 1944 and  VERTICAL_LENGTH := 1224)then
            if  V_LINE = "10011001000" then
                FRAME = '1';
                H_ROW <= "000000000000";
                V_LINE <= "00000000000";
            elsif   H_ROW = "011110011000" then
                    H_ROW <= "000000000000";
                    V_LINE <= V_LINE + 1;
            else
                H_ROW <= H_ROW + 1;
            end if;
        end if;
 
        if (HORIZONTAL_WIDTH := 2688 and  VERTICAL_LENGTH := 1520)then
            if  V_LINE = "10111110000" then
                FRAME = '1';
                H_ROW <= "000000000000";
                V_LINE <= "00000000000";
            elsif   H_ROW = "101010000000" then
                    H_ROW <= "000000000000";
                    V_LINE <= V_LINE + 1;
            else
                H_ROW <= H_ROW + 1;
            end if;
        end if;
    end if;
end if;
end process;


and the errors that i got
Capture.PNG

Thank you.
 
Last edited by a moderator:

to the OP: it seems the error code is not the same anymore. You are misusing the assignment operator vs the equality operator.
 
Last edited by a moderator:

Code:
if (HORIZONTAL_WIDTH := 1280 and  VERTICAL_LENGTH := 720)then

Uh,....

:= is a assignment operator for variables, why are you trying to use it as a comparison operator?

= is the equality comparison operator

It appears you haven't read a VHDL book or read the LRM as you don't seem to know the proper syntax.

- - - Updated - - -

Note:
A number of posts have been deleted and edited as they are unhelpful and not related to the OP's question.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top