I'm currently investigating how to add support for 1'bZ
to be able to use the constant in verilog. After creating a pull request for tilk/yosys2digitaljs#15 I figured out, that there is an issue how constants are parsed. Constant
uses Vector3vl.fromBin(constant, bits)
to convert the data provided. The function supports only 0
, 1
and x
, but there is no parameter check performed. The library implements such a check in its constructor, but not in the fromBin
function used.
Error Behavior
If any unsupported character is given (e.g. z
), the value defaults to 0
.
Correct Behavior
The value should default to x
or raise an error if another value than 0
, 1
and x
is provided.
Example:
Verilog:
// high impedance state
module sourceZ(
output out
);
assign out = 1'bZ;
endmodule
Json:
{
"subcircuits": {},
"devices": {
"dev0": {
"type": "Lamp",
"net": "out",
"order": 0,
"bits": 1,
"label": "out"
},
"dev1": {
"type": "Constant",
"constant": "z"
}
},
"connectors": [
{
"to": {
"id": "dev0",
"port": "in"
},
"from": {
"id": "dev1",
"port": "out"
},
"name": "out",
"source_positions": [
{
"name": "tests/z.sv",
"from": {
"line": 3
}
}
]
}
]
}
Simulation: