Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

(others => '-') in VHDL

I am trying to set res to "----" which is done in an example in my book. When I run the following code I get the message "failure1":

If I change

I do not get the errormessage.

I tried to isolate the problem and the following code does not give an error message:

But this did not give an error. So do you see why I get the errormessage in the first code?

jsotola's user avatar

  • 2 \$\begingroup\$ "assert tb_res="----" report "failure1" .... Not sure what you are trying to achieve with this statement. You are literally asserting that "If tb result is not don't care, report it as a failure". Is this really what you need? \$\endgroup\$ –  Mitu Raj Commented Jun 26, 2022 at 14:54
  • \$\begingroup\$ @MituRaj Yes, I am trying to find out why it works in one case, but not the other. \$\endgroup\$ –  user394334 Commented Jun 26, 2022 at 15:40
  • \$\begingroup\$ It doesn't make any sense. You are comparing tb_res (value = doesn't care) with some number in right side, which is also doesn't care. You can't determine what would be the output of comparing two such values whose values can be anything. The result should hence be don't care as well. It won't be deterministic as you presume. \$\endgroup\$ –  Mitu Raj Commented Jun 26, 2022 at 17:39
  • \$\begingroup\$ @MituRaj Thank you. I see, but why is it that it works in the second case? \$\endgroup\$ –  user394334 Commented Jun 26, 2022 at 18:21
  • \$\begingroup\$ Because tb_res = 1111 is true for the stimulus you gave to DUT. So assertion is true, not a fail. \$\endgroup\$ –  Mitu Raj Commented Jun 26, 2022 at 18:39

2 Answers 2

You have a very subtle problem.

The short answer is, for this problem, do not use the package ieee.numeric_std_unsigned .

If you look in ieee.std_logic_1164 , you will find that it does not overload the implicitly defined = operator. Hence, matching will be character based - probably like you are expecting.

When you include ieee.numeric_std_unsigned , it treats '0' or 'L' as a '0', '1' or 'H' as a '1', and everything else as an 'X'. This is fine for RTL design, however, it is not so good for testbenches where you want to match on meta values. For ieee.numeric_std.unsigned it does the exact same thing.

For RTL, if you are really doing math, I recommend that you use ieee.numeric_std and types unsigned and signed.

With VHDL-2008, the language also introduces matching relationals, ?=, ?/=, ... . For equality, these treat - as don't care. Matching relationals also return std_ulogic values rather than boolean (when used with std_logic/std_ulogic).

For this reason, I now recommend that people use 'X' instead of '-'. For historical reasons, synthesis tools interpret either of these as a don't care. With the introduction of ?= , if you assign an output to "----" and then compare it with ?= to anything, the result is '1' (aka TRUE).

Hence, I recommend that you recode your when others as:

Jim Lewis's user avatar

  • 1 \$\begingroup\$ I normally use 'U' instead of 'X' for returns that should not be used. It makes no difference during synthesis, but lets me treat 'X' in the synthesis output as a warning rather than as an expected state. \$\endgroup\$ –  Simon Richter Commented Jun 28, 2022 at 18:22

I am pretty sure it is because it doesn't make sense to assign a Don't Care. Don't Care is a umbrella grouping that represents multiple valid, but distinct, values so it only makes sense as a comparison condition, not as a write value because you can only write one value.

It's like positive or negative numbers. Each represents a group of different distinct values so while it makes sense in a comparison to determine whether a value is part of the group or not, it doesn't make sense to assign the group itself to a single value. For example, if I tried to assign "all positive numbers" to an integer, that doesn't make any sense.

Besides, if you ever need to write a Don't Care, you might as well just write any distinct value to it. But even that is pointless: Just don't modify the register it at all. Just use the null keyword to do nothing.

DKNguyen's user avatar

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged vhdl or ask your own question .

  • The Overflow Blog
  • One of the best ways to get value for AI coding tools: generating tests
  • The world’s largest open-source business has plans for enhancing LLMs
  • Featured on Meta
  • User activation: Learnings and opportunities
  • Site maintenance - Mon, Sept 16 2024, 21:00 UTC to Tue, Sept 17 2024, 2:00...

