From df7b3aee6d676b5858c8a8dad8a39fc1ed010b69 Mon Sep 17 00:00:00 2001 From: Alex-create-beep <2965312221@qq.com> Date: Fri, 18 Sep 2026 16:02:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(rtl):=20=E6=B8=85=E9=99=A4=E8=A2=AB?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=8F=8D=E5=A4=8D=E6=B3=A8=E5=85=A5=E5=88=B0?= =?UTF-8?q?=20.v=20=E6=9C=AB=E5=B0=BE=E7=9A=84=20README=20=E6=AE=8B?= =?UTF-8?q?=E8=A1=8C;=20=E6=96=B0=E5=A2=9E=20RTL=20=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=87=AA=E6=A3=80=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cpu21_pointer.v / cpu21_ps2_mouse.v / cpu21_vga.v 末尾多出一行 README 正文 (Tcl ...), 会导致 Vivado: ERROR: [Synth 8-2715] non-printable character 0xe4 - 新增 pipelined-cpu/tools/check_rtl_text.ps1: 综合前秒级自检, 检出代码位置上 的非 ASCII 文本/粘贴进来的正文行 --- pipelined-cpu/srcs/board/cpu21_board_top.v | 2 +- pipelined-cpu/srcs/rtl/cpu21_pointer.v | 1 - pipelined-cpu/srcs/rtl/cpu21_ps2_mouse.v | 1 - pipelined-cpu/srcs/rtl/cpu21_vga.v | 1 - pipelined-cpu/tools/check_rtl_text.ps1 | 77 ++++++++++++++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 pipelined-cpu/tools/check_rtl_text.ps1 diff --git a/pipelined-cpu/srcs/board/cpu21_board_top.v b/pipelined-cpu/srcs/board/cpu21_board_top.v index 74e3eec..dde1bb8 100644 --- a/pipelined-cpu/srcs/board/cpu21_board_top.v +++ b/pipelined-cpu/srcs/board/cpu21_board_top.v @@ -345,7 +345,7 @@ generate .ps2_data_i (ps2_data), .ps2_data_oe_o(), Tcl 一键重建 - .ev_valid_o (ev_valid), +valid_o (ev_valid), .ev_dx_o (ev_dx), .ev_dy_o (ev_dy), .ev_btn_o (ev_btn), diff --git a/pipelined-cpu/srcs/rtl/cpu21_pointer.v b/pipelined-cpu/srcs/rtl/cpu21_pointer.v index c431c64..969e41c 100644 --- a/pipelined-cpu/srcs/rtl/cpu21_pointer.v +++ b/pipelined-cpu/srcs/rtl/cpu21_pointer.v @@ -103,4 +103,3 @@ module cpu21_pointer #( endmodule `default_nettype wire -Tcl 一键重建 diff --git a/pipelined-cpu/srcs/rtl/cpu21_ps2_mouse.v b/pipelined-cpu/srcs/rtl/cpu21_ps2_mouse.v index 0fce540..4e8e788 100644 --- a/pipelined-cpu/srcs/rtl/cpu21_ps2_mouse.v +++ b/pipelined-cpu/srcs/rtl/cpu21_ps2_mouse.v @@ -142,4 +142,3 @@ module cpu21_ps2_mouse ( endmodule `default_nettype wire -Tcl 一键重建 diff --git a/pipelined-cpu/srcs/rtl/cpu21_vga.v b/pipelined-cpu/srcs/rtl/cpu21_vga.v index 9a9355b..0ea3bb5 100644 --- a/pipelined-cpu/srcs/rtl/cpu21_vga.v +++ b/pipelined-cpu/srcs/rtl/cpu21_vga.v @@ -239,4 +239,3 @@ module cpu21_vga #( endmodule `default_nettype wire -Tcl 一键重建 diff --git a/pipelined-cpu/tools/check_rtl_text.ps1 b/pipelined-cpu/tools/check_rtl_text.ps1 new file mode 100644 index 0000000..49d33e4 --- /dev/null +++ b/pipelined-cpu/tools/check_rtl_text.ps1 @@ -0,0 +1,77 @@ +# ============================================================================= +# check_rtl_text.ps1 —— detect stray non-Verilog text in the RTL sources. +# +# WHY: this project's .v files were twice corrupted by a text tool that inserted a +# line of README prose into them ("Tcl ..." / a Chinese sentence), which made +# Vivado fail with +# ERROR: [Synth 8-2715] syntax error near "..." 'non-printable character 0xe4' +# and produced a cascade of bogus errors in the included ROM .vh. Running this +# script takes a second and catches it before spending a synthesis run. +# +# WHAT IT CHECKS +# 1) a line inside .v/.vh/.xdc that has non-ASCII characters *outside* a comment +# (i.e. real code position) -> corruption; +# 2) a line that looks like pasted prose/markdown (leading "|", "**", or a line +# that is bare text after `endmodule`). +# +# USAGE (from the repository root or from pipelined-cpu/): +# powershell -ExecutionPolicy Bypass -File pipelined-cpu\tools\check_rtl_text.ps1 +# Exit code 0 = clean, 1 = found something. +# ============================================================================= +$ErrorActionPreference = 'Stop' + +$srcs = Join-Path (Split-Path -Parent $PSScriptRoot) 'srcs' +if (-not (Test-Path $srcs)) { Write-Output "ERROR: cannot find $srcs"; exit 2 } + +$bad = 0 +$files = Get-ChildItem -Recurse -Path $srcs -Include *.v, *.vh, *.xdc -File + +foreach ($f in $files) { + $rel = $f.FullName.Substring($srcs.Length).TrimStart('\', '/') + $lines = @(Get-Content -LiteralPath $f.FullName) + $inBlockComment = $false + + for ($i = 0; $i -lt $lines.Count; $i++) { + $line = $lines[$i] + $lineNo = $i + 1 + + # ---- strip comments so we only look at code positions ---- + $code = $line + if ($f.Extension -eq '.xdc') { + $h = $code.IndexOf('#'); if ($h -ge 0) { $code = $code.Substring(0, $h) } + } + else { + $c = $code.IndexOf('//'); if ($c -ge 0) { $code = $code.Substring(0, $c) } + if ($inBlockComment) { $code = '' } + if ($line -match '/\*') { $inBlockComment = $true } + if ($line -match '\*/') { $inBlockComment = $false } + } + + $trim = $line.Trim() + + # ---- check 1: non-ASCII in code position ---- + if ($code -match '[^\x00-\x7F]') { + Write-Output ("!! $rel`:$lineNo non-ASCII text in code position:") + Write-Output (" " + $trim) + $bad++ + continue + } + + # ---- check 2: pasted prose / markdown leftovers ---- + if ($trim -match '^\||^\*\*|^#[^0-9#]' -and $f.Extension -ne '.xdc') { + Write-Output ("!! $rel`:$lineNo looks like pasted prose:") + Write-Output (" " + $trim) + $bad++ + } + } +} + +Write-Output "" +Write-Output ("scanned " + $files.Count + " files under srcs/") +if ($bad -eq 0) { + Write-Output "RTL text check: OK (no stray non-Verilog text found)." + exit 0 +} +Write-Output ("RTL text check: FAILED, " + $bad + " suspicious line(s) - fix them before synthesis.") +Write-Output "Hint: such lines are usually injected by an editor/tool; remove them, then re-run this script." +exit 1