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

It is not possible to format the code shown below #2238

Open
17Reset opened this issue Aug 19, 2024 · 4 comments
Open

It is not possible to format the code shown below #2238

17Reset opened this issue Aug 19, 2024 · 4 comments
Labels
formatter Verilog code formatter issues

Comments

@17Reset
Copy link

17Reset commented Aug 19, 2024

pcie5_cfgchk.zip

@17Reset 17Reset added the formatter Verilog code formatter issues label Aug 19, 2024
@matlupi
Copy link

matlupi commented Aug 27, 2024

@17Reset please provide a minimal example in the issue, following the provided template.
A zip archive is not the best in terms of security, so I doubt you'll find someone opening it.

@17Reset
Copy link
Author

17Reset commented Aug 29, 2024

`timescale 1 ns / 1 ps
module
pcie5_eqif

(

input
wire
pclk
,

input
wire
prstn
,

input
wire
psrst
,

input
wire
[`PCIE_TESTIN_SIZE-1:0]
test_in
,

input
wire
equ_reset
,

input
wire
chgspeed_done
,

input
wire
[`EQRESP_SIZE-1:0]
eq_resp
,

output
wire
[`EQCMD_SIZE-1:0]
eq_cmd
,

input
wire
req_start
,

input
wire
[2:0]
req_cmd
,

output
reg
[2:0]
req_resp
,

output
wire
req_done
,

input
wire
[2:0]
localrxpresethint
,

input
wire
[3:0]
localtxpresetnew
,

input
wire
[17:0]
localcoeffnew
,

output
reg
[3:0]
localtxpresetcur
,

output
reg
[17:0]
localcoeffcur
,

output
reg
[5:0]
localfs
,

output
reg
[5:0]
locallf
,

output
reg
localcoeffrej
,

output
reg
localusepreset
,

input
wire
[17:0]
remotecoeffcur
,

input
wire
[5:0]
remotefs
,

input
wire
[5:0]
remotelf
,

output
reg
[3:0]
remotepresetnew
,

output
reg
[17:0]
remotecoeffnew
,

output
reg
remoteusepreset
,

output
wire
[127:0]
test_out_eqif

)

;

localparam
[1:0]
RQ_IDLE
=
2'd0
,

RQ_CMD
=
2'd1
,

RQ_RESP
=
2'd2
;

reg
[1:0]
lIl0
;

wire
[2:0]
IIl0
;

assign
IIl0
=
eq_resp
[`EQRESP_RESPONSE+:3]
;

always
@
(
negedge
prstn
or
posedge
pclk
)

begin:
req_ctrl
if

(
prstn

==

1'b0
)

begin
lIl0

<=

RQ_IDLE
;

req_resp

<=

`RESP_IDLE
;

localcoeffcur

<=

18'b0
;

localfs

<=

6'b0
;

locallf

<=

6'b0
;

localtxpresetcur

<=

4'h0
;

localcoeffrej

<=

1'b0
;

localusepreset

<=

1'b0
;

remotepresetnew

<=

4'h0
;

remotecoeffnew

<=

18'b0
;

remoteusepreset

<=

1'b0
;

end
else
if

(
psrst

==

1'b1
)

begin
lIl0

<=

RQ_IDLE
;

req_resp

<=

`RESP_IDLE
;

localcoeffcur

<=

18'b0
;

localfs

<=

6'b0
;

locallf

<=

6'b0
;

localtxpresetcur

<=

4'h0
;

localcoeffrej

<=

1'b0
;

localusepreset

<=

1'b0
;

remotepresetnew

<=

4'h0
;

remotecoeffnew

<=

18'b0
;

remoteusepreset

<=

1'b0
;

end
else
begin
case

(
lIl0
)

RQ_CMD
:
if

(
req_cmd
==
`CMD_SETINITPRESET


||


req_cmd
==
`CMD_REQLOCALPRESET


||


req_cmd
==
`CMD_REQLOCALCOEFF


||


req_cmd
==
`CMD_PERFORMRXEVAL
)

lIl0

<=

RQ_RESP
;

else
lIl0

<=

RQ_IDLE
;

RQ_RESP
:
if

(
IIl0
!=
`RESP_IDLE
)

