DSLX Output Verilog: Inefficient Declaration of Active Signals
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
From example 9 of [Learning-Notebook](https://colab.corp.google.com/drive/1yr5csc5FWX-qdVeQmqkvFpB0u_c2fFEI?resourcekey=0-m-_nXR58_tvK_kycuHXRAg#scrollTo=XPW-7SlZFD8g) :
```
wire p1_all_active_states_valid;
assign p1_all_active_states_valid = 1'h1;
assign p1_stage_valid = p1_all_active_states_valid & p0_valid;
```
We can see that the active signal p1_all_active_states_valid is declared which doesn't change it's state anywhere else in the design moreover, `assign p1_stage_valid = p1_all_active_states_valid & p0_valid` is equivalent to `assign p1_stage_valid = p0_valid`.
If we see the code furthermore:
```
assign p1_all_active_inputs_valid = 1'h1;
assign __user_module__output_valid_buf = p1_all_active_inputs_valid & p1_stage_valid & 1'h1;
```
If we evaluate the the second expression `assign __user_module__output_valid_buf = p1_all_active_inputs_valid & p1_stage_valid & 1'h1;` it is equivalent to `assign __user_module__output_valid_buf = p0_valid;`
Thus, instead of assigning 4 wires( `p1_all_active_states_valid`, `p1_stage_valid`, `__user_module__output_valid_buf`, `p1_all_active_inputs_valid`) we could do the same work in just one wire `p0_valid`
Some wires are sometimes useful for readability but in the example 9 of [Learning-Notebook](https://colab.corp.google.com/drive/1yr5csc5FWX-qdVeQmqkvFpB0u_c2fFEI?resourcekey=0-m-_nXR58_tvK_kycuHXRAg#scrollTo=XPW-7SlZFD8g) there are 38 assign statements and 48 wires for a small muladd FSM which makes code unreadable.
Contributor guide
Assessment
This issue has not been assessed yet.