How to create a signal vector in VHDL: std_logic_vector

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024
  • Learn how to create a data bus in VHDL using the std_logic_vector type. This type can be used for creating arrays of std_logic signals. It is the most commonly used vector type in VHDL.
    This is the blog post for this video:
    vhdlwhiz.com/s...
    The syntax for declaring a std_logic_vector signal is:
    signal signal_name : std_logic_vector(range) := initial_value;
    Of course, you have to replace "signal_name", "range", and "initial_value" with something of your own. The initial value is optional.
    A range in VHDL is some kind of integer range. (0 to 9) is a valid range, and so is (9 downto 0). Both of these define 10 bit position. The "to" or "downto" denotes the direction of the range. For example, we can declare vector like this:
    signal MySlv : std_logic_vector(9 downto 0);
    The above example will yield a 10 bit vector where the LSB (least significant bit) is at the rightmost position.When using "downto", you get the bit ordering which is known as "little endian". This is the preferred way of declaring std_logic_vectors in VHDL. Meaning, that I've never see anyone declare bit vectors using "to".
    To specify an initial value, or to assign to a std_logic_vector, we have to enclose our value in double quotes. For example:
    MySlv <= "0000000001";
    The above statement will assign the value '1' to the rightmost bit position, and '0' to all the others.

Комментарии • 39

  • @MrFKD
    @MrFKD 3 года назад

    I don't know how i missed videos of a teacher like this one ...excellent job thanks a bunch sir

  • @nafisahmed6247
    @nafisahmed6247 2 года назад

    without slv6(0)

  • @marcomoldenhauer7903
    @marcomoldenhauer7903 11 месяцев назад

    [6:03] I initialized two vectors, V1 (signal V1: std_logic_vector(7 downto 0) := "10101111") and V2 (signal V2: std_logic_vector(0 to 7) := "10101111"). In the Wave window, both vectors display the same bit sequence: "10101111." However, I expected V2 to be shown in the reverse order compared to V1. So, I anticipated the bit sequence for V1 to be "10101111" and for V2 to be "11110101." Is there any specific reason why ModelSim is not displaying it this way? THX

  • @whootoo1117
    @whootoo1117 7 лет назад +1

    Thank you for your great and interesting way of explaining everything!

  • @tts9898
    @tts9898 4 года назад

    I have a 4bit vector input and i want to take only LSB 2bits and LSB 1 bit. how i can to that?? I want to use it for a if statement . There are any other method?

  • @willashland4597
    @willashland4597 7 лет назад +6

    EPICALLY GOOD INFORMATION THANK YOU

  • @marcomoldenhauer7903
    @marcomoldenhauer7903 11 месяцев назад

    [7:49] I used the exact same code as shown in your video, but I'm not getting the same result as demonstrated. In my simulation wave window, at 10 ns, the vector Slv6 displays the value '00000011' instead of '00000010' as depicted on the right-hand side of the video. And at 70 ns the vector Slv6 has the value '11111111' instead of '10000000'. Do you know what is the reason for that? THX and BR

    • @marcomoldenhauer7903
      @marcomoldenhauer7903 11 месяцев назад

      Sorry 😞, my mistake I forgot to add the statement: Slv6(0)

  • @fridginator
    @fridginator 4 года назад

    Første kodetutorialen jeg har sett på youtube som er lagd av en nordmann!

    • @VHDLwhiz
      @VHDLwhiz  4 года назад

      Det er gøy at du la merke til det. Noen må jo være den første. 🙂

  • @marcomoldenhauer7903
    @marcomoldenhauer7903 11 месяцев назад

    [1:59] What does "8'hXX" signify? What is the significance of each character within it: {8,',h,X}? I have already found that 'X' stands for "Forcing Unknown," but what does this truly imply? In my Wave window, I observe the message "UUUUUUUU" in the vector instead of "8'hXX." Why is this the case? Thank you and best regards.

    • @VHDLwhiz
      @VHDLwhiz  11 месяцев назад +1

      'U' means "Uninitialized". It's the default value of a std_logic type signal. Buses are arrays of bits, and when there are meta values (non 0/1) in buses, Questa shows it as X. If you expand the vector, you can see the values of individual bits, as you discovered.
      Read about the nine different values the std_logic type can represent here:
      vhdlwhiz.com/std_logic/

  • @VADroidTS555
    @VADroidTS555 3 года назад +1

    Concise and Excellent video. thank you!

  • @shan9287
    @shan9287 5 лет назад

    Crystal clear explanation. Thank you sir!

  • @JustWatchingVideo56
    @JustWatchingVideo56 6 лет назад +1

    Why is it that "

    • @JustWatchingVideo56
      @JustWatchingVideo56 6 лет назад

      Never mind, I watched the Signal/Variables and Concurrent Statements video. lol

    • @VHDLwhiz
      @VHDLwhiz  6 лет назад +1

      When using variables, the code within a process will behave as any other sequential algorithm. When assigning to a signal in VHDL by using the

    • @charlieriveiv5343
      @charlieriveiv5343 4 года назад

      @@VHDLwhiz Thanks for the explanation. You solved my problems after the first time I watched this video.

  • @En3rGyFaNforEv3r
    @En3rGyFaNforEv3r 3 года назад

    is it possible to assign a decimal value to a vector? or to compare a vector to a decimal? i need the decimal value of a 12bit vector, a number in the range from 0 to 4095, is there a easy way to get this?
    for example, i want to get this: "slv1 > 100 & slv1 < 200"
    thanks, your course is awesome btw

  • @kevinhoublon8630
    @kevinhoublon8630 Год назад

    Hello, great video 😄.
    I'm a beginner and I have a question 😁 :
    Is it possible to program a "EP1C3T144 FPGA Board" with the software you use?
    Thank you in advance for your precious support 😊.
    Best regards 🤗

    • @VHDLwhiz
      @VHDLwhiz  Год назад +1

      In this video and the Basic VHDL Course it belongs to here on RUclips, I only use the ModelSim/Questa VHDL simulator. It's a simulation-only course, and you can't program any board with a simulator.
      To implement a VHDL design on an FPGA and transfer it to the FPGA (program the board) you need an FPGA implementation tool like Xilinv Vivado or Intel's Quartus toolchain.
      I am not sure if the EP1C3T144 Cyclone FPGA device is supported by Intel's newest Quartus Prime software or if you have to install an earlier version of the software like Quartus II. You have to do some research.

  • @TotalKaosEntertainment
    @TotalKaosEntertainment 2 года назад

    When I create waves for the 3 signals that I declared using
    signal Slv1 : std_logic_vector(7 downto 0);
    signal Slv2 : std_logic_vector(7 downto 0) := (others => '0');
    signal Slv3 : std_logic_vector(7 downto 0) := (others => '1');
    The wave values return as UUUUUUUU, 00000000, 11111111 respectively, rather than then "8'...." values. The previous code worked for the signals, so I could use the resolution table to change the value of the waves correctly, so the base code should work. I only have the 1 process with wait for 10 ns; and all the code is the same as in the video. Why would the wave values return that way?

    • @VHDLwhiz
      @VHDLwhiz  2 года назад

      Hello, Mark. I think it's just how ModelSim/Questa is displaying the vector that's causing it to look different.
      The std_logic_vector doesn't have any numeric value in VHDL. It's just a collection of bits, like an array. That's why you're seeing all 1's, all 0's, and all U's (the 'U' value means "uninitialized, it's the default value).
      But we can change how ModelSim displays it. Right-click the signal name in the waveform and hover over the Radix menu item. Select a different representation like hexadecimal, for example.
      The 8 in the 8'hXX just means that it's an 8-bit vector. You can turn it on or off by typing in the ModelSim or Questa terminal:
      radix -showbase
      radix -noshowbase

  • @AhmadAsmndr
    @AhmadAsmndr 2 года назад +1

    Thank you very much, very informative and helpful.

    • @VHDLwhiz
      @VHDLwhiz  2 года назад

      I'm glad you liked the video! You can find the complete free course that the video belongs to here: vhdlwhiz.com/basic-vhdl-tutorials/

  • @shan_singh
    @shan_singh 4 года назад +2

    9:02 what would have happened if you did 'right-1 instead?

    • @VHDLwhiz
      @VHDLwhiz  4 года назад +3

      That would be a run-time error in simulation and a synthesis error in implementation. The Slv6 vector is declared with a bit range of (7 downto 0), and 'right references the 0 index. If you try to index -1, that would be out of the declared range of this vector.

    • @shan_singh
      @shan_singh 4 года назад

      @@VHDLwhiz thanks

  • @sutharikulamanideep3528
    @sutharikulamanideep3528 5 лет назад

    How to design toll tax system using vhdl?
    In this 8 bit register is required,first two bits represents type of vehicle next three bits for RFID and next three bits is the amount in the ewallet,where a certain amount is deducted for specific category of vehicles.please help me solving this😓😓

  • @Phillpoke2
    @Phillpoke2 6 лет назад +1

    Thank you!! Very good class! Keep on going!

  • @AIology2022
    @AIology2022 3 года назад

    Thanks.
    You have not defined variable i. Wondering how this worked!

  • @iloveukraine-subscribe1kgo822
    @iloveukraine-subscribe1kgo822 3 года назад

    Can std_logic_vector can be a signal vector of N bit length?

    • @VHDLwhiz
      @VHDLwhiz  3 года назад

      Yes: std_logic_vector(N - 1 downto 0), given that N is defined as a constant.

  • @hugopontes4989
    @hugopontes4989 4 года назад

    if we do slv6(i)

    • @hugopontes4989
      @hugopontes4989 4 года назад

      I get it now its because of the slv6(0)

  • @sutharikulamanideep3528
    @sutharikulamanideep3528 5 лет назад

    Also please tell me how to convert integer type to bit vector type

  • @kindjupiter
    @kindjupiter 7 лет назад +1

    very useful, merci

  • @quando7162
    @quando7162 2 года назад

    thank you

  • @krolol98
    @krolol98 5 лет назад

    Like si vienes por Mariano