Giter VIP home page Giter VIP logo

Comments (4)

udif avatar udif commented on July 18, 2024

AFAIK, zero sized ports are not legal verilog or systemverilog code.
The typical [WIDTH-1:0] construct yields an error when WIDTH==0 on any tool I'm aware of.

from yosys.

povik avatar povik commented on July 18, 2024

AFAIK, zero sized ports are not legal verilog or systemverilog code. The typical [WIDTH-1:0] construct yields an error when WIDTH==0 on any tool I'm aware of.

Now that I think of it, strictly speaking shouldn't the Verilog construct be interpreted to declare a two-bit vector with reversed indexing when WIDTH=0? I think that's how Yosys does interpret it, but if I have a CXXRTL blackbox with explicit (* cxxrtl_width = "WIDTH" *) annotation on the port, then CXXRTL unsurprisingly takes the WIDTH=0 case to imply a zero-sized port. That's the behavior I want but if this wouldn't work outside of CXXRTL the same way then I guess the value in supporting this is dubious. That is, there's no companion synthesis flow where I would supply a Verilog implementation of what's otherwise the CXXRTL-blackboxed module, and the specialization would match what happens on the CXXRTL side.

I will close this for the time being.

from yosys.

udif avatar udif commented on July 18, 2024

Now that I think of it, strictly speaking shouldn't the Verilog construct be interpreted to declare a two-bit vector with reversed indexing when WIDTH=0?

It seems you were right!

Consider the following test:

module x (
  input [6:5]w1,
  input [5:6]w2,
  input [-5:-6]w3,
  input [-6:-5]w4,
  input [0:-1]w5,
  input [-1:0]w6
);
  generate
    $info("w1=%1d w2=%1d w3=%1d w4=%1d w5=%1d w6=%1d", $bits(w1), $bits(w2), $bits(w3), $bits(w4), $bits(w5), $bits(w6));
  endgenerate
endmodule

I've tested 4 tools:
slang, Verilator and 2 commercial tools, and they all produce w1=2 w2=2 w3=2 w4=2 w5=2 w6=2 .

from yosys.

whitequark avatar whitequark commented on July 18, 2024

but if I have a CXXRTL blackbox with explicit (* cxxrtl_width = "WIDTH" *) annotation on the port, then CXXRTL unsurprisingly takes the WIDTH=0 case to imply a zero-sized port.

We can special-case that to just remove the port entirely, maybe?

from yosys.

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.