Hot Network Questions

  • Is Produce Flame a spell that the caster casts upon themself?
  • Is it defamatory to publish nonsense under somebody else's name?
  • Example of two dinatural transformations between finite categories that do not compose
  • How to prove that the Greek cross tiles the plane?
  • Browse a web page through SSH? (Need to access router web interface remotely, but only have SSH access to a different device on LAN)
  • How much better is using quad trees than simple relational database for storing location data?
  • Does SpaceX Starship have significant methane emissions?
  • Copyright Fair Use: Is using the phrase "Courtesy of" legally acceptable when no permission has been given?
  • Is it a correct rendering of Acts 1,24 when the New World Translation puts in „Jehovah“ instead of Lord?
  • Fast leap year check
  • Does carbon fiber wings need wing spar?
  • What would the natural diet of Bigfoot be?
  • Why do I often see bunches of medical helicopters hovering in clusters in various locations
  • Is it possible to change the AirDrop location on my Mac without downloading random stuff from the internet?
  • "Famous award" - "on ships"
  • Help on PID circuit design
  • Why is resonance such a widespread phenomenon?
  • siunitx dollar per hour broken going from SI to qty
  • How can I support a closet rod where there's no shelf?
  • What would be an appropriate translation of Solitude?
  • Is there an essential distinction between experienced and observed consciousness?
  • The meaning of an implication in an existential quantifier
  • Why would the absence of Chalmers' 'consciousness' make p-zombie world 'inconceivable'?
  • Concerns with newly installed floor tile

vhdl others signal assignment

Success! Subscription added.

Success! Subscription removed.

Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile .

  • Intel Community
  • Product Support Forums
  • Intel® Quartus® Prime Software

VHDL signal assignment with the OTHERS keyword

  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Printer Friendly Page

Altera_Forum

  • Mark as New
  • Report Inappropriate Content
  • All forum topics
  • Previous topic

Link Copied

vhdl others signal assignment

Community support is provided Monday to Friday. Other contact methods are available here .

Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.

For more complete information about compiler optimizations, see our Optimization Notice .

  • ©Intel Corporation
  • Terms of Use
  • *Trademarks
  • Supply Chain Transparency

vhdl others signal assignment

  • Product Manual
  • Knowledge Base
  • Release Notes
  • Tech Articles
  • Screencasts

Signal Assignments in VHDL: with/select, when/else and case

Sometimes, there is more than one way to do something in VHDL. OK, most of the time , you can do things in many ways in VHDL. Let’s look at the situation where you want to assign different values to a signal, based on the value of another signal.

With / Select

The most specific way to do this is with as selected signal assignment. Based on several possible values of a , you assign a value to b . No redundancy in the code here. The official name for this VHDL with/select assignment is the selected signal assignment .

When / Else Assignment

The construct of a conditional signal assignment is a little more general. For each option, you have to give a condition. This means that you could write any boolean expression as a condition, which give you more freedom than equality checking. While this construct would give you more freedom, there is a bit more redundancy too. We had to write the equality check ( a = ) on every line. If you use a signal with a long name, this will make your code bulkier. Also, the separator that’s used in the selected signal assignment was a comma. In the conditional signal assignment, you need the else keyword. More code for the same functionality. Official name for this VHDL when/else assignment is the conditional signal assignment

Combinational Process with Case Statement

The most generally usable construct is a process. Inside this process, you can write a case statement, or a cascade of if statements. There is even more redundancy here. You the skeleton code for a process (begin, end) and the sensitivity list. That’s not a big effort, but while I was drafting this, I had put b in the sensitivity list instead of a . Easy to make a small misstake. You also need to specify what happens in the other cases. Of course, you could do the same thing with a bunch of IF-statements, either consecutive or nested, but a case statement looks so much nicer.

While this last code snippet is the largest and perhaps most error-prone, it is probably also the most common. It uses two familiar and often-used constructs: the process and the case statements.

Hard to remember

The problem with the selected and conditional signal assignments is that there is no logic in their syntax. The meaning is almost identical, but the syntax is just different enough to throw you off. I know many engineers who permanenty have a copy of the Doulos Golden Reference Guide to VHDL lying on their desks. Which is good for Doulos, because their name gets mentioned all the time. But most people just memorize one way of getting the job done and stick with it.

  • VHDL Pragmas (blog post)
  • Records in VHDL: Initialization and Constraining unconstrained fields (blog post)
  • Finite State Machine (FSM) encoding in VHDL: binary, one-hot, and others (blog post)
  • "Use" and "Library" in VHDL (blog post)
  • The scope of VHDL use clauses and VHDL library clauses (blog post)
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Combining `others` expression with `signed` cast

Let var stand for a signed vector (library IEEE.NUMERIC_STD.ALL) of size m .

Let foo be another variable of type std_logic_vector(n-1 downto 0) , where n is smaller than m.

