Practice

Spore Room Airlock

Fenwood Farm grows oyster mushrooms in a sealed grow room. Workers pass between the prep room and the grow room through a two-door airlock. Each side has a call button, and the controller may release only one door at a time. Between one door relocking and the other releasing, a fan gets 1 full cycle to flush the lock. That gap is what keeps wild spores out of the clean side.

Last Tuesday, in the harvest rush, both buttons were pressed in the same moment. Both doors released together, the fan never got its gap, and a full rack of spawn was lost to contamination. The vendor's bench for the controller is already in your rig, and it passes. It tries each door alone, and the two doors queued, but never the double press.

Your task: extend the vendor's bench so the fault shows. Keep the vendor's tests. Add the harvest-rush case: req_a and req_b rising before the same locked-door edge, plus check_doors calls that pin what the spec demands from that moment on.

Interface

PortDirectionTypeDescription
clkin1 bitClock
rstin1 bitSynchronous reset (active high)
req_ain1 bitCall button, prep-room side (level, held)
req_bin1 bitCall button, grow-room side (level, held)
unlock_aout1 bitDoor A release (registered)
unlock_bout1 bitDoor B release (registered)

Behavior (the spec the controller claims to meet)

  • Out of reset, both doors are locked: unlock_a = 0, unlock_b = 0
  • With both doors locked, req_a = 1 at a rising edge releases door A the next cycle, whatever req_b carries. On a tie, the prep side wins
  • With both doors locked, req_a = 0 and req_b = 1 at the edge releases door B the next cycle
  • A released door stays released while its request is held, and relocks the cycle after its request reads 0 at an edge
  • While one door is released, the other side waits. After the relock, both doors stay locked for 1 full cycle (the fan flush), then the waiting side may release
  • The two doors are never released in the same cycle
  • rst = 1 at a rising edge locks both doors, whatever the requests carry

What the bench checks

  • The grading bench (the read-only testbench tab) runs your bench inside it and audits every check_doors call against its own model of the spec
  • Every pair of expected doors must match the spec model at the instant of the check
  • At least 1 check must catch the shipped controller holding doors the spec model does not
  • Your bench must drive door A alone, door B alone, and both requests high at the same locked-door edge
  • At least 8 checks must run, none before rst has been high through a rising edge
  • The run ends when your bench sets tb_done; a stalled bench times out and fails

Constraints

TIMING

the controller is synchronous to clk, and both unlock outputs are registered: each effect shows the cycle after its edge.

SCOPE

the deliverable is the extended bench, not a controller fix; airlock_ctrl stays as shipped. The door hardware and the flush fan itself are out of scope.

GIVENS

keep the given signal names, the dut instance and the check_doors check helper exactly as they are. The grader finds them by name.

DO NOT MODIFY

airlock_ctrl. The farm needs the fault demonstrated, not painted over.

  • Keep the vendor's directed tests in place: the grader still requires the solo-door coverage they provide
  • Report mismatches only through check_doors. The grader owns the verdict, so never print the word FAIL yourself

Do not add ports.

Loading editor...

Click Run to execute your code. Output will appear here.