aboutsummaryrefslogtreecommitdiffstats
path: root/bugs/yosys_7.md
blob: 9e35436f96fd83e84119cc17b7d3dbf92b011222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Initial value of register ignored during synthesis

[ Fixed in [`33738c1`](https://github.com/YosysHQ/yosys/commit/33738c174560c718723b6c860af002d1a8a91cea) | [Issue 997](https://github.com/YosysHQ/yosys/issues/997) ]

## Affected versions

- Yosys 0.8+450

## Description 

### Steps to reproduce the issue

Consider the following verilog code.

```verilog
module top (y, clk, wire4);
   output wire [1:0] y;
   input             clk;
   input signed      wire4;
   reg [1:0]  reg10 = 0;
   always @(posedge clk) begin
      reg10 <= wire4;
   end
   assign y = reg10;
endmodule
```

When synthesised using

```
yosys -p 'read -formal rtl.v; synth; write_verilog -noattr syn_yosys.v'
```

and Yosys version

```
Generated by Yosys 0.8+450 (git sha1 09467bb9, clang 8.0.0 -fPIC -Os)
```

the initial value of the register seems to be ignored. Therefore, during simulation, the bit is undefined at first, and only behaves correctly after the first clock cycle.

This does not seem to happen with the official 0.8 release of Yosys. In that release, the expected behavior is generated.

### Expected behavior

It is expected that the register is initialised with 0. This was generated using the 0.8 release of Yosys.

```verilog
/* Generated by Yosys 0.8 (git sha1 b003446, clang 7.0.1 -march=x86-64 -mtune=generic -O2 -fno-plt -fPIC -Os) */

module top_1(y, clk, wire4);
  input clk;
  wire [1:0] reg10;
  input wire4;
  output [1:0] y;
  reg \reg10_reg[0]  = 1'h0; // <-----
  always @(posedge clk)
      \reg10_reg[0]  <= wire4;
  assign reg10[0] = \reg10_reg[0] ;
  assign reg10[1] = reg10[0];
  assign y = { reg10[0], reg10[0] };
endmodule
```

### Actual behavior

However, it actually gets initialised with `1'hx`.

```verilog
/* Generated by Yosys 0.8+450 (git sha1 09467bb9, clang 8.0.0 -fPIC -Os) */

module top_1(y, clk, wire4);
  input clk;
  wire [1:0] reg10;
  input wire4;
  output [1:0] y;
  reg \reg10_reg[0]  = 1'hx; // <-----
  always @(posedge clk)
      \reg10_reg[0]  <= wire4;
  assign reg10[0] = \reg10_reg[0] ;
  assign reg10[1] = reg10[0];
  assign y = { reg10[0], reg10[0] };
endmodule
```