I want to concatenate a '0' left of foo , then pad it with zeroes in its right until it size is m and then store the result in var .

But Xilinx complains with the following message on synthesis:

How do I do what I want?

Jsevillamol's user avatar

  • 1 You haven't supplied the declaration for divisor, nor rdsor ,necessary to providing a solution. Note neither var nor foo appear in your one line snippet. You've also omitted which revision of the VHDL standard your tool expects. –  user1155120 Commented Nov 26, 2016 at 20:04

2 Answers 2

Assuming rdsor is equivalent to your theoretical var and divisor equivalent to foo you could use two assignments in a process statement:

This works because each element of rdsor is a separate signal and there is only one value for any particular time in a projected output waveform . By not providing an after time_expression in the waveform element of the second assignment the elements of rdsor slice will be assigned the second assignments expression values. (The elements of the first assignment are supplanted by the second). This method of overwriting the projected output waveform is commonly used in providing default values prior to incomplete condition coverage with if statements.

This example analyzes, elaborates and simulates, while doing nothing interesting it demonstrates index ranges are constructed properly.

Notice it avoids the issue of concatenation versus aggregation brought up by Matthew Taylor's answer.

For a single signal assignment in a method not sensitive to tool VHDL revision:

This uses concatenation and subsumes the others into an aggregate. There's a subtype declaration for the trailing '0's portion to allow the aggregate expression to be the target of a qualified expression.

This architecture also analyzes, elaborates and simulates proving index arithmetic is correct.

  • Ups, I mixed up the names of the variables. Thank you for the exhaustive solution! –  Jsevillamol Commented Nov 26, 2016 at 22:37

You would need to use others as part of an aggregate not part of a concatenation . Here's a solution using an aggregate and attributes (which relies on you using VHDL 2008):

https://www.edaplayground.com/x/5Yuw

Matthew's user avatar

  • Notice the -2008 option. –  user1155120 Commented Nov 26, 2016 at 21:42
  • @user1155120 You're right. Not for the first time, I have inadvertently come up with a solution that requires VHDL 2008, because that switch is set by default for Riviera Pro on EDA Playground. –  Matthew Commented Nov 27, 2016 at 15:53

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged vhdl xilinx-ise or ask your own question .

  • The Overflow Blog
  • One of the best ways to get value for AI coding tools: generating tests
  • The world’s largest open-source business has plans for enhancing LLMs
  • Featured on Meta
  • User activation: Learnings and opportunities
  • Site maintenance - Mon, Sept 16 2024, 21:00 UTC to Tue, Sept 17 2024, 2:00...
  • What does a new user need in a homepage experience on Stack Overflow?
  • Announcing the new Staging Ground Reviewer Stats Widget

Hot Network Questions

  • Doesn't nonlocality follow from nonrealism in the EPR thought experiment and Bell tests?
  • Looking for a short story on chess, maybe published in Playboy decades ago?
  • How can I switch from MAG to TRU heading in a 737?
  • Removing extra characters from code environment in beamer
  • Should I write an email to a Latino teacher working in the US in English or Spanish?
  • How should I email HR after an unpleasant / offensive interview?
  • Why did early ASCII have ← and ↑ but not ↓ or →?
  • How many engineers/scientists believed that human flight was imminent as of the late 19th/early 20th century?
  • If Act A repeals another Act B, and Act A is repealed, what happens to the Act B?
  • VBA: Efficiently Organise Data with Missing Values to Achieve Minimum Number of Tables
  • Should I change advisors because mine doesn't object to publishing at MDPI?
  • Is a thing just a class with only one member?
  • "Famous award" - "on ships"
  • Rocky Mountains Elevation Cutout
  • What prevents indoor climbing gyms from making a v18 boulder even if one hasn't been found outside?
  • How can a microcontroller (such as an Arduino Uno) that requires 7-21V input voltage be powered via USB-B which can only run 5V?
  • How much better is using quad trees than simple relational database for storing location data?
  • Keyboard shortcuts for running last command with changes?
  • Subject verb agreement - I as well as he is/am the culprit
  • The meaning of an implication in an existential quantifier
  • How to reply to a revise and resubmit review, saying is all good?
  • Why was Panama Railroad in poor condition when US decided to build Panama Canal in 1904?
  • siunitx dollar per hour broken going from SI to qty
  • How did people know that the war against the mimics was over?

vhdl others signal assignment

GitHub

Select Statement – VHDL Example

Assigning signals using selected signal assignment.