lIl0

<=

RQ_IDLE
;

default
:
if

(
req_start
==
1'b1
)

lIl0

<=

RQ_CMD
;

endcase
// synopsys translate_off
// synthesis translate_off
if

(
lIl0
!=
RQ_RESP


&&


IIl0
!=
`RESP_IDLE
)

$display

(

"%t : %m : ERROR : EQ RESPONSE RECEIVED BUT NO RESPONSE IS EXPECTED"
,
$time
)

;

if

(
lIl0
==
RQ_RESP


&&


IIl0
!=
`RESP_IDLE


&&



(


(
req_cmd
==
`CMD_SETINITPRESET


&&


IIl0
!=
`RESP_LOCALCOEFFMAPPING
)



||



(
req_cmd
==
`CMD_REQLOCALPRESET


&&


IIl0
!=
`RESP_LOCALCOEFFMAPPING


&&


IIl0
!=
`RESP_LOCALCOEFFREJECT
)



||



(
req_cmd
==
`CMD_REQLOCALCOEFF


&&


IIl0
!=
`RESP_LOCALCOEFFACCEPT


&&


IIl0
!=
`RESP_LOCALCOEFFREJECT
)



||



(
req_cmd
==
`CMD_PERFORMRXEVAL


&&


IIl0
!=
`RESP_EQUFAIL


&&


IIl0
!=
`RESP_EQUSUCCESS


&&


IIl0
!=
`RESP_NEWREMOTEPRESET


&&


IIl0
!=
`RESP_NEWREMOTECOEFF
)

)

)

$display

(

"%t : %m : ERROR : INCORRECT RESPONSE RECEIVED (%0d)"
,
$time
,
eq_resp
[`EQRESP_RESPONSE+:3]
)

;

// synthesis translate_on
// synopsys translate_on
if

(
lIl0
==
RQ_RESP


&&


IIl0
!=
`RESP_IDLE
)

req_resp

<=

IIl0
;

if

(
chgspeed_done
==
1'b0
)

localcoeffcur

<=

localcoeffnew
;

else
if

(
lIl0
==
RQ_RESP


&&


IIl0
==
`RESP_LOCALCOEFFMAPPING
)

begin
localcoeffcur

<=

eq_resp
[`EQRESP_LOCALCOEFF_CUR
+:
18]
;

localfs

<=

eq_resp
[`EQRESP_LOCALFS
+:
6]
;

locallf

<=

eq_resp
[`EQRESP_LOCALLF
+:
6]
;

end
else
if

(
lIl0
==
RQ_RESP


&&



(
IIl0
==
`RESP_LOCALCOEFFACCEPT


||



(
IIl0
==
`RESP_LOCALCOEFFREJECT


&&


req_cmd
!=
`CMD_REQLOCALPRESET
)

)

)

localcoeffcur

<=

localcoeffnew
;

if

