Giter Site home page Giter Site logo

Comments (3)

quark17 avatar quark17 commented on July 3, 2024

I don't see a reason why that shouldn't be accepted. Thank you for reporting the issue!

As you saw, one workaround is to replace the vector selection with a variable name. Another is to wrap the selection with asReg or asIfc.

I suspect that fixing this might be as simple as adding the following clause to the flags used for parsing the init and increment parts of the for-loop control triple:

allowSubscriptAssign = (ctxt == ISCSequence)

This is in the function pImperativeForControl (here) which parses the triple. It's used in pImperativeFor, defined above it, that parses the for loop.

The question is whether this would allow something incorrect to parse -- probably not? Note that it would also allow assignment to a range, not just a single index:

Reg#(Bit#(32)) baz <- mkReg('1);
...
    for(baz[7:0] <= 0; baz[7:0] < 10; baz[7:0] <= baz[7:0] + 1) action
      $display("baz[7:0] is %h", baz[7:0]);
      $display("baz is %h", baz);
    endaction

from bsc.

quark17 avatar quark17 commented on July 3, 2024

Having a look at the other fields in the type ImperativeFlags, I see that we might also want to assert allowFieldAssign, to allow code like this:

for(rg_s.f1 <= 0; rg_s.f1 < 10; rg_s.f1 <= rg_s.f1 + 1) action
  $display("rg_s.f1 is %h", rg_s.f1);
endaction

from bsc.

quark17 avatar quark17 commented on July 3, 2024

I've merged a PR that fixes this and adds test cases. Thanks again!

from bsc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.