Loading simulator…
The provided controller generates:
Init_Load
Count_Enable
Hit_Enable
Busy
Done
The learner completes three main datapath sections.
Threshold Register
Use four storage bits to create:
Threshold_Reg[3:0]
Each bit must load the corresponding external Threshold bit when Init_Load = 1 and otherwise retain its current value.
For bit i:
Threshold_Next[i] =
Init_Load · Threshold[i]
+
Init_Load' · Threshold_Reg[i]
This ensures that the threshold is captured once at the beginning of the transaction and remains fixed while samples are processed.
Unsigned Comparator
Use a 4-bit unsigned magnitude comparator.
Connect:
Comparator A = Sample[3:0]
Comparator B = Threshold_Reg[3:0]
For a cascaded magnitude comparator, configure the equality input for a standalone comparison and disable the incoming greater-than and less-than conditions.
Use only the greater-than result:
GREATER = Sample > Threshold_Reg
Therefore:
Sample > Threshold_Reg → GREATER = 1
Sample = Threshold_Reg → GREATER = 0
Sample < Threshold_Reg → GREATER = 0
The provided controller uses this status together with Sample_Valid to determine whether the hit counter should advance.
Hit Counter
Use a 3-bit register:
Hit_Count[2:0]
and a 3-bit adder.
Form the increment operand as:
00 : Hit_Enable
Therefore:
Hit_Count_Next =
Hit_Count + (00 : Hit_Enable)
When:
Hit_Enable = 0
the counter holds.
When:
Hit_Enable = 1
the counter increments by one.
The 3-bit counter can therefore represent all possible results:
000 = 0 hits
001 = 1 hit
010 = 2 hits
011 = 3 hits
100 = 4 hits
The hit counter must also be cleared when a new transaction is initialized.
The completed datapath therefore performs:
Threshold capture
↓
Sample > Threshold_Reg
↓
GREATER
↓
provided controller
↓
Hit_Enable
↓
3-bit Hit_Count
The fourth valid sample is processed before the controller enters DONE, so it can still increment Hit_Count when it is greater than the stored threshold.