Commit Graph

11 Commits

Author SHA1 Message Date
Sean Anderson 599a2fce17 tb: axis_mii_tx: Simulate a longer reset
Simulate a reset lasting for at least once clock cycle to ensure our
external interfaces act sane.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-15 15:51:54 -04:00
Sean Anderson a5d1eff22b tb: axis_mii_tx: Fix failures on newer versions of cocotb
Since cocotb/cocotb#2793, writes happen before the clock instead of
after the clock. This breaks the collision test, since we test for
differing behavior over a difference of 1 ns. Fix the failure by
applying an adjustment for newer versions.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 13:26:35 -05:00
Sean Anderson 798968d3d6 axis_mii_tx: Add support for half duplex
This adds support for half-duplex. This is mostly done by predicating
col and crs on half_duplex. In one place we need to go to IPG_LATE
directly (although we could go to IPG_LATE like FCS with no loss of
standard compliance).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-14 00:08:38 -05:00
Sean Anderson 2fd6dedddb Fix failing tests due to floating point imprecision
get_sim_time can return floating point values. This will cause tests to
fail since there is an epsilon of error. Fix this by timing things in
steps (which is always an int).

Fixes: 0495ae3 ("Add TX MAC (most of it)")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-14 00:05:50 -05:00
Sean Anderson e59e34db93 tb: Fix reset occasionally failing
We might not release rst synchronously if clk was already high. Fix this
by forcing clk to z.

Fixes: 19f2f65 ("axis_mii_tx: Add reset")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-14 00:05:35 -05:00
Sean Anderson 01ff073916 tb: axis_mii_tx: Test one-cycle error
Ensure we transition properly even if buf_err is only high for one
cycle.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-11 17:31:42 -05:00
Sean Anderson 4746b3b6cd tb: axis_mii_tx: Test underflow rather than err with collision
If we ever see an error, we shouldn't retry if we get a collision at the
same time, as we will just have to jam next time. Test for this case
instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-11 17:27:35 -05:00
Sean Anderson a3ae038f4f tb: axis_mii_tx.py: Rework test_underflow
This test has a lot of duplication, which makes it harder to modify.
Stick most of it in a loop.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-11 17:26:20 -05:00
Sean Anderson 68751229a0 tb: axis_mii_tx: Forward keyword arguments to send_packet
This makes it easier to add additional arguments.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-11 17:25:52 -05:00
Sean Anderson 19f2f656cd axis_mii_tx: Add reset
Yosys doesn't optimize FSMs without resets. Add one so ours gets
optimized.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-10 23:56:04 -05:00
Sean Anderson 0495ae377c Add TX MAC (most of it)
This adds the transmit half of a MAC, supporting 100M and half-duplex.
It's roughly analogous to the axis_(x)gmii_tx modules in Alex
Forencich's ethernet repo. I've taken the approach of moving all state
into the state variable. All decisions are made once and have a
different state for each path. For example, instead of checking against
a "bytes_sent" variable to determine what to do on collision, we have a
different state for each set of actions.

This whole module is heinously complex, especially because of the many
corner cases caused by the spec. I have probably not tested it nearly
enough, but the basics of sending packets have mostly had the bugs wrung
out.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-09 21:05:31 -05:00