"output int" (signed) in SV is translated into "output" (unsigned) in V

Open
#2,425 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Domain
compilers

Research direction

Start with the top.sv reproduction and run the provided yosys command using the SystemVerilog plugin. Inspect how the output port declaration and signed cast are represented in the generated Verilog. Done means the generated declaration preserves the signed 32-bit output expected for output int o.

Written by the indexing model from the issue text.

Description

Version

Latest release (2024-03-13-d844d8d)
with Yosys 0.36+58 (git sha1 ea7818d31, clang 14.0.6 -fPIC -Os)

Reproduction Steps

SystemVerilog code top.sv:

module top(output int o);
   typedef struct packed {
      logic [9:0] min_v;
   } filter_ctl_t;

   filter_ctl_t [1:0][2:0] a;
   assign a[0][0].min_v = '1;
   assign o = int'(a[0][0].min_v);
endmodule

Command:

yosys -p "plugin -i systemverilog; read_systemverilog top.sv; write_verilog -noattr"

Got the following Verilog:

/* Generated by Yosys 0.36+58 (git sha1 ea7818d31, clang 14.0.6 -fPIC -Os) */

module top(o);
  wire [59:0] a;
  output [31:0] o;
  wire [31:0] o;
  assign a[9:0] = 10'h3ff;
  assign o = { 22'h000000, a[9:0] };
endmodule
Expected Behavior

The output port o is declared as int in SystemVerilog. Therefore, I was expecting something like:

output signed [31:0] o;
Dominant language
Verilog
Stars
237
Forks
30
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from chipsalliance/synlig

All issues in chipsalliance/synlig

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.