P11.4.1 Implement the Address Filter

EasyImplementIcarus Verilog · serverReview the topic

Decide for each destination address whether a station takes the frame, and why. Then sort Length/Type values.

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 MAC receiver looks at the first six octets of every frame. Most frames on a network are for someone else, and it must drop those.

Write addr_filter. It returns the reason a frame is accepted, or 0 for a drop. It also returns the two flag bits of the destination address.

Write lt_kind too. It says whether a Length/Type value is a length, a type or neither.

A filter that only knows its own address looks fine in a direct test. It fails as soon as the network sends a broadcast.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic [4:0] addr_filter(input [47:0] da, input [47:0] station, input [143:0] groups,
                                     input int n_groups, input bit multicast_en, input bit promiscuous);
// returns {local, group, reason[2:0]}
function automatic [1:0] lt_kind(input [15:0] lt);
ItemRule
Address formatThe first octet sent is bits 47 to 40. Each octet is sent low bit first.
groupThe first bit of the address on the wire.
localThe second bit of the address on the wire.
Reason 1da equals station.
Reason 2da is all ones. Broadcast is always accepted.
Reason 3multicast_en is 1, da is a group address, and da equals one of the first n_groups list entries.
Reason 4None of the above, and promiscuous is 1.
Reason 0Otherwise: drop.
groupsEntry i is groups[48*i +: 48]. n_groups is 0 to 3. Entries from n_groups up hold junk.
lt_kind0 for a length (0 to 1500), 1 for a type (1536 and up), 2 for the values between.

Report the first reason that applies, in the order 1, 2, 3, 4.

Examples

Example 1

The Station Address
Input
the destination equals the station address
Output
reason = own address (1), group = no, local = yes

Reason 1. The first octet 0Ah is even, so the group bit is 0. Its bit 1 is 1, so the address is local.

Example 2

Broadcast
Input
all ones, with multicast reception disabled
Output
reason = broadcast (2), group = yes, local = yes

Broadcast does not depend on the multicast switch. Both flag bits are 1.

Example 3

A Group on the List
Input
the first list entry
Output
reason = group list (3), group = yes, local = no

The first octet 01h is odd, so this is a group address. It equals list entry 0 and multicast reception is on.

Constraints and Contract

  • Keep both function names, their arguments and their result widths.
  • The station address is always an individual address.
  • A list entry that is not a group address never matches.
  • Off limits: the names lib, rng, tb, root and the modules of the bench.

Hints

Hint 1

Which bit of the 48-bit input is the first bit on the wire? Write the first octet in binary and send it low bit first.

Hint 2

Handle the reasons in order and stop at the first that applies. Promiscuous mode is the last resort, not the first test.

Hint 3

For the list, loop over n_groups entries only. The unused entries can equal anything.

What the grader checks: The fixture checks eight fixed cases, 800 random addresses against the bench filter and all 65,536 Length/Type values. It does not test more than three list entries or hashed group filters.

11 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

The Station Address

Input
the destination equals the station address
Expected output
reason = own address (1), group = no, local = yes

Reason 1. The first octet 0Ah is even, so the group bit is 0. Its bit 1 is 1, so the address is local.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus Verilog · server