A sampling clock occasionally skips a reading. Remember selected rising and falling edges until software acknowledges each pin.
Hardware context: ap_soc 16-pin GPIO bank. Board bring-up and interrupt-driven I/O
A sampling clock occasionally skips a reading. Remember selected rising and falling edges until software acknowledges each pin.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
port_clk | 1 | stimulus, the same for every design |
port_rst_n | 1 | stimulus, the same for every design |
port_valid | 1 | stimulus, the same for every design |
port_pins | 16 | stimulus, the same for every design |
port_rise_en | 16 | stimulus, the same for every design |
port_fall_en | 16 | stimulus, the same for every design |
port_ack | 16 | stimulus, the same for every design |
port_pending | 16 | stimulus, the same for every design |
Full specification
pins already contains synchronized levels. On valid edges compare with the previous valid sample. Save that sample even when both trigger masks are zero.
A per-pin rise_en bit enables a low-to-high transition. fall_en enables a high-to-low transition. Both may be set.
On every clock, each ack bit clears its pending bit unless that pin has a fresh enabled transition. Reset clears the history and pending bits.
Examples
Example 1
Reset History- Input
rst_n=1'h0, valid=1'h1, pins=16'h0000, rise_en=16'hffff, fall_en=16'hffff, ack=16'hffff
- Output
pending = 0x0
Reset starts every previous sample low.
Example 2
Two Rising Pins- Input
rst_n=1'h1, valid=1'h1, pins=16'h8002, rise_en=16'hffff, fall_en=16'h0000, ack=16'h0000
- Output
pending = 0x8002
Pins 15 and 1 both enter pending.
Example 3
Clear Meets a Falling Edge- Input
rst_n=1'h1, valid=1'h1, pins=16'h0000, rise_en=16'h0000, fall_en=16'h0002, ack=16'h8002
- Output
pending = 0x2
Pin 1 has a new event on its clear edge.
Constraints and Contract
- Sample on each rising edge. Synchronous active-low reset wins over all other inputs. Binary inputs only.
Hints
Hint 1
Mark the last valid sample.
Hint 2
Draw separate masks for each transition direction.
Hint 3
Compare a fresh event with an acknowledgment on that same pin.
What the grader checks: Single-pin trials cover every position. Mixed words vary direction, acknowledgment, validity and history.
503 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 3 problems on this path