VHDL Code: Testing Equality of Vectors

Click For Summary

Discussion Overview

The discussion revolves around a VHDL code snippet that aims to test the equality of specific bits within two vectors. Participants are addressing a syntax error encountered in the context of using an "if" statement to compare portions of these vectors.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents a code snippet and describes the intention to check if the first four bits of the vector checkHR are equal to HRH.
  • Another participant suggests that the "if" statement must be placed inside a process, implying that this could be a source of the error.
  • A third participant confirms that the code is indeed within a process but does not provide further details.
  • A later reply indicates that there is no syntax error in the posted code and suggests that the issue may lie in other parts of the code, requesting additional context about the signals and ports involved.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the source of the error, as there are differing views on whether the posted code is correct and whether the placement of the "if" statement is appropriate.

Contextual Notes

Participants note the need for additional context regarding the definitions of signals and ports, as well as the complete process code to better diagnose the issue.

user101
Messages
205
Reaction score
0
Hi all, I have the following code:

if (checkHR(7 downto 4) = HRH) and (checkHR(3 downto 0) = HRL)
and (checkMIN(7 downto 4) = MINH) and (checkMIN(3 downto 0) = MINL) then

SECL <= "0000";
SECH <= "0000";
MINL <= "1000"; -- set to 8888 to notify alarm has been set
MINH <= "1000"; -- set to 8888 to notify alarm has been set
HRL <= "1000"; -- set to 8888 to notify alarm has been set
HRH <= "1000"; -- set to 8888 to notify alarm has been set

where checkHR and checkMIN are 8 bit vectors (7 downto 0)... and SECL, SECH, MINL, MINH, HRL, and HRH are all 4 bit vectors (3 downto 0).

What I'm trying to do is check to see if the first four bits of checkHR is equal to HRH.

Can someone tell me what's wrong? I'm getting the error: Line 74. = can not have such operands in this context.
 
Engineering news on Phys.org
Did you put the code inside a process? You can only use the "if" statement inside a process.
 
Yes, it's in a process.
 
In the portion of code that you posted there is no syntax error. There must be some conflicting code somewhere else. You should post the whole process. Also tell us which of SECL, SECH, MINL, MINH, HRL, HRH, checkHR and checkMIN, are signals and which are ports.
 

Similar threads

Replies
1
Views
9K
  • · Replies 1 ·
Replies
1
Views
12K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
3
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K