Design a positive-edge–triggered T flip-flop with active-high asynchronous reset and preset. Reset dominates preset; preset forces Q=1 only when reset is inactive.
Requirements
- Module:
t_ff_async_pr - Ports:
- Functional behavior (priority)
RST=1 → Q=0 immediately.- else
PRE=1 → Q=1 immediately. - else on
posedge CLK:
- Modeling constraints
- Use
always @() with nonblocking assignments (<=). - Encode priority:
RST > PRE > toggle/hold.
Behaviour / Worked Example
From Q=0:
PRE↑ (with RST=0) → Q=1RST↑ → Q=0 (reset dominates)RST=0, PRE=0, T=1 at edge → Q=1 (toggle)T=0 at edge → Q=1 (hold)