Select statements are used to assign signals in VHDL. They can only be used in combinational code outside of a process . A selected signal assignment is a clear way of assigning a signal based on a specific list of combinations for one input signal. The syntax is demonstrated in the example below. The signal name after with is the signal whose values are used to assign the output signal. The when others clause should always be used to avoid creating a latch by accident.

Note that if you try to put a select statement inside a process, you will get the error: Illegal sequential statement.

Learn Verilog

Leave A Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

Chapter 3 - Data Flow Descriptions

Section 6 - signal assignments.

IMAGES

  1. Solved Problem: (a) Write a VHDL signal assignment to

    vhdl others signal assignment

  2. 006 11 Concurrent Conditional Signal Assignment in vhdl verilog fpga

    vhdl others signal assignment

  3. VHDL Introduction

    vhdl others signal assignment

  4. PPT

    vhdl others signal assignment

  5. Solved Write a VHDL program for signal selected assignment

    vhdl others signal assignment

  6. Solved Write a VHDL code using Selected Signal Assignment to

    vhdl others signal assignment

VIDEO

  1. VHDL Operators

  2. VLSI Signal Processing Week 8 Assignment Solution

  3. VLSI Signal Processing Week 5 Assignment Solution

  4. VLSI Signal Processing Week 6 Assignment Solution

  5. DE0 Nano

  6. Conditional and selected signal assignment statements

COMMENTS

  1. What does "others=>'0'" mean in an assignment statement?

    The expression (others=>’O’) means that all elements are assigned to ’0’. If cmd_r is 8 bit then it will assign 00000000 to cmd_r. If cmd_r is two dimensional then the same thing will be (others =>(others =>'0')).

  2. VHDL Logical Operators and Signal Assignments for ...

    Learn how to use basic VHDL operators and signal assignment statements, such as when else and with select statements, to model combinatorial logic.

  3. (others => '-') in VHDL - Electrical Engineering Stack Exchange

    When you include ieee.numeric_std_unsigned, it treats '0' or 'L' as a '0', '1' or 'H' as a '1', and everything else as an 'X'. This is fine for RTL design, however, it is not so good for testbenches where you want to match on meta values. For ieee.numeric_std.unsigned it does the exact same thing.

  4. VHDL signal assignment with the OTHERS keyword

    I've been trying to do this using the others keyword but I'm not quite sure how to do assignments like that with multiple bits at once. So something like this: outputsignal <= ((23 downto 16) => inputsignal(7 downto 0), others => '0');

  5. Signal Assignments in VHDL: with/select, when/else and case

    Let’s look at the situation where you want to assign different values to a signal, based on the value of another signal. With / Select The most specific way to do this is with as selected signal assignment.

  6. vhdl - Combining `others` expression with `signed` cast ...

    You would need to use others as part of an aggregate not part of a concatenation. Here's a solution using an aggregate and attributes (which relies on you using VHDL 2008): rdsor <= (rdsor'LEFT => '0', (rdsor'LEFT-1) downto (rdsor'LEFT-divisor'LENGTH) => signed(divisor), others => '0');

  7. 6 6.111 Lecture VHDL Statements - MIT OpenCourseWare

    Signal Assignment. outc <= ina AND (inb or inc); If-then-elsif-else. IF. ELSIF. inc = '0' THEN outc <= ina; inc = '1' THEN outc <= inb; ELSE outc <= inc; END IF; Case-When: CASE inc IS WHEN '0' WHEN '1' WHEN OTHERS.

  8. Select Signal Assignment - VHDL Example - Nandland

    Select statements are used to assign signals in VHDL. They can only be used in combinational code outside of a process. A selected signal assignment is a clear way of assigning a signal based on a specific list of combinations for one input signal. The syntax is demonstrated in the example below.

  9. VHDL Tutorial - Signal Assignments

    The following is an example of a conditional signal assignment statement. ... signal d,in,en: bit; ... d<=in when en='1' else d; ... This signal assignment could be used to model a transparent latch. The right hand side of this statement is re-evaluated whenever there is an event on in,en, or d because each of these signals appear on the right ...

  10. X <= (others => '0'); in vhdl : r/FPGA - Reddit">X <= (others => '0'); in vhdl : r/FPGA - Reddit

    VHDL allows assigning bits of a vector (or elements of an aggregate in general) by their positions in a single term. E.g. you could write. x <= (3 => '0', 2 downto 1 => '1', 0 => '0'); which would be equivalent to. x <= "0110"; They keyword others may be used to assign all positions that haven't been assigned in this term yet, so.