Use when processing RTL modules at the microarchitecture level - including FIFO, state machines, counters, arbiters, decoders, or any Verilog/SystemVerilog hardware design. Load this skill immediately upon identifying RTL design tasks, before diving into brainstorming,planning or implementation.
This skill provides microarchitecture design guidance for RTL modules. It covers design principles, naming conventions, interface design, module partitioning, and architectural decisions that should be established before writing code.
Core principle: Good microarchitecture decisions made early prevent costly refactoring later.
Load this skill when:
Do NOT wait until coding phase. Microarchitecture decisions shape the entire design process.
低时序耦合的接口设计包括但不限于下方式:
使用握手信号(如valid/ready)来管理数据传输,避免模块之间的时序依赖。这种形式下接口命名可以统一以业务名称为前缀,xxx_vld、xxx_rdy、xxx_data等,形成一套清晰的接口命名规范。
使用阈值机制来控制数据流,例如上游给下游xxx_en和xxx_data、xxx_addr等载荷,而下游通过xxx_stall等信号来反馈是否准备好接收数据。但这种情况下需要严格计算上游en传播到下游,下游stall再传播到上游的总时间,下游应当有足够的buffer来吸收这个时间,否则就会产生时序耦合。
使用Credit-based flow control机制来管理数据流,例如上游给下游xxx_vld(xxx_en)和xxx_data等载荷,而下游通过xxx_credit等信号来反馈可用的buffer数量,从而实现流量控制。这里要注意下游的credit必须是基于内部真实能够接收数据的buffer数量来设计的,而不能是一个虚拟的值,否则也会产生时序耦合。
采用无流量控制的接口设计,例如上游直接给下游xxx_vld(xxx_en)和xxx_data等载荷,而下游没有任何反馈信号来控制数据流。这种设计虽然简单,但需要保证下游模块能够在任何时候都准备好接收数据,或者当前的这个上下游数据传输是可接受丢包的。
采用标准协议作为链接层,例如AXI、APB、Wishbone等,这些协议其实都是上述方案的变体或者多方案合一的方案,已经被广泛验证过,可以直接使用。
某些特殊的pipeline场景,允许出现严格的时序耦合。但要在更上层的设计中严格论证这个时序耦合是可控的,并且在接口设计中明确标注这个时序耦合的存在和要求。
Define interfaces before implementation:
Module Interface Template:
- Clock and reset naming (clk, rst_n)
- Data signals: prefix-based naming (in_vld, in_rdy, in_data)
- Control signals: clear semantic names
- Parameter naming: ALL_CAPS with explicit types
Split modules by:
在设计时,尽量进行低耦合设计,对于timing较为紧张的路径,可能出现长距离路由的路径,或者必须跨越多个模块的路径,就必须采取低耦合的设计,考虑到未来通过pipeline插入来解决时序问题。
在模块划分时,对于装载了实际电路逻辑的模块,需要考虑floorplanning的需求,如果这些电路有可能被放在不同的区域,那么就需要考虑拆分到不同的模块里,以便后续的floorplanning和布局布线。并且他们之间的接口设计也需要考虑到这个物理上的分布,尽量减少跨区域的信号数量和频率,以及采用低耦合的接口设计来降低跨区域通信的时序风险。
Signal naming:
_n (rst_n)xxx_vld, xxx_rdy, xxx_datav_ for independent signals of same typeModule naming:
sc_bus_arbiter not arbiterParameter naming:
DATA_WIDTH, FIFO_DEPTHparameter integer unsigned DATA_WIDTH = 8For async designs:
微架构设计应该包含以下输出:
微架构示意图: 应当逐层展示模块划分和接口关系。
接口定义: 每个模块的接口定义应当清晰地列出所有输入输出信号的名称、类型(单比特/向量)、方向(输入/输出)、功能描述、所属时钟域、是否有时序耦合等信息。
参数化: 每个模块的参数列表应当清晰地列出所有参数的名称、类型、默认值、功能描述、可选值范围等信息。
| Design Aspect | Key Considerations |
|---|---|
| Interface | Define before implementation, use consistent prefixes |
| Partitioning | Single responsibility, separate timing domains |
| Naming | Meaningful, consistent, prefix-based for buses |
| Parameters | Type-explicit, ALL_CAPS, synthesizable defaults |
| Clock Domains | Identify early, plan CDC structures |
| Reset | Document type, synchronous release |
Before coding, answer:
| Mistake | Impact | Fix |
|---|---|---|
| Inconsistent naming | Debugging nightmare | Define naming convention upfront |
| Late partitioning | Rewrites, bugs | Partition during design phase |
| No interface spec | Integration failures | Define all interfaces first |
| Ignoring CDC | Metastability, data corruption | Identify clock domains early |
| Hard-coded values | Non-reusable modules | Parameterize from start |
Interfaces:
- Write side: wr_clk, wr_rst_n, wr_en, wr_data, full
- Read side: rd_clk, rd_rst_n, rd_en, rd_data, empty
Key decisions: Depth, width, clock domains, full/empty logic
Interfaces:
- Control inputs, status outputs
- State-specific data paths
Key decisions: Encoding (one-hot/binary), state partitioning, FSM type (Moore/Mealy)
Interfaces:
- Request/Grant pairs per master
- Shared resource interface
Key decisions: Arbitration policy, priority scheme, fairness
Good microarchitecture:
Poor microarchitecture: