P11.45.1 Set the Guard Band

MediumImplementIcarus Verilog · serverReview the topic

A gate will close in 200 octet times, and a frame of 190 octets is waiting. May it start? Write the rule that keeps a frame from running into the next window.

Hardware context: An Ethernet MAC and physical coding sublayer: frame builder and checker, reconciliation sublayer and block encoder. Build, check and pace Ethernet frames, and code them for the physical layer as IEEE 802.3 specifies.

A port has two queues, and each has a transmission gate. A gate control list opens and closes them in a cycle.

Write five functions about one such list. All of them take the list, its length and the cycle time.

gates_at gives the two gates at a time t. It follows the List Execute state machine.

until_close gives the time from t to the next gate-close event of one queue.

may_start is the rule of 8.6.8.4: a frame is available only if it can end before that event.

next_start gives the first time from t on at which the frame may start.

overruns tells what happens without the rule: is the frame still on the line when the gate closes?

This is a model. Time is in ticks, and one tick is one octet time. The standard counts in nanoseconds.

The list never changes here: there is no List Config machine. Every cycle is like the first.

Course choices: the list is packed into one vector, and the codes -1 and -2 are ours.

The lesson has a readable stepper, eth_gcl. You may port it. It is slow if you run it for every call.

Time budget: the tests make 1,351 calls, on cycles of up to 500 ticks. Work from the list where you can.

One loop over the ticks of a cycle in a call is fine. Such a loop inside another one will run out of time.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic [1:0] gates_at(input [143:0] list, input int len, input int cycle, input int t);
function automatic int until_close(input [143:0] list, input int len, input int cycle, input int q, input int t);
function automatic bit may_start(input [143:0] list, input int len, input int cycle, input int q, input int t, input int octets);
function automatic int next_start(input [143:0] list, input int len, input int cycle, input int q, input int t, input int octets);
function automatic bit overruns(input [143:0] list, input int len, input int cycle, input int q, input int t, input int octets);
ItemRule
listentry k is bits 18k +: 18. Bits 15:0: TimeInterval in ticks. Bit 16: the gate of queue 0. Bit 17: the gate of queue 1. 1 is open
len, cycle1 to 8 entries. The cycle time is 1 to 500 ticks
tticks since a cycle start. It may be many cycles on
A cycle (Figure 8-20)entry 0 is executed at the cycle start. The next entry follows when the TimeInterval has run out
TimeInterval 0counts as 1 (8.6.9.2.1)
After the last entrythe gates stay as they are until the next cycle starts
A cycle that ends earlythe entries that were not reached are not executed. The next cycle starts with entry 0
Gate-close eventa gate that was open is closed by an entry. Executing an entry that leaves the gate as it is, is no event (Table 8-7)
gates_atbit q is the gate of queue q during tick t
until_closethe gate is closed at t: -1. It never closes: -2. Else the ticks from t to the tick of the next gate-close event
may_startthe gate is open, and the frame with its overhead ends no later than the gate-close event (8.6.8.4)
Overhead (12.4.2.2)20 octets on Ethernet: 7 of preamble and the SFD before the frame, a gap of 12 after it
octetsthe frame, from the destination address to the FCS. It takes one tick for each octet
next_startthe smallest time from t on at which may_start holds. -1 if there is none
overrunsthe frame starts at t, with its preamble. 1 if the gate closes while preamble, SFD or frame are still sent (12.29.1.1.2)
overruns, gate closed0: the frame does not start

Random tests compare each function with a private model.

Examples

Example 1

How Long Until the Gate Closes?
Input
queue 0 is open from tick 100 to the end of the cycle of 500; now it is tick 300
Output
ticks_to_close = 200

The gate closes when the next cycle starts: 200 ticks from now.

Example 2

A Frame That Fits, and One That Does Not
Input
180 and 181 octets at tick 300
Output
may_start = 1
may_start = 0

180 octets and 20 of overhead are 200 ticks: they end at the event. One octet more does not fit.

Example 3

When May It Start, and What If It Starts Now?
Input
181 octets at tick 300
Output
start_time = 600
overruns = 0

The frame waits for the next window of queue 0, at tick 600. Started now, its last octet is sent in tick 488: no overrun.

Constraints and Contract

  • Keep the five names and their arguments.
  • A call must not depend on the calls before it.
  • You may add helper functions and variables.
  • Declare your variables at the top of a function, not inside a loop, and do not return from inside a loop.
  • Do not call a variable cell, use, before or cross: they are reserved keywords of SystemVerilog (IEEE 1800 Annex B).
  • Off limits: the names ref_t, rng, tb, root, names that begin with fx_ and the modules of the bench.
  • The fixture's own names are off limits to keep an answer from reading the expected values.

Hints

Hint 1

Write down where each entry starts in the cycle. Which entries are never reached?

Hint 2

The gate is open in the last entry and in entry 0. Is there a gate-close event at the cycle start?

Hint 3

A frame ends exactly at the gate-close event. Does it fit?

Hint 4

A frame does not fit now. Can it fit one tick later, in the same window?

Hint 5

For overruns, which of the 20 octets of overhead are sent before the frame, and which are not sent at all?

Hint 6

A loop over every tick of a cycle is fine once in a call. A loop inside such a loop may run out of time.

What the grader checks: A bench model in ticks of one octet time, for a list that never changes. Fifty-one scripted calls take their expected values from a JavaScript model that looks at every tick. Five more tests compare the five functions with a private model, on random lists seeded by the judge. That is 1,351 calls in all. The packed list and the codes -1 and -2 are course choices. The List Config machine, time in nanoseconds, more than two queues, Set-And-Hold-MAC, queueMaxSDU and the selection between queues are not graded.

56 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

How Long Until the Gate Closes?

Input
queue 0 is open from tick 100 to the end of the cycle of 500; now it is tick 300
Expected output
ticks_to_close = 200

The gate closes when the next cycle starts: 200 ticks from now.

Run samples executes all 5 public checks. Check all tests runs 56 checks on the server.

Icarus Verilog · server