Giter Club home page Giter Club logo

Comments (4)

typingArtist avatar typingArtist commented on May 18, 2024

I’d suggest to enter the code like the following. It should be functionally equivalent but points out better the intent.

(* parallel case *)
case(1) // synopsys parallel_case
    ((pc_state & `PcState_defautEncoding_Idle) == `PcState_defaultEncoding_Idle): begin

Also this would allow the code to be used for other *hot encodings as well, e.g. two-hot.

However, the parallel_case tags should only be applied if really all cases have been decoded. Is SpinalHDL already capable of detecting this property in a water-proof way?

from spinalhdl.

Dolu1990 avatar Dolu1990 commented on May 18, 2024

@typingArtist
So you have access to the whole AST durring the Verilog generation.
There is where the switch cases statements is emited :

The is isPure is calculated to be true if only literals are used in the SpinalHDL 'is' statements, as Verilog doesn't support case statements with non literal cases.

So the generation of switch statement with only literal stuff is there

b ++= s"${tab}case(${emitExpression(switchStatement.value)})\n"

@typingArtist and @tomverbeure
What happend if you throw some

(* parallel case *)
case(1) // synopsys parallel_case
    ((pc_state & `PcState_defautEncoding_Idle) == `PcState_defaultEncoding_Idle): begin

code into non synposys / parrallel cases capable tools ? is that still legal verilog ?

from spinalhdl.

tomverbeure avatar tomverbeure commented on May 18, 2024

However, the parallel_case tags should only be applied if really all cases have been decoded.

I believe that's only true for full_case, but not for parallel_case. My rule of thumb is to never ever use full_case. It's too dangerous. For parallel_case, the simply rule of them is the one listed above: if you know for sure that the input is one-hot, then you're good, even if you don't cover all the options.

code into non synposys / parrallel cases capable tools ? is that still legal verilog ?

Tools that don't implement the parallel case will implement a priority encoder instead of a flat encoder. But it will functionally still be totally fine. It's legal Verilog.

Tom

from spinalhdl.

tomverbeure avatar tomverbeure commented on May 18, 2024

@typingArtist
Your patch is great! As expected, the clock speed of my design went up, and number of gates went down.

I suggest 2 fixed:

  • // synopsys parallel_case -> // synthesis parallel_case

    I'm old school, but even if some tools still don't support (* parallel_case *), they all support synthesis instead of synopsys.

  • Either keep the (* parallel_case *) attribute, or provide an option to use one or the other or both.

Tom

from spinalhdl.

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.