Files
skills-win/simulink_rtl_dev/scripts/check_hdl_support.m
T
bowei ea4541ee90 sync: SHANGHAI-U9 2026-07-27 三个 Simulink→RTL skill 转系统级 + 新增 simulink-rtl-redev
- simulink_rtl_dev / rtl-ip-replace: 从工程级 .claude/skills 迁到用户级并去工程耦合
  (模型名/Notes 文档依赖/工程实测基线移出; addpath 与脚本路径改用户级)
- rtl-ip-replace/scripts/gen_cmp_tb.py: Vivado 路径不再写死, 改读 VIVADO_PATH /
  XILINX_VIVADO (兼容 install root / bin / bin\vivado.bat 三种写法), 回落时提示
  去设 skills_env.md 的 VIVADO_PATH
- simulink-rtl-redev: 新增。原生模型改动后的仿真模型同步规范, 含两个实测过的工具
  check_sync.py (三条时序链新鲜度闸门) 与 measure_k.m (时域/频域/包络三估计器互证)
- sim-rtl-flow/SKILL.md: 加入 sync_sim:* 步骤, 引用上述三个 skill
2026-07-27 10:39:53 +08:00

65 lines
1.9 KiB
Matlab

function ok = check_hdl_support(target, varargin)
%CHECK_HDL_SUPPORT HDL Coder compatibility check for an RTL-bound subsystem.
%
% ok = CHECK_HDL_SUPPORT('model/HdlSubsystem')
% ok = CHECK_HDL_SUPPORT(..., 'Out', 'hdl_support.txt')
%
% Wraps checkhdl: catches blocks that cannot become RTL at all -- the other
% half of Task12-1 rule 1 ("must be built from blocks that generate RTL
% directly"). The m-code policy audit is audit_hdl_blocks.m; run both.
p = inputParser;
p.addParameter('Out', '');
p.parse(varargin{:});
model = strtok(target, '/');
if ~bdIsLoaded(model)
load_system(model);
end
txt = '';
threw = false;
try
txt = evalc('checkhdl(target)');
catch e
threw = true;
txt = sprintf('checkhdl threw: %s\n%s', e.identifier, e.message);
end
% The summary line is localised ("0 个错误、2 个警告" / "0 errors, 2 warnings"),
% so count both spellings rather than grepping for the word "error".
nErr = local_count(txt, {'(\d+)\s*个错误', '(\d+)\s+errors?'});
nWarn = local_count(txt, {'(\d+)\s*个警告', '(\d+)\s+warnings?'});
ok = ~threw && nErr == 0;
rep = regexp(txt, '(?<=file:///)[^''"<>]*_report\.html', 'match', 'once');
fprintf('=== checkhdl %s : %s (%d error(s), %d warning(s)) ===\n', ...
target, string(ok), nErr, nWarn);
if ~isempty(rep)
fprintf('report: %s\n', strrep(rep, '/', filesep));
end
disp(txt);
if nWarn > 0
fprintf(['NOTE: warnings are not a pass/fail gate here, but read them -- they are usually\n' ...
' "this block will cost you area/latency in RTL" hints.\n']);
end
if ~isempty(p.Results.Out)
fid = fopen(p.Results.Out, 'w');
fwrite(fid, txt);
fclose(fid);
fprintf('checkhdl log -> %s\n', p.Results.Out);
end
end
function n = local_count(txt, pats)
n = 0;
for i = 1:numel(pats)
t = regexp(txt, pats{i}, 'tokens', 'once');
if ~isempty(t)
n = str2double(t{1});
return
end
end
end