Author Topic: Help with this verilog video  (Read 1152 times)

0 Members and 1 Guest are viewing this topic.

Offline lawrence11Topic starter

  • Frequent Contributor
  • **
  • Posts: 321
  • Country: ca
Help with this verilog video
« on: August 17, 2019, 06:00:49 pm »


Lecture 2 of 10.

Here in this @ 5:10 , the line that bugs me is WORD [i+3:i], because it has an error box that points to it

Mr Kirk Weedman says its in the same direction? So its good or not, or did he just make a mistake? he never states this is a error but the box is there.
« Last Edit: August 17, 2019, 06:02:29 pm by lawrence11 »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11302
  • Country: us
    • Personal site
Re: Help with this verilog video
« Reply #1 on: August 17, 2019, 06:22:46 pm »
The error is because index is not constant.

This construction would be fine in the 'generate' block. Because in the end it still results in a fixed index.
Alex
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4468
  • Country: dk
Re: Help with this verilog video
« Reply #2 on: August 17, 2019, 06:24:11 pm »
it's right on the slide: indexes must be constants
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7801
  • Country: ca
Re: Help with this verilog video
« Reply #3 on: August 20, 2019, 03:38:38 am »
That one got me thinking, didn't I successfully use variables in my indexes in the past?

I just checked, and it was not a normal variable, but a 'Parameter'.

If you want parameters for your Verilog module, say a configuration for the address size for a block of memory, the assigned label you use for the parameter is allowed in your indexes.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3743
  • Country: us
Re: Help with this verilog video
« Reply #4 on: August 20, 2019, 04:03:30 am »
Yes, parameter and `define values are constant so they can be used freely in index expressions.

You can use a single variable expression index with no problem. Only for ranges are constant expressions required.  Note that you can also do a variable range select using the -: syntax:  myreg[8*i + 7 -: 8] will select bytes out of a multi-byte register.  The starting index can be variable only the offset has to be constant.
 
The following users thanked this post: BrianHG

Offline kfnight

  • Regular Contributor
  • *
  • Posts: 71
Re: Help with this verilog video
« Reply #5 on: August 22, 2019, 03:02:15 pm »
The desire for non-constant width part selects has been on the SV ballot for a while now. See https://accellera.mantishub.io/view.php?id=2684
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14590
  • Country: fr
Re: Help with this verilog video
« Reply #6 on: August 22, 2019, 03:27:53 pm »
Note that it's been available in VHDL for ages. ::)
 
The following users thanked this post: Bassman59


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf