Verilog practice / Problem 34
Sum of the last four samples
At each rising edge, capture the 8-bit input x. sum is the total of the four most recent captured values. Slots not yet filled since reset count as 0. The largest total is 4 × 255 = 1020, so sum has 10 bits.
Ports
| Name | Direction | Bits |
|---|---|---|
clk | input | 1 |
rst | input | 1 |
x | input | 8 |
sum | output | 10 |
How it's checked
Each cycle: the test sets the inputs, waits for your logic to settle, checks the outputs, then gives one rising clock edge. It holds rst high for the first two cycles and once more later on.
Stuck? Read the lesson Pipelining.
sum4.vCtrl + Enter runs