Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property type considerations #12

Closed
gatecat opened this issue Feb 24, 2021 · 6 comments · Fixed by #19
Closed

Property type considerations #12

gatecat opened this issue Feb 24, 2021 · 6 comments · Fixed by #19

Comments

@gatecat
Copy link
Collaborator

gatecat commented Feb 24, 2021

At the moment, it appears like there are three allowed kinds of properties:

  • strings
  • 32-bit integers
  • booleans

The second two of these look reasonable. However, I think it would be prudent to distinguish between a string that is actually a string value (something like https://github.com/YosysHQ/yosys/blob/master/techlibs/nexus/cells_sim.v#L95, Lattice use these a lot) and a string value that is actually containing a bitvector (e.g. encoded as a Verilog constant).

Without that difference being stored; I don't think it will be possible to reliably go back to a Verilog netlist from an interchange netlist - the original value could have either been the bitvector 16'h1234; or actually a string "16'h1234" (equivalent to a much longer bitvector containing the ASCII values of those characters).

Yosys originally made a similar design mistake in its JSON format and now we have to live with a somewhat horrible escaping scheme involving postfixed spaces for disambiguation: https://github.com/YosysHQ/yosys/blob/master/backends/json/json.cc#L403-L405

@litghost
Copy link
Contributor

litghost commented Feb 24, 2021

String properties require quotes if they are quoted strings. My processing of Yosys JSON might be messing this up and need to be fixed. So for example:

EX #(.PROP1("TRUE"), .PROP2(16'h1234)) ex();

Should actually be encoded as:

{
  .key = "PROP1"
  .textValue = "\"TRUE\""
},
{
  .key = "PROP2"
  .textValue = "16'h1234"
}

That make sense?

@gatecat
Copy link
Collaborator Author

gatecat commented Feb 24, 2021

Yes, that makes sense. I hadn't actually checked that the JSON frontend was doing.

I'm still not sure if encoding two fundamentally different types of property into a string is the best option with access to all the power of a proper schema; storing bit vector parameters as a vector of bytes/32-bit words/etc would seem easier to work with to me.

@litghost
Copy link
Contributor

storing bit vector parameters as a vector of bytes/32-bit words/etc would seem easier to work with to me.

This immediately runs into problems with LUTs (64-bits) and BRAM init strings (256-bits). As a future extension, we could add a varint property field, but I think operating on verilog encoded strings is probably the right short-term answer.

@gatecat
Copy link
Collaborator Author

gatecat commented Feb 24, 2021

This immediately runs into problems with LUTs (64-bits) and BRAM init strings (256-bits).

Yes, that's why I suggested a vector of bytes/words

I think operating on verilog encoded strings is probably the right short-term answer.

Don't have a massive problem with this provided that the semantics are well defined so we don't end up in a situation where different tools have slightly different ideas of what Verilog encoded string means (ime these kinds of differences tend to cause big problems with EDIF interoperability).

@litghost
Copy link
Contributor

litghost commented Feb 24, 2021

I think operating on verilog encoded strings is probably the right short-term answer.

Don't have a massive problem with this provided that the semantics are well defined so we don't end up in a situation where different tools have slightly different ideas of what Verilog encoded string means (ime these kinds of differences tend to cause big problems with EDIF interoperability).

So the initial solution here is to require that user supplied primitive cell parameters follow the format of the default parameters of the library definition (in the device database)! So if the device database primitive cell default is 64'b0, then it is required that the parameter use verilog binary bit strings. If the default is 256'h0, then it is required that use verilog hex bit strings. This is something that I've been planning on writing up in a docs folder, but wanted to get a basic non-timing driven P&R up and running before doing so.

One way to handle the Nexus use of c-style hex constants (e.g. 0x0) is maybe to provide a format library in the documentation of possible ways to format bitstrings.

@litghost
Copy link
Contributor

I think operating on verilog encoded strings is probably the right short-term answer.

Don't have a massive problem with this provided that the semantics are well defined so we don't end up in a situation where different tools have slightly different ideas of what Verilog encoded string means (ime these kinds of differences tend to cause big problems with EDIF interoperability).

I've tried to address this in #19, take a look with that in mind.

FPGA interchange bootstrapping automation moved this from To Do to Done Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants