Learn

0/8
0/6
0/6
0/6

Practice

Snowmaking Monitor

A ski resort's snow cannons only pay off below a cutoff temperature, so the slope station works in signed whole °C. The forecast unit supplies the expected drift over the next hour. Your monitor predicts the next reading, measures how far the slope sits from the cutoff, and raises two flags. None of these results may ever wrap, whatever the inputs.

Interface

PortDirectionTypeDescription
temp_iin8-bit signedMeasured slope temperature
rise_iin8-bit signedForecast drift for the next hour (may be negative)
ref_iin8-bit signedSnowmaking cutoff temperature
next_oout9-bit signedPredicted temperature: temp_i + rise_i
dev_oout9-bit signedDistance from the cutoff: temp_iref_i
warm_oout1 bitHigh when temp_i is strictly above ref_i: pause the cannons
thaw_oout1 bitHigh when next_o is at or above 0 °C: the slope starts thawing

Behavior

  • next_o is the full 9-bit sum of temp_i and rise_i; extreme pairs like 100 + 90 or −100 + −90 must come out exact, never wrapped
  • dev_o is the full 9-bit difference temp_iref_i; extremes like 120 − (−120) = 240 must come out exact
  • warm_o is high exactly when temp_i > ref_i; at temp_i = ref_i it stays low
  • thaw_o is high exactly when next_o ≥ 0; a predicted 0 °C already counts as thawing
  • All comparisons are signed: −1 is below 0, not above 255. The testbench includes pairs that expose an unsigned misreading

Constraints

OPERATORS: only +, -, and relational operators; widen with resize.

  • One assignment outside a procedural block per output; no procedural blocks
  • Route each comparison with the '1' when ... else '0' recipe
Loading editor...

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