Repository navigation
Port fpga/vivado/uart_detect_top.v (Verilog, 1 module) to specs/port/fpga/vivado/uart_detect_top.t27 - #6534
Merged
Conversation
…art_detect_top.t27 module uart_detect_top: the LUT1 (INIT 2'b01, an inverter) ring step, the 23-bit counter, the two-flop RX synchroniser with falling-edge pulse count, the three output assigns, and an on_comb surface that gen-verilog lowers to a module of the same name. Edge sequences were cross-checked against the original under iverilog. Closes #4969 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 5, 2026
This was referenced Oct 5, 2026
Contributor
This was referenced Oct 5, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4969
Ports
fpga/vivado/uart_detect_top.v(46 lines, 1 module) tospecs/port/fpga/vivado/uart_detect_top.t27asmodule uart_detect_top { ... }. One file,.t27only.What the original computes, and where it is in the spec
LUT1 #(.INIT(2'b01)): O = INIT[I0], which is an inverterlut1(init, i0)chain[0] = ~chain[19],chain[i] = LUT1(chain[i-1])ring_step(chain)counter <= counter + 1(23 bits)counter_nextrx_sync <= rx; rx_prev <= rx_sync; if (rx_prev && !rx_sync) pulse_count++falling_edge,pulse_next,clock_edge(non-blocking: every RHS reads the old state)led_r23 = ~counter[20],led_t23 = pulse_count > 0 ? ~counter[19] : 1,uart_tx_pin = 1led_r23,led_t23,uart_tx_pin,outputson_comb(counter, pulse_count) -> u8, which packs the three output pinsAn honest note in the header comment: the ring has 20 inversions, an even number. In zero-delay logic the alternating pattern is therefore a fixed point (test
ring_has_a_fixed_point_in_zero_delay_logic). Whether the placed ring oscillates depends on routing delay, which this model does not carry.pulse_counthas no initialiser in the original, so the spec starts it at 0, the FPGA's GSR value.Cross-checked against the original
I simulated the original
.vunder iverilog with a behaviouralLUT1and a forcedosc. It gives the same values the spec's tests assert:rx = 1,1,0,0,0,1,1:pulse_countis 0, 0, 1 after 2, 3 and 4 edges, and 1 after 7 edges, with counter 7 and led_t23 1;rx = 1,0,0,1,1,0,0,1:pulse_countis 2.I also simulated the generated Verilog's
resultport for (counter, pulse_count) = (0,0), (0x100000,0), (0x080000,0), (0x080000,1) and (0x180000,2). It gives7 5 7 3 1, the same astest on_comb_packs_the_same_pins_as_outputs, andiverilog -g2012accepts the generated file.Acceptance criteria
These were run on the Railway t27c lab, with t27c built from origin/master e7afb32.
Negative control. I flipped three expectations (the pulse count after 4 edges, the LUT1 inverter output, and one
on_combvalue).test-reportthen printedpass 8, FAIL 3, naming those three tests.Two t27c defects I worked around (details on #4969)
testbody, the firstx = f(x);aftervar x : T = ...;is emitted to Zig asvar x = f(x);, which is a redeclaration and BLOCKs the build. Function bodies are unaffected. Workaround: the edge sequence is driven byrun_edges(a fn).gen-veriloglowersfn osc(chain: [20]bool) -> bool { return chain[19]; }with no input and a body ofosc = c2[19];, a name taken from the test call site, and iverilog rejects it. Workaround:osc = chain[19]is read inline.🤖 Generated with Claude Code