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