(
equ_reset


||



(
lIl0
==
RQ_CMD


&&



(
req_cmd
==
`CMD_REMOTECOEFF


||


req_cmd
==
`CMD_REMOTEREQREJECT


||


req_cmd
==
`CMD_REMOTEREQFAIL
)

)

)

begin
remotecoeffnew

<=

remotecoeffcur
;

end
else
if

(
lIl0
==
RQ_RESP
)

begin
if

(
IIl0
==
`RESP_NEWREMOTECOEFF
)

remotecoeffnew

<=

eq_resp
[`EQRESP_REMOTECOEFF_NEW
+:
18]
;

if

(
IIl0
==
`RESP_NEWREMOTEPRESET
)

remotepresetnew

<=

eq_resp
[`EQRESP_REMOTEPRESET_NEW
+:
4]
;

end
if

(
lIl0
==
RQ_RESP


&&


IIl0
!=
`RESP_IDLE
)

begin
if

(
IIl0
==
`RESP_LOCALCOEFFREJECT
)

localcoeffrej

<=

1'b1
;

else
localcoeffrej

<=

1'b0
;

if

(
IIl0
==
`RESP_LOCALCOEFFMAPPING


||



(
IIl0
==
`RESP_LOCALCOEFFREJECT


&&


req_cmd
!=
`CMD_REQLOCALCOEFF
)

)

localtxpresetcur

<=

localtxpresetnew
;

if

(
IIl0
==
`RESP_LOCALCOEFFMAPPING


||



(
IIl0
==
`RESP_LOCALCOEFFREJECT


&&


req_cmd
!=
`CMD_REQLOCALCOEFF
)

)

localusepreset

<=

1'b1
;

else
if

(
IIl0
==
`RESP_LOCALCOEFFACCEPT


||


IIl0
==
`RESP_LOCALCOEFFREJECT
)

localusepreset

<=

1'b0
;

end
if

(
equ_reset
)

remoteusepreset

<=

1'b0
;

else
if

(
lIl0
==
RQ_RESP


&&


IIl0
!=
`RESP_IDLE
)

begin
if

(
req_cmd
==
`CMD_REMOTEREQREJECT


||


req_cmd
==
`CMD_REMOTEREQFAIL
)

remoteusepreset

<=

1'b0
;

else
if

(
IIl0
==
`RESP_NEWREMOTEPRESET
)

remoteusepreset

<=

1'b1
;

else
if

(
IIl0
==
`RESP_NEWREMOTECOEFF
)

remoteusepreset

<=

1'b0
;

end
end
end
assign
eq_cmd
=

{

localrxpresethint
,

localtxpresetnew
,

localcoeffnew
,

remotelf
,

remotefs
,

remotecoeffcur
,


(
lIl0
==
RQ_CMD
)

?
req_cmd
:
`CMD_IDLE

}

;

assign
req_done
=

(
lIl0
==
RQ_IDLE


&&


req_start
==
1'b0
)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[17:0]
=
remotecoeffnew

;

assign
test_out_eqif
[21:18]
=
remotepresetnew

;

assign
test_out_eqif
[22]
=
remoteusepreset

;

assign
test_out_eqif
[40:23]
=
localcoeffnew

;

assign
test_out_eqif
[44:41]
=
localtxpresetnew

;

assign
test_out_eqif
[45]
=
localusepreset

;

assign
test_out_eqif
[48:46]
=
localrxpresethint

;

assign
test_out_eqif
[52:49]
=
localtxpresetcur

;

assign
test_out_eqif
[70:53]
=
localcoeffcur

;

assign
test_out_eqif
[76:71]
=
localfs

;

assign
test_out_eqif
[82:77]
=
locallf

;


assign
test_out_eqif
[100:83]
=
remotecoeffcur

;

assign
test_out_eqif
[106:101]
=
remotefs

;

assign
test_out_eqif
[112:107]
=
remotelf

;

assign
test_out_eqif
[113]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_SETINITPRESET

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[114]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_REQLOCALPRESET

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[115]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_REQLOCALCOEFF

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[116]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_REMOTECOEFF

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[117]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_PERFORMRXEVAL

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[118]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_REMOTEREQREJECT

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[119]
=

(
eq_cmd
[`EQCMD_COMMAND
+:
3]

==

`CMD_REMOTEREQFAIL

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[120]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_LOCALCOEFFMAPPING

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[121]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_LOCALCOEFFACCEPT

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[122]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_LOCALCOEFFREJECT

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[123]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_NEWREMOTEPRESET

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[124]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_NEWREMOTECOEFF

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[125]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_EQUSUCCESS

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[126]
=

(
eq_resp
[`EQRESP_RESPONSE
+:
3]

==

`RESP_EQUFAIL

)

?
1'b1
:
1'b0
;

assign
test_out_eqif
[127]
=
1'b0
;

endmodule

@17Reset
Copy link
Author

17Reset commented Aug 29, 2024

Run the above code with the command verible-verilog-format.exe demo1.v and the console output,however the above is the result of an obfuscate from another programme:

demo1.v: Formatted output is lexically different from the input.    Please file a bug.  Details:
Mismatched token enums.  got: (MacroIdItem) (#298: "`RESP_IDLE") vs. (MacroIdentifier) (#296: "`RESP_IDLE")
First mismatched token [295]: (MacroIdItem) (#298: "`RESP_IDLE") vs. (MacroIdentifier) (#296: "`RESP_IDLE")
; problematic formatter output is

@17Reset
Copy link
Author

17Reset commented Sep 2, 2024

There is also the problem shown below, which is the result of a code sample and format:

assign test_out_eqif[113] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_SETINITPRESET) ? 1'b1 : 1'b0;
assign test_out_eqif [114] =  ( eq_cmd [`EQCMD_COMMAND +: 3]  ==  `CMD_REQLOCALPRESET  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif[115] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REQLOCALCOEFF) ? 1'b1 : 1'b0;
assign test_out_eqif[116] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REMOTECOEFF) ? 1'b1 : 1'b0;
assign test_out_eqif[117] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_PERFORMRXEVAL) ? 1'b1 : 1'b0;
assign test_out_eqif [118] =  ( eq_cmd [`EQCMD_COMMAND +: 3]  ==  `CMD_REMOTEREQREJECT  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif[119] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REMOTEREQFAIL) ? 1'b1 : 1'b0;
assign test_out_eqif [120] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFMAPPING  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [121] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFACCEPT  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [122] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFREJECT  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [123] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_NEWREMOTEPRESET  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [124] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_NEWREMOTECOEFF  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [125] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_EQUSUCCESS  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif[126] = (eq_resp[`EQRESP_RESPONSE+:3] == `RESP_EQUFAIL) ? 1'b1 : 1'b0;
assign test_out_eqif[127] = 1'b0;
assign test_out_eqif[113] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_SETINITPRESET) ? 1'b1 : 1'b0;
assign test_out_eqif[114] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REQLOCALPRESET) ? 1'b1 : 1'b0;
assign test_out_eqif[115] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REQLOCALCOEFF) ? 1'b1 : 1'b0;
assign test_out_eqif[116] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REMOTECOEFF) ? 1'b1 : 1'b0;
assign test_out_eqif[117] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_PERFORMRXEVAL) ? 1'b1 : 1'b0;
assign test_out_eqif[118] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REMOTEREQREJECT) ? 1'b1 : 1'b0;
assign test_out_eqif[119] = (eq_cmd[`EQCMD_COMMAND+:3] == `CMD_REMOTEREQFAIL) ? 1'b1 : 1'b0;
assign test_out_eqif [120] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFMAPPING  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [121] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFACCEPT  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif [122] =  ( eq_resp [`EQRESP_RESPONSE +: 3]  ==  `RESP_LOCALCOEFFREJECT  )  ? 1'b1 : 1'b0 ;
assign test_out_eqif[123] = (eq_resp[`EQRESP_RESPONSE+:3] == `RESP_NEWREMOTEPRESET) ? 1'b1 : 1'b0;
assign test_out_eqif[124] = (eq_resp[`EQRESP_RESPONSE+:3] == `RESP_NEWREMOTECOEFF) ? 1'b1 : 1'b0;
assign test_out_eqif[125] = (eq_resp[`EQRESP_RESPONSE+:3] == `RESP_EQUSUCCESS) ? 1'b1 : 1'b0;
assign test_out_eqif[126] = (eq_resp[`EQRESP_RESPONSE+:3] == `RESP_EQUFAIL) ? 1'b1 : 1'b0;
assign test_out_eqif[127] = 1'b0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Verilog code formatter issues
Projects
None yet
Development

No branches or pull requests

2 participants