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.

Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.

Q&A for work

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

Assign record to different type without conversion function in VHDL

Brief introduction to the issue I am trying to solve. I have type, which is a subtype of std_logic_vector , representing generic frame. I have also few record types, which represent specific types of frame.

I would like to be able to assign signals/variables of these types without calling conversion functions. I was thinking about 2 ways to achieve this.

Overload assignment operators. However it looks like custom overloading of assignment operators is not possible. I am not 100% as I failed to find this explicitly being said in the standard, but I think so because I have found no examples of such overloading in the IEEE library source codes.

Make specific frame record types a subtypes of t_frame type. It looks like declaring a record as a subtype is also not possible. I have found no examples in the standard.

Does anyone know if it is possible to assign record to different type without conversion function in VHDL?

Al Bundy's user avatar

  • 1 \$\begingroup\$ Assignment is not an operator, to answer Q1.. One hack I've seen used in Ada is to overload a convenient unary operator like "+" (since "+ x" is idempotent with "x") with your conversion functions. Should work equally well in VHDL. Not perfect but "keeps the noise down a bit". \$\endgroup\$ –  user16324 Apr 5, 2020 at 14:29
  • \$\begingroup\$ You mean that assignment is not an operator in VHDL, but assignment in other languages usually are operators, aren't they? By the way the trick with unary operators works, at least in GHDL. Thanks. \$\endgroup\$ –  Al Bundy Apr 5, 2020 at 15:59
  • \$\begingroup\$ The concept of operators comes from mathematics : an operator produces a result without altering any of its arguments. (This allows operators to be treated in special ways, reordering, optimisations, etc without affecting correctness of results). Thus assignment cannot be an operator. But you are correct that some languages are sloppy and get this wrong... \$\endgroup\$ –  user16324 Apr 5, 2020 at 16:34
  • 2 \$\begingroup\$ The two assignments (without conversion) - t_frame_obj <= t_frame_x_obj.a & t_frame_x_obj.b; and t_frame_x_obj <= (a => t_frame_obj(23 downto 20), b => t_frame_object(19 downto 0); Your question has elements of an XY problem and a Yes/No question. \$\endgroup\$ –  user8352 Apr 5, 2020 at 18:47
  • \$\begingroup\$ @user8352 The shown example is trivial just to show the problem. The records I use have much more fields and using the concatenation method you have presented is tedious and error prone (in the sense of typing mistake). \$\endgroup\$ –  Al Bundy Apr 5, 2020 at 19:26

To answer the question directly:

Is it possible to assign a record to a different type without conversion function in VHDL?

No, you will need to write a custom conversion function, or split the assignment out manually as per the comment by @user8352. As you say, this looks messy and is error prone, so a custom conversion function (probably inside a package) is the way to go.

Community'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 that you have read and understand our privacy policy and code of conduct .

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

  • The Overflow Blog
  • If you want to address tech debt, quantify it first
  • Fighting comment spam at Facebook scale (Ep. 602)
  • Featured on Meta
  • Moderation strike: Results of negotiations
  • Our Design Vision for Stack Overflow and the Stack Exchange network

Hot Network Questions

  • How to reduce an LP problem already in its standard form?
  • Question about klala in parshas Ki Tavo
  • Writing multiline equation in align environment -> integrals become smaller?
  • How will we invite the Shekhinah?
  • Why do methane engines require burn-off igniters?
  • Noisy bottom bracket SHIMANO BB-RS500
  • How can I find all integer numbers so that mydistance is an integer number?
  • Is there any clear evidence that private universities are on average better than public ones?
  • What are the balance implications of removing spell lists?
  • Is there a socially-optimal way to drive on a busy interstate?
  • Is "abreast a" something ever correct?
  • Use shader's texture in displacement modifier
  • How many days did it take for the Terminator to find real Sarah Connor?
  • How to appease the Goddess of Traffic Lights
  • What do the white circle and black arrow on the airport chart mean? (VOR identifier and frequency written)
  • Censorship of African-American characters in "Tintin in America"
  • Do interspecies couples exist in Zootopia?
  • Isn't strong ignorability an incorrect assumption in complex causal structures?
  • What - - - - - - - corresponds to the question mark?
  • Are there any Star Trek episodes in which the bad guys looked human and the good guys looked very alien?
  • Refinishing engineered wood with laminate—where to find?
  • Sustainable eating habits as a pilot
  • Half even rounding
  • Why is 50% black/white is 128, and not 127?

assignment types vhdl

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

GitHub

Variables vs. Signals in VHDL

Variables and Signals in VHDL appears to be very similar. They can both be used to hold any type of data assigned to them. The most obvious difference is that variables use the := assignment symbol whereas signals use the <= assignment symbol. However the differences are more significant than this and must be clearly understood to know when to use which one. If you need a refresher, try this page about VHDL variables .

Signals vs. Variables:

  • Variables can only be used inside processes, signals can be used inside or outside processes.
  • Any variable that is created in one process cannot be used in another process, signals can be used in multiple processes though they can only be assigned in a single process .
  • Variables need to be defined after the keyword process but before the keyword begin . Signals are defined in the architecture before the begin statement.
  • Variables are assigned using the := assignment symbol. Signals are assigned using the <= assignment symbol.
  • Variables that are assigned immediately take the value of the assignment. Signals depend on if it’s combinational or sequential code to know when the signal takes the value of the assignment.

The most important thing to understand (and the largest source of confusion) is that variables immediately take the value of their assignment, whereas signals depend on if the signal is used in combinational or sequential code . In combinational code, signals immediately take the value of their assignment. In sequential code, signals are used to create flip-flops, which inherently do not immediately take the value of their assignment. They take one clock cycle. In general, I would recommend that beginners avoid using variables. They can cause a lot of confusion and often are hard to synthesize by the tools.

The example below demonstrates how signals behave differently than variables. Notice that r_Count and v_Count appear to be the same, but they actually behave very differently.

assignment types vhdl

Variables can be a bit tricky to display in simulation. If you are using Modelsim, read more about how to see your variables in Modelsim’s waveform window . Look carefully at the waveform above. Do you see how o_var_done pulses every 5th clock cycle, but o_sig_done pulses every 6th clock cycle? Using signals and variables to store data generates very different behavior . Make sure you clearly understand what you code will be generating and make sure that you simulate your code to check that behaves like you want!

Learn Verilog

Leave A Comment Cancel reply

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

404 Not found

  • Stack Overflow Public questions & answers
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Talent Build your employer brand
  • Advertising Reach developers & technologists worldwide
  • Labs The future of collective knowledge sharing
  • About the company

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.

VHDL assigning literals

I'm trying to use unsigned integers in VHDL with well defined bit widths. It seems VHDL does not like me trying to assign literal values to these types defined as:

But in my IDE (Quartus), I get a complaint "UNSIGNED type does not match integer literal." I also get complaints for adding numbers to types defined like this. Whats the preferred change I need to make?

  • unsigned-integer

Christopher Brown's user avatar

3 Answers 3

See other answers, and note that for non-zero literals, you probably want to do something like:

Substitute a literal for n . This works for n =0 too, of course, but it's not as tidy as (others => '0') .

fru1tbat's user avatar

  • LCD_DATA'LENGTH isn't available until after the semicolon. IEEE Std 1076-1993 10.3 Notes "2—The rules defining immediate scope, hiding, and visibility imply that a reference to an identifier, character literal, or operator symbol within its own declaration is illegal (except for design units). The identifier, character literal, or operator symbol hides outer homographs within its immediate scope—that is, from the start of the declaration. On the other hand, the identifier, character literal, or operator symbol is visible only after the end of the declaration (again, except for design units)." –  user1155120 Mar 18, 2014 at 23:02
  • For -2008 that's Section 12.3 Visibility, same Note 2. –  user1155120 Mar 18, 2014 at 23:16
  • The original erroneous answer provided variable LCD_DATA: unsigned(19 downto 0) := to_unsigned(n, LCD_DATA'length); Essentially something isn't available until it is declared and the declaration is variable_declaration ::= [ shared ] variable identifier_list : subtype_indication [ := expression ] ; , which is where the after the semicolon comment comes from. See IEEE Std 1076-1993 4.3.1.3 (6.4.2.4 -2008) Variable declarations. –  user1155120 Mar 18, 2014 at 23:26
  • Yeah, I'm so used to using that construct in processes, etc., I forgot it was illegal in declarations. –  fru1tbat Mar 19, 2014 at 13:53

And for the 2nd part of your question while adding number of this type.

Check whether you have used above libraries in the code or not.

user3217310's user avatar

unsigned is related to std_ulogic, where the value for an element would be '0'.

which provides an aggregate for the default assignment with all elements set to '0'.

You can't assign a single element of integer type to an array of std_ulogic elements.

You can add signed or unsigned to a natural (unsigned) or integer (signed) using "+" functions defined in package numeric_std:

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 that you have read and understand our privacy policy and code of conduct .

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

  • The Overflow Blog
  • If you want to address tech debt, quantify it first
  • Fighting comment spam at Facebook scale (Ep. 602)
  • Featured on Meta
  • Moderation strike: Results of negotiations
  • Our Design Vision for Stack Overflow and the Stack Exchange network
  • Call for volunteer reviewers for an updated search experience: OverflowAI Search
  • Discussions experiment launching on NLP Collective
  • Temporary policy: Generative AI (e.g., ChatGPT) is banned

Hot Network Questions

  • Training vs increasing gear ratio
  • Who is this Daft Punk looking character?
  • Isn't strong ignorability an incorrect assumption in complex causal structures?
  • Is saturday considered weekday or weekend, or something else?
  • How to reduce an LP problem already in its standard form?
  • People who can't receive O negative blood?
  • One Piece Treasure- Find the number of palindromic substrings in a large substring
  • How to ensure that an optimising compiler will terminate?
  • How can I replace circle objects with a sphere of same radius?
  • What does в сложн. сл. mean in Russian dictionary?
  • a joke in the big bang theory
  • "Just" at the end of a question tag
  • What - - - - - - - corresponds to the question mark?
  • How to center in the definition context?
  • Outlining the boundary of a shape defined by intersections in TikZ
  • 13 puzzles I like
  • Use shader's texture in displacement modifier
  • Roadmap for getting into a US graduate program in physics as an international student
  • Writing multiline equation in align environment -> integrals become smaller?
  • Is there a socially-optimal way to drive on a busy interstate?
  • Is declining an offer to give a talk at a conference halfway around the world a bad idea?
  • Calculate the Distance to a Line Segment
  • Coworker hiding/stealing lab material - advice?
  • How did Catwoman manage to pierce Batman's armor using a sewing claw?

assignment types vhdl

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

IMAGES

  1. PPT

    assignment types vhdl

  2. 😀 Vhdl assignment. Vhdl overload assignment operator. 2019-03-06

    assignment types vhdl

  3. Introduction to VHDL

    assignment types vhdl

  4. VHDL types

    assignment types vhdl

  5. VHDL code for 1 to 8 demux using signal assignment statement

    assignment types vhdl

  6. Learn.Digilentinc

    assignment types vhdl

VIDEO

  1. VHDL Operators

  2. DICA:L2.2 || PROGRAMMING STRUCTURE OF VHDL || BY:G.SANDHYA RANI

  3. C++ Programming 4 Competitions

  4. Assignment 1 Data Types [كود مصري]

  5. دورة FPGA بالعربية الجزء الأول

  6. #two #types of #assignment #front #page #trending #buatifull_designs and uses of#easy #stickynotes

COMMENTS

  1. VHDL Basics

    1. VHDL Basics 2. Objectives 3. Course Outline 4. VHDL Basics 5. VHDL Design Units 6. Architeture Modeling Fundamentals 7. Logic Synthesis 8. Designing Hierarchically 9.

  2. vhdl

    2 Answers Sorted by: 4 Essentially, the difference boils down to whether the signal gets assigned on a clock edge or not. Combinational code, like A <= B + 1 would have A being assigned B+1 "immediately," whereas process (clk) begin if (rising_edge (clk)) then A <= B + 1; end if; end process;

  3. VHDL Logical Operators and Signal Assignments for Combinational Logic

    May 16, 2020 In this post, we discuss the VHDL logical operators, when-else statements, with-select statementsand instantiation. These basic techniques allow us to model simple digital circuits. In a previous post in this series, we looked at the way we use the VHDL entity, architecture and librarykeywords.

  4. 3. Data types

    3.1. Introduction ¶ In the Chapter 2, we used the data-types i.e. 'std_logic' and 'std_logic_vector' to define '1-bit' & '2-bit' input and output ports and signals. Also, some operators e.g. 'and' and 'or' etc. were discussed. In this chapter, some more information is provided on these topics. 3.2. Lexical rules ¶

  5. VHDL Syntax Reference

    The most basic of complete VHDL statements, a signal assignment is likely also one of the most common. Syntax: < signal_name > <= < expression >; -- the expression must be of a form whose result matches. the type of the assigned signal. Examples: std_logic_signal_1 <= not std_logic_signal_2; std_logic_signal <= signal_a and signal_b;

  6. Assign values to an array partially in VHDL?

    Assign values to an array partially in VHDL? Ask Question Asked 6 years, 8 months ago Modified 6 years, 8 months ago Viewed 13k times 1 I have an array in VHDL of the form, type CacheArray is array (0 to 15) of std_logic_vector (33 downto 0); signal cache_array: CacheArray := (others => (others => '0'));

  7. Assign record to different type without conversion function in VHDL

    Overload assignment operators. However it looks like custom overloading of assignment operators is not possible. I am not 100% as I failed to find this explicitly being said in the standard, but I think so because I have found no examples of such overloading in the IEEE library source codes. Make specific frame record types a subtypes of t ...

  8. PDF VHDL Syntax Reference

    1. Bits, Vectors, Signals, Operators, Types 1.1 Bits and Vectors in Port Bits and vectors declared in port with direction. Example: port ( a : in std_logic; -- signal comes in to port a from outside : out std_logic; -- signal is sent out to the port b : inout std_logic; -- bidirectional port

  9. 1. First project

    Digital design using 'VHDL codes', Manual pin assignment for implementation, Pin assignments using '.csv' file, ... Type the Listing ref{vhdl_half_adder_vhdl` in this file and save it as 'half_adder_vhdl.vhd'. Now, set this design as 'top level entity' (Fig. 1.10). We can analyze the design now, but we will do it after assigning ...

  10. syntax

    Contrary to the book Digital Mclogic Design by Bryan Mealy VHDL has no assignment operators. Assignment is a basic operation found in assignment statements and object and interface declarations. - user16145658. Feb 15 at 22:18 ... type array_type is array(0 to 1) of std_logic_vector(7 downto 0); constant my_array : array_type := (0 => x"AB ...

  11. Assignment Symbol

    In VHDL there are two assignment symbols: <= Assignment of Signals := Assignment of Variables and Signal Initialization Either of these assignment statements can be said out loud as the word "gets". So for example in the assignment: test <= input_1; You could say out loud, "The signal test gets (assigned the value from) input_1."

  12. 2. Overview

    VHDL is the hardware description language which is used to model the digital systems. VHDL is quite verbose, which makes it human readable. ... the implementation processes, i.e. pin-assignments and downloading the design on FPGA etc, are discussed in Chapter 1 and Chapter 8. ... to define the 1-bit input and output data-types. Lastly, entity ...

  13. PDF VHDL Handbook

    • A new type that is a part of an existing type, for example a part of the predefined unconstrained array BIT_VECTOR, must be declared as a subtype. type-declaration -›

  14. PDF 6. Sequential and Concurrent Statements in The Vhdl Language

    rent signal assignments, and component instantiations (described in Laboratory No. 8). This laboratory work presents the format and use of sequential and concurrent statements. As examples some basic combinational and sequential circuits are described, such as multiplexers, decoders, flip-flops, regis-ters, and counters. 6.1. Sequential Statements

  15. Multiple assignments in CASE statement in VHDL

    For assign to multiple signals in one statement, the VHDL-2008 supports aggregate assignment, so if you are using VHDL-2008, you can write: WHEN "10" => (output3, output2, output1, output0) <= std_logic_vector' ("0100"); For VHDL-2003, a solution may be to create an intermediate output signal as std_logic_vector, and then assign to this.

  16. Variables vs. Signals in VHDL

    Variables and Signals in VHDL appears to be very similar. They can both be used to hold any type of data assigned to them. The most obvious difference is that variables use the := assignment symbol whereas signals use the <= assignment symbol.

  17. Assignment Symbol

    In VHDL there are two assignment symbols: <= Assignment are Signals := Mission of Variables press Signal Initialization. Either for such assignment instructions able be said out loud as the word "gets". So for example in the assignment: test <= input_1; You could say out loud, "The ringing test gets (assigned the value from) input_1."

  18. unsigned integer

    1. unsigned is related to std_ulogic, where the value for an element would be '0'. variable LCD_DATA: unsigned (19 downto 0) := (others => '0'); which provides an aggregate for the default assignment with all elements set to '0'. You can't assign a single element of integer type to an array of std_ulogic elements.

  19. Review of VHDL Signed/Unsigned Data Types

    The "signed" and "unsigned" data types are defined in the numeric_std package. To use "signed" and "unsigned" data types, we need to include the following lines in our code: 1 library ieee; 2 use ieee.std_logic_1164.all; 3 use ieee.numeric_std.all; Note that the "std_logic_1164" package is required because the "numeric_std ...