Practice

Cutter Ramp Streamer

The blade head of a vinyl cutter cannot go from parked to cutting speed in one step; it tears the material. So every move starts with a ramp: 8 velocity words, streamed to the servo drive over a valid/ready handshake.

The previous implementation shipped to three customers before the field reports arrived. Ramps had missing steps or the same step twice, and one memorable unit drove the head into the rollers at full speed. The cause: whenever its buffer fills, the drive drops ready during the ramp, but the old source counted every word it presented as sent. The handshake rule it skipped is the one every datasheet states: a word transfers only on a cycle where valid and ready are both high. Until then, the source must hold valid high and keep the word rock steady.

Your task: build the source side, with the handshake done right. When the motion planner pulses go with a starting velocity on base, stream the 8 words base, base+1, ... base+7. Flag the final word with last, then go quiet.

Interface

PortDirectionTypeDescription
clkin1 bitClock
rstin1 bitSynchronous reset (active high)
goin1 bitStart pulse from the motion planner
basein8-bit vectorStarting velocity, captured when go is taken
readyin1 bitDrive can accept a word this cycle
validout1 bitWord on data is valid
dataout8-bit vectorVelocity word base + k (wraps mod 256)
lastout1 bitHigh while word 8 of 8 is presented

Behavior

  • Idle: valid = 0 and last = 0; data is meaningless and unchecked while valid = 0
  • go = 1 sampled at a clock edge while idle starts a burst: from the next cycle, valid = 1 and data = base as captured at that edge
  • A word transfers at each clock edge where valid = 1 and ready = 1; the next cycle presents the next word, data = base + k for word k (wrapping mod 256)
  • While valid = 1 and ready = 0, every output holds exactly: valid, data, and last must not change
  • last = 1 exactly while the eighth word (base + 7) is presented, stalled or not
  • After the eighth word transfers, the block returns to idle from the next cycle; a go on that first idle cycle starts a new burst
  • go is ignored whenever a burst is in progress; base changes mid-burst are ignored too
  • rst = 1 at a clock edge aborts everything: idle from the next cycle

What the bench checks

  • The testbench checks valid and last on every cycle and data on every cycle where valid should be 1
  • A full-rate burst must present eight consecutive values, assert last only on the eighth, then return to idle
  • Stalls on the first, middle, and final words must hold outputs steady; the stalled ramp also wraps from FF to 00
  • A new go pulse and changes to base during a burst must not alter that burst
  • Reset during a stalled burst must abort it immediately and keep the source idle afterward
  • A go held across the final transfer must be ignored there, then start the next burst from the following idle cycle

Constraints

TIMING

everything is synchronous to clk; outputs may only change at clock edges.

SCOPE

this models the source side of the handshake only. The servo drive and its buffer live behind ready, and the blade mechanics are out of scope.

The burst length is fixed at 8 and the word values are base + k mod 256, so no memory is involved.

Do not add ports.

Loading editor...

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