{"slug":"readable-verilog-always","title":"readable-verilog-always","summary":"Use when writing, splitting or reviewing Verilog always blocks, including clocked register updates, reset and enable priority, and combinational assignment coverage.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-03T17:18:07.380366Z","repo":{"url":"https://github.com/Eriemon/verilog-generator","stars":348,"forks":23,"license":"Apache-2.0","updatedAt":"2026-12-03T15:34:41Z"},"bodyHtml":"<hr>\n<h2>name: readable-verilog-always\ndescription: Use when writing, splitting or reviewing Verilog always blocks, including clocked register updates, reset and enable priority, and combinational assignment coverage.</h2>\n<h1>always 块</h1>\n<ol>\n<li><strong>确定触发与写入对象。</strong> 对每块列出事件、实际左值、复位值、使能和同拍优先级。区分边沿触发的时序块、组合块和有意锁存。同一模块可包含多个时序块。</li>\n<li><strong>一个时序块最多写一个寄存器。</strong> 同一寄存器在复位、使能、保持分支的重复写入或不同位段写入算一个目标。<code>{a,b} &lt;= data;</code> 写入两个独立目标。一个数组的不同索引按同一声明计；另查同址写冲突。时序更新用非阻塞赋值，每个目标核对所有驱动源。</li>\n<li><strong>按原采样关系拆块。</strong> 例如 <code>a &lt;= d; b &lt;= a;</code> 分成两个同沿块后，第二块仍采样旧的 <code>a</code>。各自保留原复位极性、同步或异步方式、使能和优先级。原来依赖阻塞赋值顺序、task 副作用或 RAM 推断模板时，先查清依赖，对照逐拍结果再改。</li>\n<li><strong>组合块检查每条路径。</strong> 使用 <code>always @(*)</code> 和阻塞赋值。允许同一组合块计算多个相关结果；用入口默认值和完整分支覆盖各目标。有意锁存要记录使能及保持条件。状态转移按<a href=\"../readable-verilog-fsm/SKILL.md\">状态机</a>单独处理。</li>\n</ol>\n<h2>标准示例：选择字节并延迟一级输出</h2>\n<p>组合块先选低字节，<code>i_high</code> 有效时改选高字节。两个时序块各写一个寄存器，共用时钟、同步复位和使能。使能沿到来时，<code>reg_sample</code> 采入所选字节，<code>o_previous</code> 采入沿前的 <code>reg_sample</code>。使能为低时两者保持，复位时两者清零。</p>\n<pre><code>module byte_sample_delay (\n\tinput  wire        i_clk,\n\tinput  wire        i_rst,\n\tinput  wire        i_enable,\n\tinput  wire        i_high,\n\tinput  wire [15:0] i_data,\n\toutput reg  [7:0]  o_previous\n);\n\treg [7:0] selected_byte;\n\treg [7:0] reg_sample;\n\n\t// 默认值覆盖低字节路径，组合译码使用阻塞赋值。\n\talways@(*)begin\n\t\tselected_byte = i_data[7:0];\n\t\tif(i_high)selected_byte = i_data[15:8];\n\tend\n\n\t// 第一级只在使能沿接收样本。\n\talways@(posedge i_clk)begin\n\t\tif(i_rst)reg_sample &lt;= 8'h00;\n\t\telse if(i_enable)reg_sample &lt;= selected_byte;\n\tend\n\n\t// 第二级同步取走上一次使能沿保存的样本。\n\talways@(posedge i_clk)begin\n\t\tif(i_rst)o_previous &lt;= 8'h00;\n\t\telse if(i_enable)o_previous &lt;= reg_sample;\n\tend\nendmodule\n</code></pre>\n<p>运行 <code>python -m verilog_generator review &lt;RTL文件&gt;</code>。<code>always.multiple_registers</code> 报告时序块位置及写入对象，<code>reg.multiple_drivers</code> 报告不同过程对同一变量的重叠写入。前者是结构建议，后者是驱动错误。按<a href=\"../readable-verilog-verify/SKILL.md\">验证</a>回放复位、使能、停顿和连续更新，对照首个受影响的输出拍。</p>\n","files":[{"path":"SKILL.md","sizeBytes":2901,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-03T17:19:26.541743Z","sha256":"0D3BCC7256179CDF82D53F24E94F81F8CF529CB17830ABDE79DAE1F68B45B847","sizeBytes":1778},"review":null,"source":{"repositoryUrl":"https://github.com/Eriemon/verilog-generator","path":"skills/readable-verilog-always","license":"Apache-2.0","commit":"4738a3c74a2b8a4fec46e6abef7abf66f3eaebea","subtreeSha":"F8794E1DE38AE0328B54D6D7B9B3ECC3E03DDCE1A342964D835F10C41E8AC2BD","lastSyncedAt":"2026-12-03T17:18:07.377421Z"},"reviewedAt":"2026-12-03T17:22:14.958164Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/Eriemon/verilog-generator/tree/main/skills/readable-verilog-always"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install eriemon-verilog-generator@llmmart"},{"target":"git","command":"git clone https://github.com/Eriemon/verilog-generator.git"}]}