<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sean Galloway on Medium]]></title>
        <description><![CDATA[Stories by Sean Galloway on Medium]]></description>
        <link>https://medium.com/@seangalloway_16533?source=rss-4c2e21d4b142------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YNoYg6hC9uJYJOm7SaHSxg@2x.jpeg</url>
            <title>Stories by Sean Galloway on Medium</title>
            <link>https://medium.com/@seangalloway_16533?source=rss-4c2e21d4b142------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:06:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@seangalloway_16533/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[“AI Wrote My DMA. The Microarchitecture Made It Good.”]]></title>
            <link>https://medium.com/@seangalloway_16533/ai-wrote-my-dma-the-microarchitecture-made-it-good-89dbebd11c06?source=rss-4c2e21d4b142------2</link>
            <guid isPermaLink="false">https://medium.com/p/89dbebd11c06</guid>
            <dc:creator><![CDATA[Sean Galloway]]></dc:creator>
            <pubDate>Sun, 01 Nov 2026 00:00:37 GMT</pubDate>
            <atom:updated>2026-11-03T15:29:49.984Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/">RTL Design Sherpa — Articles</a></p><p>I used Claude to help me implement Stream, a high-performance, multi-channel DMA. The first working version arrived quickly, but its AXI utilization did not. Getting from a working design to one that streams at line rate turned out to be a useful lesson in what an LLM can infer, and what a designer still needs to specify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mu3wHBLKF4l0CGcdyj4SVg.png" /></figure><p>Is Stream any good? The current FPGA measurements say yes, within its documented operating envelope. But the result wasn’t a one-week AI success story. The control architecture worked early because I described it in detail. The AXI engines needed a second attempt because I initially gave them a performance goal instead of a microarchitecture. Months of FPGA work then turned “it passes” into evidence I could trust.</p><h3>The thoughts behind Stream</h3><p>The architectural thought was to separate ownership of work, movement, and storage. I use the word <em>engine</em> for a block that works on its own after receiving an input; give it more work, and it knows how to make progress. I specified the scheduler, descriptor engine, and SRAM control in detail because they own the contracts that make concurrent streaming possible. For the AXI read and write engines, I initially specified only those external contracts and asked for maximum utilization. That left the most important internal decisions open.</p><p>The <strong>scheduler</strong> owns one channel’s active transfer. It accepts descriptors, presents source work to the read engine and destination work to the write engine, and tracks the beats in each direction. It does not need to know how either engine packs work into AXI bursts. Its job is to keep both sides moving and to distinguish issued writes from writes that have actually committed.</p><p>The <strong>descriptor engine</strong> keeps the scheduler supplied with work. It fetches descriptors, validates their addresses, follows chains, and prefetches future descriptors into a FIFO while the current transfer continues. Descriptor traffic and data traffic can therefore make progress independently, rather than taking turns.</p><p>The <strong>SRAM control</strong> connects the two data engines without requiring a descriptor to fit in the buffer. It reserves space before read bursts and reserves data before write bursts. The read engine can fill while the write engine drains, with backpressure applying only when the corresponding ledger says that continuing would be unsafe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*qDYH7RG6g8FgmLze.png" /></figure><h3>The scheduler tracks two different kinds of completion</h3><p>Each channel scheduler has a conventional control sequence:</p><pre>CH_IDLE -&gt; CH_FETCH_DESC -&gt; CH_XFER_DATA -&gt; CH_COMPLETE</pre><p>Chained transfers continue through CH_NEXT_DESC, while errors enter a sticky CH_ERROR state until the channel is reset. In CH_XFER_DATA, the scheduler presents independent read and write requests to the two engines. Each request carries an address and beat count. Done strobes and beat counts come back, so the scheduler can advance without knowing how either engine organizes its internal bursts.</p><p>The subtle part is completion. Three counters separate work that has been issued from work that is actually finished:</p><ul><li>Read beats remaining tracks the source side.</li><li>Write beats remaining tracks write issue.</li><li>Write beats to commit tracks AXI B responses still owed.</li></ul><p>A descriptor can advance when its reads are done, and its writes have been issued. The channel cannot report completion until all its writes have committed. Treating an accepted AW command as completed data movement would be a protocol bug, not an optimization.</p><p>Current Stream also lets the read side peek at the next chained descriptor without removing it from the FIFO. The read engine starts filling the SRAM with descriptor N+1 while the write side drains descriptor N. When the write side catches up, it loads the same descriptor and pops the FIFO entry. The in-order SRAM keeps the two streams separated by their beat counts. On silicon, this read-ahead path raised datapath utilization for a <strong>16-descriptor chain of 64-beat transfers</strong> from <strong>76.1% to 95.3%</strong>.</p><h3>The descriptor engine keeps work ahead of the datapath</h3><p>A Stream descriptor describes a source, a destination, a length in beats, and the next descriptor in a chain. The basic fetch sequence is short:</p><pre>RD_IDLE -&gt; RD_ISSUE_ADDR -&gt; RD_WAIT_DATA -&gt; RD_COMPLETE</pre><p>The engine validates the descriptor address, issues the AXI read, accepts the returned descriptor, and puts it in a FIFO for the scheduler. An error path discards a bad fetch instead of quietly launching it. The current implementation also has a second fetch state pair for EXT descriptors, which need another 32-byte chunk.</p><p>Fetching only on demand would leave the scheduler waiting at every chain boundary. The descriptor engine therefore follows the chain autonomously and buffers descriptors ahead of use. A runtime threshold limits how far it runs ahead; with prefetch disabled, it still keeps roughly one descriptor available rather than stopping completely. In the default shared-engine build, one fetch engine round-robins across channels, and the AXI response ID routes each descriptor back to the right channel FIFO.</p><p>That separation gives the data engines something useful to do while descriptor traffic proceeds on another AXI master.</p><h3>The SRAM has two reservation ledgers</h3><p>The per-channel SRAM control is my favorite part of the architecture. It makes high-rate streaming a bookkeeping problem with explicit invariants, rather than a collection of hopes about AXI timing.</p><p>Two virtual FIFOs sit alongside the physical data FIFO, so there are <strong>four accounting pointers</strong>, not one write pointer with several names. The RTL calls the two pointers inside each controller r_wr_ptr_bin and r_rd_ptr_bin; the controller name is what disambiguates them. These are event counters, not physical RAM addresses.</p><pre>Space ledger: stream_alloc_ctrl alloc_wr_ptr += burst size when an AR burst reserves space alloc_rd_ptr += 1 when an accepted W beat releases space space_free = SRAM_DEPTH - (alloc_wr_ptr - alloc_rd_ptr) Data ledger: stream_drain_ctrl actual_wr_ptr += 1 when an actual R beat enters the physical FIFO drain_rd_ptr += burst size when an AW burst reserves data data_available = actual_wr_ptr - drain_rd_ptr</pre><p>The <strong>allocation write pointer</strong>, alloc_wr_ptr, records promises to supply future read data. The <strong>actual write pointer</strong>, actual_wr_ptr, records data that has really arrived. An AR reservation moves only the first. An accepted R beat moves only the second. That distinction is what lets the controller represent several outstanding reads whose data has not arrived yet.</p><p>The two read pointers also have different jobs. drain_rd_ptr reserves existing data for an AW burst, removing it from the pool available to other write requests. alloc_rd_ptr releases space only when a W beat is actually accepted. Reserving data for a future write does not free its space; transmitting that data does.</p><p>This lets the read engine issue AR bursts aggressively whenever enough unreserved space remains. It does <strong>not</strong> issue one read, wait for all its data to return, and only then consider the next read. Multiple bursts can be outstanding, each with its full data space already reserved. Returning R beats stream into storage that was guaranteed before the corresponding command left the engine.</p><p>For a 16-beat example, the four events are independent:</p><ol><li>The read engine reserves a burst: alloc_wr_ptr += 16. No data has arrived, so actual_wr_ptr does not move.</li><li>Sixteen R beats enter the FIFO: actual_wr_ptr advances 16 times. Space was already reserved, so alloc_wr_ptr does not move.</li><li>The write engine reserves those beats for AW: drain_rd_ptr += 16. The beats are still in the SRAM, so alloc_rd_ptr does not move.</li><li>Sixteen W beats are accepted: alloc_rd_ptr advances 16 times, releasing their space. Neither write pointer changes during this step.</li></ol><p>Reserved beats no longer count as available to another request, even if they still sit in the FIFO or latency bridge. Neither engine needs to predict the other’s response latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p4D2IyJQKNo8zGWw.png" /></figure><p>The latency bridge aligns the FIFO’s registered read timing with the write interface. Its occupancy must not be added to data_available, because those beats are already included in the drain ledger. The drain ledger also has extra accounting depth so beats in the bridge cannot disappear from the count at a full-FIFO boundary. Neither detail is glamorous. Both separate clean streaming from a channel that eventually wedges.</p><p>This structure is also why small and large descriptors use the same control. Pointer increments change size, but the rules do not. Reads and writes continue simultaneously, backpressure stops the side that cannot proceed, and a descriptor larger than the SRAM still streams through it.</p><h3>“Maximize utilization” was not a microarchitecture</h3><p>Claude produced the descriptor engine, scheduler, and SRAM controls successfully from the detailed definitions. The AXI engines also passed our tests within about a week. When I asked for utilization, the early result I remember was around <strong>65%</strong>.</p><p>The October 2025 design package provides useful context for that stage. Its analytical low-performance mode reports <strong>65.8%</strong> efficiency with one outstanding transaction in each AXI direction, and its requirements call for greater than <strong>80%</strong> of theoretical AXI bandwidth. My development history is that the implementation reached about <strong>80%</strong> and stalled there. The raw early simulation reports are no longer in the repository, so I treat those implementation numbers as project history, not as results a reader can reproduce today.</p><p>I let Claude keep working on the engines for another week with general performance nudges. At roughly 80%, it told me this was the industry-standard maximum.</p><p>No universal industry-standard maximum stops a well-fed AXI interface at 80%. More importantly, the answer didn’t identify the mechanism preventing the next beat. I stopped optimizing by encouragement.</p><p>I asked Claude to clean-slate the engines, then gave it a specific V2 microarchitecture. The October 28 design note records the important changes:</p><ul><li>Increase from one blocking transaction up to <strong>eight outstanding transactions</strong>, as a parameter.</li><li>Queue commands so address issue no longer waits for earlier data and responses.</li><li>Decouple AW, W, and B on the write side instead of serializing AW -&gt; W -&gt; B -&gt; next AW.</li><li>Give the W channel its own drain machinery to preserve command order.</li><li>Track B responses asynchronously and route them by ID.</li><li>Carry per-command SRAM base and current-pointer state instead of assuming one active transaction.</li><li>Keep the scheduler and SRAM interfaces unchanged.</li></ul><p>The new coding took about a day, and the engines reached full utilization in our development setup. The architecture had changed, not the motivational wording in the prompt.</p><h3>Passing quickly is not the same as being finished</h3><p>The rest of the story matters because the first version was not literally bug-free. Later simulation and FPGA work found real corner cases:</p><ul><li><strong>Completion came too early.</strong> The channel initially reported done after issuing write commands rather than after all B responses committed.</li><li><strong>A lost WLAST beat could deadlock a channel.</strong> SRAM could pop a beat that the AXI W channel did not transmit under a particular backpressure and registered-valid alignment. The fix was to pop only on the actual WVALID &amp;&amp; WREADY handshake.</li><li><strong>Registered space and data counts went stale.</strong> New allocations or drains could still be crossing pipeline registers while the next arbitration decision used the old count. The engines now subtract in-flight updates before issuing another command.</li><li><strong>A stale grant could duplicate AW.</strong> In non-pipelined operation, one channel could load a second write command while the first was outstanding. Command acceptance now uses the live arbitration request.</li><li><strong>A 256-beat request wrapped to zero.</strong> AxLEN + 1 was evaluated in eight bits. Configuration is now clamped to the buffer capacity and the representable transfer-size range.</li></ul><p>These weren’t all part of the one-day V2 rewrite. They came from the months of verification that followed. That is precisely why I don’t equate a clean first regression with a finished DMA.</p><p>There was also a later measurement lesson. An archived FPGA report showed roughly <strong>94%</strong> before reaching <strong>100%</strong>. Part of the gap came from the synthetic test slave inserting a dead cycle between bursts, and part came from charging one-time pipeline fill and drain to starvation. The DUT was gapless between its first and last beat once those harness and measurement issues were corrected. This later 94% correction is separate from my early 65% to 80% development story.</p><h3>What the current measurements support</h3><p>The <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/fpga-systems/Genesys2/dma-ip/stream/reports/perf/README.md">current Stream performance report</a> now includes board sweeps, raw JSON, CRC checking, on-chip bus meters, memory-latency tests, and transaction-size sweeps.</p><p>On Genesys 2, an eight-channel, 128-bit build running at 100 MHz passed all <strong>40 configurations</strong> with both shared and per-channel descriptor engines. Each 40-point sweep varied active channels and descriptor-chain length, moved 1 MiB per descriptor per channel, and used no added memory latency. Both builds moved data at <strong>1525.9 MiB/s</strong> from first beat to last, the full rate available from 16 bytes per cycle at 100 MHz. Sharing the descriptor engine did not cost throughput.</p><p>That 100% claim is specifically <strong>datapath utilization while data is owed</strong>. It doesn’t mean every possible transfer has zero end-to-end overhead. Startup, descriptor handling, and trailing completion still cost cycles. One- and two-beat bursts cannot keep the in-flight window full, and enough memory latency will expose the bandwidth-delay limit. The performance report makes those boundaries explicit rather than hiding them behind the headline.</p><p>The FPGA work also standardized the harnesses and added the capabilities needed to trust a result: reusable bus functional models, per-channel timing skew, backpressure profiles, CRC end-to-end checks, on-chip utilization counters, host-driven sweeps, and archived raw results. This took much longer than generating the RTL. It also changed the conversation from “the model says it is fast” to “here is the workload, the measurement window, and the data.”</p><h3>What I would do the same way</h3><p>Stream is good because its control contracts are explicit, its buffer accounting has closed invariants, and its performance has now been measured on hardware. Claude accelerated the implementation considerably. It did not replace the architectural decisions that made the implementation converge.</p><p>If I repeated the project, I would still give an LLM the detailed FSMs, flows, and interfaces. I would not give any engine only a bandwidth target. I would specify outstanding-transaction behavior, command-and-response ordering, reservation timing, completion semantics, and the exact events that update every counter.</p><p>The useful division of labor wasn’t human architecture versus machine verification. I needed both throughout. It was more concrete: <strong>I specified the mechanisms that determine correctness and throughput; Claude helped turn those mechanisms into RTL and tests.</strong> When the specification was vague, the implementation stayed vague. When the mechanism was clear, the code followed quickly.</p><h3>Final takeaway</h3><p>I always set very clear criteria for my projects on GitHub. Stream reinforces my reasoning for always writing an architecture specification and a microarchitecture specification before any coding starts. Clear specifications made the difference between RTL that merely worked and a design that met its performance goals.</p><h3>References</h3><p>The published work below records architectural precedents for ideas that also appear in Stream. It is not a claim that Stream’s implementation copied these sources.</p><ol><li>Li-Shiuan Peh and William J. Dally, <a href="https://cva.stanford.edu/publications/1999/flit_rsvn.pdf">“Flit-Reservation Flow Control”</a>, <em>HPCA 2000</em>, DOI <a href="https://doi.org/10.1109/HPCA.2000.824340">10.1109/HPCA.2000.824340</a>. Control flits reserve buffers and bandwidth ahead of data, a close precedent for reserving SRAM before AR data arrives.</li><li>H. T. Kung, Trevor Blackwell, and Alan Chapman, <a href="https://www.eecs.harvard.edu/~htk/publication/1994-sigcomm-kung-blackwell-chapman.pdf">“Credit-Based Flow Control for ATM Networks”</a>, <em>SIGCOMM 1994</em>, DOI <a href="https://doi.org/10.1145/190314.190324">10.1145/190314.190324</a>. Credit accounting, subtracting in-flight data, per-flow buffer allocation, and sizing credits based on bandwidth and round-trip latency.</li><li>James E. Smith, <a href="https://doi.org/10.1145/357401.357403">“Decoupled Access/Execute Computer Architectures”</a>, <em>ACM Transactions on Computer Systems</em> 2(4), 1984. Autonomous producers and consumers connected by queues, the broader precedent for Stream’s decoupled engines.</li><li>Tao Chen and G. Edward Suh, <a href="https://www.csl.cornell.edu/~tchen/abstract/accelmem-micro16/">“Efficient Data Supply for Hardware Accelerators with Prefetching and Access/Execute Decoupling”</a>, <em>MICRO 2016</em>, DOI <a href="https://doi.org/10.1109/MICRO.2016.7783749">10.1109/MICRO.2016.7783749</a>. Prefetching and decoupling to tolerate long, variable memory latency.</li><li>Luca P. Carloni, Kenneth L. McMillan, and Alberto L. Sangiovanni-Vincentelli, <a href="http://webcluster.cs.columbia.edu/~luca/research/lipTransactions.pdf">“Theory of Latency-Insensitive Design”</a>, <em>IEEE Transactions on Computer-Aided Design</em> 20(9), 2001, DOI <a href="https://doi.org/10.1109/43.945302">10.1109/43.945302</a>. Stallable modules, backpressure, and latency bridging between decoupled components.</li><li>Daniel Lenoski et al., <a href="https://doi.org/10.1145/146628.139706">“The DASH Prototype: Implementation and Performance”</a>, <em>ISCA 1992</em>. Tagged split transactions with independently outstanding requests and responses, a precedent for Stream’s V2 command and response tracking.</li><li>John D. C. Little, <a href="https://www2.isye.gatech.edu/~spyros/courses/IE7201/Fall-13/Little-OR-paper.pdf">“A Proof for the Queuing Formula: L = λW”</a>, <em>Operations Research</em> 9(3), 1961, DOI <a href="https://doi.org/10.1287/opre.9.3.383">10.1287/opre.9.3.383</a>. The relationship among in-flight work, throughput, and latency behind the bandwidth-delay limit.</li><li>AMD/Xilinx, <a href="https://docs.amd.com/api/khub/documents/pYERDdVbLWxnOwYMeCp9_Q/content"><em>AXI MCDMA Product Guide PG288</em></a>, 2017. A commercial comparison for multiple channels, per-channel descriptor queues, independent descriptor fetching and data movement, and independent MM2S and S2MM paths.</li><li>ARM, <a href="https://developer.arm.com/documentation/ihi0022/latest"><em>AMBA AXI and ACE Protocol Specification</em></a>. The AR, R, AW, W, and B channel rules, transaction IDs, and write-response semantics used by Stream.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/docs/stream_mas/ch02_blocks/05_descriptor_engine.md">Stream descriptor engine</a>, and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/docs/stream_mas/ch02_blocks/04_scheduler.md">channel scheduler</a>. Descriptor prefetch, engine signaling, read-ahead, and commit-gated completion.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/docs/stream_mas/ch02_blocks/07_stream_alloc_ctrl.md">Stream allocation controller</a>, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/docs/stream_mas/ch02_blocks/11_stream_drain_ctrl.md">drain controller</a>, and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/rtl/fub/sram_controller_unit.sv">SRAM controller unit RTL</a>. The two reservation ledgers and latency-bridge accounting.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/a087c4c25/projects/components/stream/docs/AXI_ENGINE_V2_DESIGN.md">October 2025 AXI Engine V2 design note</a>. The command-pipelined engine rework described in this article.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/docs/stream_has/ch05_performance/01_throughput.md">Stream throughput measurements</a> and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/fpga-systems/Genesys2/dma-ip/stream/reports/perf/README.md">current FPGA performance characterization</a>. Board configuration, measurement definitions, operating limits, and raw-result locations.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/stream/known_issues/resolved/axi_write_engine_wlast_drain.md">WLAST/drain resolution</a> and closed Stream bugs <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/vault/tracking/projects/components/dma-ip/stream/bug/closed/BUG-012.md">BUG-012</a>, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/vault/tracking/projects/components/dma-ip/stream/bug/closed/BUG-013.md">BUG-013</a>, and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/vault/tracking/projects/components/dma-ip/stream/bug/closed/BUG-018.md">BUG-018</a>. Later engine corner cases and their fixes.</li></ol><p>From the <a href="https://github.com/sean-galloway/RTLDesignSherpa">RTLDesignSherpa</a> project ·<a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/feed.xml">RSS</a></p><p><em>Originally published at </em><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/stream-dma-microarchitecture/"><em>https://sean-galloway.github.io</em></a><em> on November 1, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89dbebd11c06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Generic Valid/Ready BFMs in Cocotb: One Interface Description for Every FUB Test”]]></title>
            <link>https://medium.com/@seangalloway_16533/generic-valid-ready-bfms-in-cocotb-one-interface-description-for-every-fub-test-9083114051d6?source=rss-4c2e21d4b142------2</link>
            <guid isPermaLink="false">https://medium.com/p/9083114051d6</guid>
            <category><![CDATA[verification]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[rtl-design]]></category>
            <category><![CDATA[cocotb]]></category>
            <dc:creator><![CDATA[Sean Galloway]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 00:00:12 GMT</pubDate>
            <atom:updated>2026-11-01T13:37:43.046Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/">RTL Design Sherpa — Articles</a></p><p>When I started coding RTL on GitHub, I needed to use CocoTB, as it is open source, and I wanted to test each module at the functional unit block, or FUB, level while the design was still fresh in my mind. Write the FUB, wrap a small testbench around it, and find the interface and control bugs right there. I didn’t want to wait until the whole component came together, possibly months later, and then hunt for a bug across several integrated blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fC80wIGLRtO14rkY.png" /></figure><p>I also didn’t want to keep rewriting the same testbench collateral. Many FUB interfaces are just valid, ready, and a payload, but the payload takes different forms. Sometimes it is one data signal. Sometimes it is a packed struct or a flat vector containing several fields. Sometimes every packet field has its own signal. Hand-connecting each bus functional model, or BFM, was error-prone. The wiring also became one more thing to maintain as the RTL changed.</p><p>I initially asked LLMs for help implementing it. That didn’t go well. When I was coding, the context for the FieldConfig, Packet, and Signal Resolver classes alone was too large, even when I tried to pass in the API’s through Markdown files. Nearly all of the original code is hand-crafted. The useful abstractions came from working through real testbench problems: field layout, signal discovery, handshake ownership, and readable diagnostics. The result is a generic valid/ready BFM whose interface can be described by a class or a dictionary.</p><h3>One handshake, several payload shapes</h3><p>A valid/ready transfer follows a simple rule: a transaction moves when both sides are ready. The BFM should own that rule and the payload. A BFM that drives valid while the test still pokes data signals only solves half the problem.</p><p>The payload representation should not dictate the test API. I wanted to write this:</p><pre>await cmd.send(cmd.create_packet(op=ACT, bank=2, row=0x234))</pre><p>Whether op, bank, and row travel in one packed cmd_pkt signal or on three separate signals depends on the RTL connection. This shouldn&#39;t change how the test describes the transaction.</p><p>Making that work required three pieces of collateral: FieldConfig, Packet, and SignalResolver.</p><h3>FieldConfig describes the transaction</h3><p>FieldConfig is the schema. It records each field&#39;s name and width, along with the information needed to interpret and display it: ordering, bit positions, defaults, number format, descriptions, and optional symbolic encodings.</p><p>A command interface can start as an ordinary dictionary:</p><pre>COMMAND_FIELDS = { &quot;op&quot;: { &quot;bits&quot;: 4, &quot;format&quot;: &quot;hex&quot;, &quot;encoding&quot;: {0x1: &quot;ACT&quot;, 0x3: &quot;RD&quot;, 0x4: &quot;WR&quot;}, }, &quot;bank&quot;: {&quot;bits&quot;: 3, &quot;format&quot;: &quot;dec&quot;}, &quot;row&quot;: {&quot;bits&quot;: 14, &quot;format&quot;: &quot;hex&quot;}, }</pre><p>The BFM factories accept that dictionary and normalize it into a FieldConfig. Code that prefers the class interface can construct the FieldConfig directly and pass that instead. A plain data-only interface does not even need a custom schema; FieldConfig.create_data_only(width) supplies the default.</p><p>For a packed interface, field order and width are part of the wire contract. They determine the bit ranges used to pack and unpack the vector. This is not display metadata bolted onto a BFM. It is the shared description used by the driver, collector, packet, and diagnostics.</p><h3>Packet gives the fields a useful representation</h3><p>Packet stores values by field name. A test can set packet.bank, compare two packets field by field, pack the values into an integer, or unpack a received vector back into named fields. Width masking keeps a field inside its declared size.</p><p>The same metadata makes received traffic readable. Number formats can present addresses in hexadecimal and pad them to their declared display width, while symbolic encodings can decode opcodes without hiding their raw values. For example, the 14-bit row address above is padded to four hexadecimal digits, and ACT appears alongside its encoded value:</p><pre>GAXIPacket(row=0x0234, bank=2, op=ACT (0x1))</pre><p>That’s much easier to debug than one long hexadecimal word and a round of mental shift-and-mask. A field such as bank can remain decimal, while descriptions and number formats make the detailed output useful too.</p><p>The field description can also represent implied low-order address bits. If only addr[31:5] is stored, expanding the field appends five zero bits on the right; for example, 0x80 becomes the full byte address 0x00001000. Packed and multi-signal inputs produce the same kind of packet, so the diagnostic doesn&#39;t depend on how the RTL exposed the payload.</p><p>That also improves scoreboards and failure messages. A mismatch can name the differing field instead of reporting only that two large integers were unequal.</p><p>There’s a conceptual echo of Knuth’s literate programming here: the human explanation and the executable behavior come from the same field description. The BFM isn’t a literate program itself, but its diagnostics follow the same human-first priority.</p><h3>FieldConfig links the BFM to the RTL</h3><p>FieldConfig is the link between the RTL and the BFMs. It describes the packet fields that the BFM presents to the test, while SignalResolver matching that description to the actual top-level DUT signals. I did not want to manually bind every signal, especially while port names and interface shapes were still changing.</p><p>SignalResolver follows common naming heuristics. It uses the protocol side, prefixes, bus name, packet prefix, and payload mode to match the packets to RTL ports. For a conventional cmd_ interface, it can discover names such as cmd_valid, cmd_ready, and cmd_pkt. In multi-signal mode, it looks for individual field names such as cmd_op, cmd_bank, and cmd_row. If the heuristics cannot resolve a required signal, the resolver throws an error rather than leaving the BFM silently disconnected.</p><p>When the RTL does not follow the common conventions, a signal_map provides an override mechanism:</p><pre>signal_map = { &quot;valid&quot;: &quot;cmd_valid_i&quot;, &quot;ready&quot;: &quot;cmd_ready_o&quot;, &quot;data&quot;: &quot;cmd_payload_i&quot;, }</pre><p>The map may be partial. Explicit entries bind first, and the common heuristics resolve the rest. This keeps automatic connection convenient without forcing unusual RTL names to fit the default patterns.</p><p>The resolved signal handles are then shared with the data-driving and data-collection strategies. They do not repeat the discovery work or maintain a second interpretation of the interface.</p><h3>One description becomes three BFMs</h3><p>Here is the factory-level view of the packed command example:</p><pre>from CocoTBFramework.components.gaxi.gaxi_factories import create_gaxi_master cmd = create_gaxi_master( dut, &quot;cmd&quot;, &quot;&quot;, dut.aclk, field_config=COMMAND_FIELDS, bus_name=&quot;cmd_&quot;, ) await cmd.send(cmd.create_packet(op=0x1, bank=2, row=0x234))</pre><p>With multi_sig=False, the data strategy packs the fields and drives one combined payload signal. With multi_sig=True, the resolver looks for separate field signals, and the driver writes each field directly:</p><pre>cmd = create_gaxi_master( dut, &quot;cmd&quot;, &quot;&quot;, dut.aclk, field_config=COMMAND_FIELDS, bus_name=&quot;cmd_&quot;, multi_sig=True, )</pre><p>For a simple data-only interface, the same pattern becomes:</p><pre>from CocoTBFramework.components.shared.field_config import FieldConfig read_data = create_gaxi_master( dut, &quot;read_data&quot;, &quot;&quot;, dut.aclk, field_config=FieldConfig.create_data_only(128), bus_name=&quot;dfi_rd_&quot;, )</pre><p>The master BFM drives valid and payload while honoring ready. The slave BFM drives ready and captures valid and payload. Timing profiles can introduce valid delays or backpressure without changing the packet definition or the test’s transaction API.</p><p>The reuse goes beyond putting three constructors behind one function name. The same field description flows through the whole path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/0*pSWPFF5UT8H3B72G.png" /></figure><p>That’s the difference between reusable BFM collateral and yet another protocol driver.</p><p>I didn’t set out to implement patterns from a catalog, but several familiar software ideas describe what emerged. FieldConfig is a table-driven description of behavior. Packet is a canonical transaction model that hides individual signal formats. The resolver and payload paths act as adapters, with packed and multi-signal implementations providing strategy variants. Automatic naming with explicit exceptions is convention over configuration.</p><h3>The unexpected result: design moved faster</h3><p>I expected to write less testbench code. I didn’t expect the immediate FUB tests to speed up design cleanup as much as they did.</p><p>A small FUB test can exercise a boundary as soon as one writes it. It can apply backpressure, inspect the accepted transaction, and compare named fields without the rest of the component obscuring the result. You still remember why the logic looks the way it does, and the failing interface is usually small enough to reason about directly.</p><p>These tests found real control mistakes early: readiness logic sampling current state instead of next state, a grant based on a registered decision rather than an accepted handshake, and bookkeeping that disagreed with state at a FUB boundary. Fixing those problems at the FUB level was much cheaper than discovering them after integration, when several modules could plausibly be at fault.</p><p>Another, less obvious benefit exists. Because the BFM owns both handshake and payload, the testbench stops encoding accidental assumptions through hand-poked signals. The test states what transaction should happen. The collateral handles how it crosses the interface.</p><p>Generic doesn’t mean universal. A valid-only strobe with no ready isn’t a valid/ready interface, so it needs a different driver. Nonstandard port names need discovery patterns or a signal_map. A packed struct still needs a field layout that matches the RTL. The abstraction removes repetitive work; it doesn&#39;t remove the need to define the contract correctly.</p><p>The payoff is that you no longer need a new collection of handshake drivers, packing functions, monitors, and formatting code for each new FUB interface. Define the fields, choose the payload form, connect the BFM, and start testing the design. The earlier you run that loop, the sooner the design gets clean.</p><h3>References</h3><ol><li>Donald E. Knuth, “Literate Programming,” <em>The Computer Journal</em> 27(2), 1984, pp. 97–111. <a href="https://doi.org/10.1093/comjnl/27.2.97">DOI</a>; <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/articles/references/LiterateProgramming__Knuth1984.pdf">archived PDF</a>. Human-first explanation and the conceptual analogy for readable packet diagnostics, not a claim that the BFM uses literate programming.</li><li>Steve McConnell, <em>Code Complete</em>, 2nd ed., Microsoft Press, 2004, <a href="https://www.oreilly.com/library/view/code-complete-2nd/0735619670/ch18.html">Chapter 18, “Table-Driven Methods”</a>. The general technique behind letting FieldConfig descriptions drive behavior instead of writing per-interface logic.</li><li>Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, <em>Design Patterns: Elements of Reusable Object-Oriented Software</em>, Addison-Wesley, 1995. <a href="https://www.informit.com/store/design-patterns-elements-of-reusable-object-oriented-9780201633610">Publisher</a>; <a href="https://www.informit.com/articles/article.aspx?p=1398600">Adapter excerpt</a>. Adapter reconciles the packet API with different RTL interfaces, and Strategy provides interchangeable packed and multi-signal payload paths.</li><li>Gregor Hohpe and Bobby Woolf, <em>Enterprise Integration Patterns</em>, Addison-Wesley, 2003, <a href="https://www.enterpriseintegrationpatterns.com/patterns/messaging/CanonicalDataModel.html">“Canonical Data Model”</a>. This sets the precedent for Packet as a common transaction representation independent of each RTL payload format.</li><li>David Heinemeier Hansson, <a href="https://rubyonrails.org/doctrine">“The Ruby on Rails Doctrine: Convention over Configuration”</a>. A clear statement of the principle behind common naming heuristics by default and explicit signal_map overrides for exceptions.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/bin/TBClasses/fub_bfm.py">FUB valid/ready BFM wrappers</a>. Producer and consumer helpers, explicit signal mapping, timing profiles, and the valid-only boundary.</li><li>RTL Design Sherpa DV, <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/shared/field_config.py">FieldConfig and FieldDefinition</a>. Field schemas, widths, ordering, formats, encodings, and dictionary conversion.</li><li>RTL Design Sherpa DV, <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/shared/packet.py">Packet</a> and <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/gaxi/gaxi_packet.py">GAXIPacket</a>. Named values, packing, comparison, and human-readable output.</li><li>RTL Design Sherpa DV, <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/shared/signal_mapping_helper.py">SignalResolver</a>. Automatic signal discovery, partial overrides, and required-signal validation.</li><li>RTL Design Sherpa DV, <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/gaxi/gaxi_component_base.py">GAXI component base</a> and <a href="https://github.com/sean-galloway/RTLDesignSherpa-DV/blob/main/src/CocoTBFramework/components/shared/data_strategies.py">data strategies</a>. How the field configuration, resolver, packets, and BFMs fit together.</li></ol><p>From the <a href="https://github.com/sean-galloway/RTLDesignSherpa">RTLDesignSherpa</a> project ·<a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/feed.xml">RSS</a></p><p><em>Originally published at </em><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/generic-valid-ready-bfm-cocotb/"><em>https://sean-galloway.github.io</em></a><em> on October 30, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9083114051d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Should a DMA’s FSM Become a Processor?]]></title>
            <link>https://medium.com/@seangalloway_16533/when-should-a-dmas-fsm-become-a-processor-986673c1802c?source=rss-4c2e21d4b142------2</link>
            <guid isPermaLink="false">https://medium.com/p/986673c1802c</guid>
            <category><![CDATA[fpga]]></category>
            <category><![CDATA[rtl-design]]></category>
            <category><![CDATA[risc-v]]></category>
            <category><![CDATA[dmas]]></category>
            <dc:creator><![CDATA[Sean Galloway]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 00:00:57 GMT</pubDate>
            <atom:updated>2026-11-01T13:34:31.742Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/">RTL Design Sherpa — Articles</a></p><p>I had read about barrel processors and thought they might be useful for a future project. I turned notes from Hennessy and Patterson, and Harris and Harris, into requirements. Kimi helped with coding and validation. A very lean, N-Barrel RV32i, called Gatling, was ready sooner than the project needed. So, I tried to use it in another way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KNWsDEjBxbBJju8K.png" /></figure><p>I name my projects to make them easier to talk about. I called it Gatling. Once it worked, I remembered someone’s suggestion: put a processor into a high-performance DMA.</p><p>I’ve long preferred microcontrollers for power management and training/calibration control. I was curious whether DMA FSMs could offer the same flexibility.</p><p>The idea was to replace scheduler FSMs with small processors: not a host CPU, and not a processor moving every beat. An RV32I core rotates N hardware contexts through one shared datapath, one context per cycle. Descriptor policy becomes firmware; the engine-rate datapath stays hardware.</p><p>The surprising part wasn’t that it worked. It was how badly it lost in one test, and how close it came in another:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bUNBu5bMdZ3PV2yd.png" /></figure><p>The first is <strong>18.1×</strong> slower. The second is <strong>0.2%</strong> slower. That gap is the cost/benefit question: how much control work does each descriptor need, and what useful data movement can hide it?</p><p>I used <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/rapids/docs/rapids_mas/ch05_rapids_g/01_overview.md">RAPIDS and rapids-g</a> to find out: an 8-channel, 256-bit DMA running at 100 MHz with a 3,200 MB/s peak in each direction. The two implementations share the datapath, descriptor format, register map, and host software. That gave me an unusually controlled comparison.</p><h3>Replace the policy, not the datapath</h3><p>Firmware takes and validates descriptors, follows chains, commands channel-state transitions, and calculates EXT run bases. It also validates the next descriptor while the current one transfers.</p><p>Hardware still advances addresses within a run, decrements engine counters, enforces timeouts, records sticky errors, emits monitor packets, and moves data. A channel reset forces CH_IDLE; a fatal fault forces CH_ERROR immediately. Those interlocks don&#39;t wait for a firmware polling pass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SV4hT-iCETcTzzUe.png" /></figure><p>So “replace the FSMs with processors” is useful shorthand, but it’s inaccurate if you take it literally. The processors replace <em>policy sequencers</em>. They don’t replace machinery that has to respond on the next clock.</p><h3>What a barrel processor buys</h3><p>A barrel core is fine-grained multithreading in its simplest form. With N contexts, the core rotates through them and can issue one instruction each cycle in aggregate. Each context, called a hart, issues at most once every N cycles. These are hardware threads, not N complete processors. One instruction per cycle sounds great until you’re the hart waiting for your next turn.</p><p>This organization has a long history, including the CDC 6600’s rotating peripheral processors and later fine-grained multithreaded machines. The <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/riscv-ip/gatling-rv32i/docs/gatling_has/ch01_introduction/01_introduction.md">Gatling documentation and references</a> place our implementation in that lineage; the technique isn’t new.</p><p>For DMA control, I cared about four things:</p><ul><li><strong>Policy and descriptor checks become programmable.</strong> I can add descriptor quality checks on the fly in a writable build, then commit the firmware to ROM.</li><li><strong>Work can be moved ahead.</strong> Pre-validation and pre-arming let hardware start a chained descriptor as soon as its predecessor completes.</li><li><strong>New debug and error messages are free.</strong> I can send new messages by changing firmware, not by changing an FSM state or message path. Existing monitor machinery carries them. Verification still costs effort, but there’s no new message RTL.</li><li><strong>One datapath serves many channels.</strong> At 4 and 8 channels, the default is one hart per channel. At 16 channels, eight harts serve two slots each.</li></ul><p>Both RAPIDS-G builds instantiate <strong>one Gatling per direction</strong>, two in total. At 16 channels, FSM LUTs grow from 69,184 to 126,820 and firmware LUTs from 77,975 to 141,067. The extra state is channel windows, base queues, and other per-channel logic, so firmware overhead stays in the 11–13% range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fxvomtLEJaCnInXo.png" /></figure><p>Why not use 16 harts? Each channel would get its own hart, but each hart would wait 16 clocks between instructions. The two-slot build wins the lone-channel short-descriptor test, <strong>3,131 cycles to 4,731</strong>; the 16-hart build wins with every channel busy, <strong>4,620 to 5,383</strong>. The 1 MB results are effectively tied. The eight-hart build keeps half the hart state and stays within 0.6% of the best EXT result. Two 8-hart Gatlings per direction could avoid slot sharing without the longer rotation, but would duplicate core resources. I haven’t built or measured that option.</p><p>One example shows the benefit: the firmware build supports next-address selector 1, a Z-order algorithm that the FSM build refuses. That doesn’t mean every feature is cheaper in software. The EXT measurements show the opposite for address arithmetic, but it’s still valuable to have a place to put a new algorithm.</p><h3>The implementation bill</h3><p>The out-of-context Kintex-7 comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pBK1KcODwJsoO1NB.png" /></figure><p>Firmware costs <strong>12.7% more LUTs at 8 channels</strong> and <strong>11.2% at 16</strong>, plus six BRAM tiles. Timing still closes, with less margin. In exchange, all 64 DSPs at 8 channels and 128 at 16 disappear: firmware repeated addition replaces the hardware index-by-stride multipliers.</p><p>These FPGA implementation results are not ASIC area or power measurements. Utilization tables don’t measure programmability or maintainability.</p><h3>Context count is a latency/throughput knob</h3><p>I ran every scheduler-limit scenario with 4 and 8 contexts on the same 8-channel build and the same committed firmware. Four contexts mean two channel slots per hart; eight mean one. The current RTL doesn’t support two contexts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7_9cGMwpaTlUV9SQ.png" /></figure><p>With one busy channel, 4 contexts are <strong>34% faster</strong> than 8: the active hart gets an issue slot every four cycles rather than every eight. Turn on every channel and the answer flips. Now 4 contexts are <strong>17% slower</strong> because each hart must walk two slots. At 64 beats, it’s 16% slower. At 1 MB, the difference is one cycle.</p><p>The EXT rows expose a different wall. A base costs firmware about <strong>15–35 instructions</strong>, each taking N cycles in that context, while the hardware generator produces one per cycle. In the per-beat EXT scheduler test, 8 contexts take <strong>125×</strong> the FSM’s cycles. A bigger transfer won’t fix an operation that has to be produced at engine rate. That needs hardware assistance, not just more contexts.</p><h3>Firmware tricks that hide the latency</h3><p>The first working image wasn’t fast. We gained performance by changing <em>where</em> and <em>when</em> the firmware did its work.</p><p><strong>Pre-validate and pre-arm.</strong> The descriptor engine pre-fetches up to four descriptors ahead when the chain and FIFO space allow. STAGE_ARM stages and arms the next descriptor before its predecessor finishes. Without it, arming during the active descriptor takes about 25 instructions: 200 cycles at 8 contexts. The 64-beat sink-chain case drops from 672 clocks per descriptor to about 90 with the fast paths.</p><p><strong>Put the chained-head fast path in the poll.</strong> The one-slot loop tests HEAD_SUM first. The value 13 means an open, valid, chained head that isn&#39;t last, so firmware writes STAGE | STAGE_ARM | STAGE_ARM_NEXT immediately. Four instructions cover the read and command. This tight loop reduced the same chained-descriptor cost from about 288 clocks to about 90.</p><p><strong>Close the read race.</strong> A head can arrive between the HEAD_SUM and SUMMARY reads. Re-reading HEAD_SUM after SUMMARY shows attention ensures it&#39;s judged inline rather than falling into the slower service path. This correctness fix also prevents an avoidable latency cliff. Don&#39;t optimize the check away.</p><p><strong>Make idle cheap.</strong> A seven-instruction one-slot idle pass recovered a 1–2% dip on short eight-channel, single-descriptor points. With two slots per hart, reading SUMMARY first makes the idle pass two instructions.</p><p><strong>Specialize the two-slot loop.</strong> The firmware unrolls both slots and puts the chain hook in each slot’s branch. The final ordering reads SUMMARY first, then handles each slot that needs attention. On the 16-channel build, where eight harts each serve two slots, this reduced chained cost from <strong>184 to 103 clocks</strong> and improved the corresponding board measurement from <strong>1,122 to 2,008 MB/s</strong>. An earlier HEAD_SUM-first version alternated between 36- and 156-clock waits: catching the head early was better, but missing it sent the pass back through the slow path.</p><p><strong>Use table dispatch, not a branch ladder.</strong> After the poll, the step reads STATUS and indexes a 64-entry policy table with its six-bit state field. Four instructions reach any state&#39;s row. A handler makes one or two command writes and returns without re-reading STATUS or dispatching itself, so no handler holds a hart for several descriptors. The table links below 2 KB, eliminating a base register for its jump; the firmware generator rejects larger images. Every saved instruction saves N cycles for that channel.</p><p><strong>Keep handlers run-to-completion.</strong> Each poll gives at most one handler a slot. There’s no preemption, stack, or handler loop. That makes latency predictable and lets the other harts continue issuing.</p><p>These techniques hide control behind the in-flight descriptor and behind other channels. They don’t make an individual context issue faster than once per N cycles. Custom DMA instructions could provide a future EXT assist, but I’m not claiming a measured benefit for them here.</p><h3>Where the crossover lands</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XBXyYnFhP1d_vi2T.png" /></figure><p>After all that, where does firmware catch the FSM? The chart plots <strong>FSM cycles divided by rapids-g cycles</strong>, so 1.00 is parity and lower values are slower. All data are scheduler simulations with 32-byte beats.</p><p>The thresholds tell the practical story:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*keBlGx4KN5Tb3Km3.png" /></figure><p>These are <strong>bytes per descriptor</strong>, not per run. Chains overlap the next head with the active transfer, and multiple channels provide data movement behind which firmware can work. A lone descriptor has no advantage, so fixed firmware cost dominates longer.</p><p>That’s why “near parity on 1 MB” and “18× slower on one beat” aren’t contradictory. They’re opposite ends of the same amortization curve.</p><h3>Verification is part of the price</h3><p>Moving policy into firmware doesn’t eliminate verification; it changes what you have to verify. The firmware image is part of the hardware deliverable.</p><p>Rapids-g runs side-by-side equivalence tests against the FSM scheduler, comparing commands, monitor packets, and state transitions. It reuses the existing RAPIDS test suites, adds mutation tests for both firmware and RTL, and checks board runs against simulation cycle by cycle. The comparison also exposed and fixed two bugs in the original FSM implementation. I’ll happily take that result, but it shows a second implementation was useful, not that firmware is inherently easier to verify.</p><p>A barrel is phase-sensitive: when a faster scenario changes the starting phase of the next one, an A/B comparison can move without a code change. Isolated runs from the same cycle settle that question.</p><h3>When I would choose each</h3><p>I’d choose barrel-RV32I sequencing when descriptors or chains are large enough to amortize control work, several channels can keep the engines busy, and policy is expected to evolve. The deciding question is whether DSP removal and programmability justify more LUTs, BRAM, and firmware verification.</p><p>I’d keep an FSM, or add targeted hardware assist, when tiny descriptors dominate, lone-channel launch latency is a hard requirement, or an address pattern needs new bases at engine rate. The firmware toolchain and verification burden are real design costs, not secondary details.</p><p>The useful question isn’t “is a processor better than an FSM?” It’s <strong>how much control work each descriptor needs, how quickly that work must finish, and what can hide it?</strong> Sometimes the measured answer is firmware. Sometimes it’s an FSM. Often, it’s a deliberate split between the two.</p><h3>References</h3><ol><li>D. A. Patterson and J. L. Hennessy, <em>Computer Organization and Design, RISC-V Edition</em>, 2nd ed., Morgan Kaufmann, 2021. Section 6.4, “Hardware Multithreading.”</li><li>S. L. Harris and D. M. Harris, <em>Digital Design and Computer Architecture, RISC-V Edition</em>, Morgan Kaufmann, 2022. Section 7.7.7, “Multithreading.”</li><li>J. E. Thornton, “Parallel Operation in the Control Data 6600,” <em>Proceedings of the AFIPS Fall Joint Computer Conference, Part II</em>, 1964, pp. 33–40. The strict-rotation ancestor of the barrel organization.</li><li>B. J. Smith, “A Pipelined, Shared Resource MIMD Computer,” <em>Proceedings of the International Conference on Parallel Processing</em>, 1978, pp. 6–8. The Denelcor HEP and fine-grained interleaving.</li><li>H. F. Jordan, “Performance Measurements on HEP — A Pipelined MIMD Computer,” <em>Proceedings of the 10th International Symposium on Computer Architecture</em>, 1983, pp. 207–212. The single-thread latency versus aggregate-throughput trade.</li><li>G. Alverson, R. Alverson, D. Callahan, B. Koblenz, A. Porterfield, and B. Smith, “Exploiting Heterogeneous Parallelism on a Multithreaded Multiprocessor,” <em>Proceedings of Supercomputing </em>’92, 1992, pp. 188–197. The Tera MTA and high-context-count latency hiding.</li><li>P. Kongetira, K. Aingaran, and K. Olukotun, “Niagara: A 32-Way Multithreaded SPARC Processor,” <em>IEEE Micro</em>, 25(2), March-April 2005, pp. 21–29. A modern fine-grained implementation with stalled-thread skipping.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/rapids/docs/rapids_mas/ch05_rapids_g/01_overview.md">RAPIDS-G architecture</a>, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/rapids/docs/rapids_mas/ch05_rapids_g/03_sequencer_and_firmware.md">sequencer and firmware</a>, and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/dma-ip/rapids/docs/rapids_mas/ch05_rapids_g/05_verification_and_measurements.md">verification and measurements</a>. The implementation and all RAPIDS measurements used in this article.</li><li>RTL Design Sherpa, <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/riscv-ip/gatling-rv32i/docs/barrel_model/barrel_model.md">Gatling barrel model</a>, and <a href="https://github.com/sean-galloway/RTLDesignSherpa/blob/main/projects/components/riscv-ip/references/microarchitecture-papers.md">curated microarchitecture references</a>. Gatling’s design trade-offs and the historical sources above.</li></ol><p>From the <a href="https://github.com/sean-galloway/RTLDesignSherpa">RTLDesignSherpa</a> project ·<a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/feed.xml">RSS</a></p><p><em>Originally published at </em><a href="https://sean-galloway.github.io/RTLDesignSherpa/articles/dma-fsm-barrel-processor/"><em>https://sean-galloway.github.io</em></a><em> on October 28, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=986673c1802c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>