GithubHelp home page GithubHelp logo

case statement about veryl HOT 16 CLOSED

dalance avatar dalance commented on June 8, 2024
case statement

from veryl.

Comments (16)

dalance avatar dalance commented on June 8, 2024 1

I want to consider it, but I think the priority is low.

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024 1

Does Expression in case item have no problem for synthesis?

Yes. In fact, our RTL includes this kind of code.

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

Do you plan to add case inside feature?

from veryl.

dalance avatar dalance commented on June 8, 2024

Instead of default, How about Rust style default?

always_ff (clk) {
    case x {
        0: a = 1;
        1: a = 2;
        2: {
            a = 3;
            b = 4;
        }
        _: a = 4;
    }
}

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

In SysemVerilog, ? and * are used as symbols which mean wildcard. For exmaple: wildcard operator ==?, wildcard index type int a[*].
How about using ? or * instead of _?

from veryl.

dalance avatar dalance commented on June 8, 2024

I thought default may be a little long. but there is not another problem.
So I'll use default to follow SystemVerilog.

Do you have any other reason to change to ? or *?

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

I simply proposed ? and * as an alternative of _ character. So I have no special reason.

from veryl.

dalance avatar dalance commented on June 8, 2024

OK. I'll use default at this time.

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

How about introducing case expression less case statement.
Example:

case {
  foo:     a = 1;
  bar:     a = 2;
  default: a = 3;
}

Equivalent code:

case 1 {
  foo:     a = 1;
  bar:     a = 2;
  default: a = 3;
}

This idea is originally from Ruby's case expression.

image

from veryl.

dalance avatar dalance commented on June 8, 2024

It looks good. Does Expression in case item have no problem for synthesis?

from veryl.

dalance avatar dalance commented on June 8, 2024

Expression less case seems to be difficult to parse by LL(k).
This is because

case {  <- Is this `{` case body's start or expression with concatenation?
    foo: a = 1;
}

To avoid this, chanigning case keyword for expression less case is required.

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

I don't care if expression less case feature is not introduced because I just put 1 as a case expression.

from veryl.

dalance avatar dalance commented on June 8, 2024

I feel case 1 may be bit strange, but I have no idea about alternative keyword.
So I'll keep the current implementation until new idea.

from veryl.

taichi-ishitani avatar taichi-ishitani commented on June 8, 2024

Introduce other keyword insead of case? For example, switch, branch..?

from veryl.

dalance avatar dalance commented on June 8, 2024

switch seems to be good.

from veryl.

dalance avatar dalance commented on June 8, 2024

The idea of switch statement moved to #643.

from veryl.

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.