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.

VHDL if statements making portable condition for non nibble sized words

Status
Not open for further replies.

wtr

Full Member level 5
Joined
May 1, 2014
Messages
299
Helped
29
Reputation
58
Reaction score
25
Trophy points
1,308
Activity points
4,108
Hello all,

This question is primarily related to the problem associated with doing if statement with non-nibble sized words.

for example


Code VHDL - [expand]
1
2
3
4
5
signal sig : std_logic_vector(5 downto 0);
 
if sig = (others => '0') then -- will not work, because the condition is unconstrained.
 
if sig = (sig'range => '0') then -- will work, because the condition is  constrained.



Now what if I wanted to do an if statement on the signal, where every bit must be of one value, but bit 1, 3, 5 for example must be another value.
Lets assume that the signal to under go a conditional check is huge and that it would take a long time for a human to work out (I don't have the integer value for to_unsigned(I, sig'length) command) the total signal value. Therefore, the most practical solution would be to do


Code VHDL - [expand]
1
2
3
constant c_condition : std_logic_vector(121 downto 0) := (5 => '0', 3 => '0', 1=>'0', others => '1');
signal sig : std_logic_vector(121 downto 0)
if sig = c_condition then



However in my quest to take laziness to a whole new level, I don't want to have to declare a constant to use it in the condition. Is there a way I can go straight to the if statement.

Regards,
 

Re: vhdl if statements making portable condition for non nibble sized words

No
Using a constant is the easiest, and at 1 extra line, isnt much of a burden.
Other than the constant, the only other way would be some sort of function, but thats way more complicated that just a constant, and likely to need a constant anyway.

Clear code is preferable to compact code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top