Commit Graph

165 Commits

Author SHA1 Message Date
Sean Anderson 2c2527e8d9 axis_replay_buffer: Fix slave handshaking
Handshaking happens on the rising edge based on the current values of
ready/valid. Fix the current (incorrect) logic. Additionally, modify the
testbench to properly stimulate AXI stream cores. This will catch
several handshaking failures fixed in previous commits.

Fixes: 52325f2 ("Add AXI stream replay buffer")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 14:30:27 -05:00
Sean Anderson 58cebe5ac2 uart_tx: Fix AXIS handshaking
AXI stream data is transferred based on the current values of the signals,
not the previous ones. This will cause problems if the other end isn't
valid all the time. Fix this, and amend the testbench to test it.

Fixes: e44d381 ("Add UART transmit module")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 14:30:07 -05:00
Sean Anderson 1bbb6d7f41 axis_wb_bridge: Fix wishbone handshaking
The wishbone transfer logic is incorrect. We need to use signals from the
current cycle, not the previous one.

Fixes: 7514231 ("Add AXIS-Wishbone bridge")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 14:30:05 -05: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 ec04874781 tb: phy_core: Make signal_status more robust
signal_status and must be low for a rising edge before it goes high. At
the moment we depend on ClockEnable to wait for a rising edge. Instead,
wait for a falling edge explicitly. This makes this test less
dependent on how tx_ce is generated.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 00:13:13 -05:00
Sean Anderson 19a588bd81 Makefile: Reduce cocotb width
Newer versions of cocotb have excessively-wide logging defaults. Reduce
it to something reasonable.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 00:03:49 -05:00
Sean Anderson 139baaffcf tb: Use correct width for Xs
In several cases, not the number of Xs did not match the number of bits.
Correct this.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-05 00:03:18 -05:00
Sean Anderson 601cccd3dc uart_rx: Add state machine debug
Add a textual description of the state machine for easier debugging.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 16:43:32 -05:00
Sean Anderson 067029ad3b uart_rx: Fix incorrect handshaking
AXI stream is transferred exactly on the rising edge of the clock. Use
the current value of the signals for this, instead of past values.
Simulate a slower slave to ensure this is tested.

Fixes: a549fca ("Add UART receive module")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 16:43:22 -05:00
Sean Anderson 10a4199381 axis_wb_bridge: Fix AXIS master
The AXI stream master doesn't cope with slaves that aren't ready all the
time. There are two separate issues: first, the data was only valid for one
cycle. Second, the handshake logic was incorrect. Rectify these, and modify
the testbench to test for this condition.

Fixes: 7514231 ("Add AXIS-Wishbone bridge")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 14:32:04 -05:00
Sean Anderson d2b4351899 axis_wb_bridge: Use DATA_WIDTH parameter
This was defined but left unused. Use it for the width of various
registers.

Fixes: 7514231 ("Add AXIS-Wishbone bridge")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 14:30:26 -05:00
Sean Anderson 587a567188 tb: uart_rx: Export putchar
This function is useful for other testbenches. Export it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 14:29:31 -05:00
Sean Anderson d89fd13238 tb: uart_tx: Check stop bit
Ensure that the stop bit is asserted at the end of each character.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 13:39:09 -05:00
Sean Anderson 7110eee136 tb: uart_tx: Export getchar
This function is useful for other testbenches. Export it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 13:38:38 -05:00
Sean Anderson d44c5b257e uart_tx: Add reset
Add a reset to match uart_rx.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 12:37:54 -05:00
Sean Anderson f09b89adeb phy_internal: Disable coltest without wishbone
When the wishbone management interface is disabled, disable coltest.

Fixes: b351beb ("Add hub")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 12:29:46 -05:00
Sean Anderson 3b49fedb6d mdio_regs: Simplify conditions
Instead of duplicating the cyc/stb condition everywhere, just reuse the
one from ack.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-04 12:28:34 -05:00
Sean Anderson 2b7e4f9f16 Add action to deploy documentation
This adds a basic action to deploy generated documentation.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-01 20:14:22 -05:00
Sean Anderson 75142311f2 Add AXIS-Wishbone bridge
This adds the core of the UART-Wishbone bridge. The protocol has
a variable-length address phase to help reduce overhead. Multiple
in-flight commands are not supported, although this could be resolved
with some FIFOs.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-01 20:14:22 -05:00
Sean Anderson 0f6d4b166f tb: mii_elastic_buffer: Remove unnecessary try/except
The value will be checked for Xs in the following comparison.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-01 19:19:31 -05:00
Sean Anderson bc78d56f05 tb: util: Use RisingEdge for ClockEnable
Signals modified by cocotb tasks may not be visible to other tasks on
the same clock cycle. This was causing issues for recv_packet, because
it might not see the same values for ready/valid driven by ClockEnable
that the DUT sees. This was worked around by sampling on the RisingEdge.
However, this can cause recv_packet to miss data. Fix this by using
RisingEdge for ClockEnable, so everything can be sampled on the
FallingEdge.

Fixes: 52325f2 ("Add AXI stream replay buffer")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-01 19:19:31 -05:00
Sean Anderson 69dd68822c tb: mdio: Export wb_read/write/err
These functions are useful for other testbenches. Export them so they
can be reused.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-03-01 19:19:31 -05:00
Sean Anderson a549fca957 Add UART receive module
Add the recieve half of the UART. It's more or less the inverse of the
transmit half, except we manage the state explicitly. I originally did
this in hopes that yosys would recode the FSM, but it doesn't like the
subtraction in the D* states. I left in the async reset anyway since it
reduces the LUT count.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-28 23:50:36 -05:00
Sean Anderson 3f61f85a1f tb: axis_mii_buffer: Export recv_packet
Export recv_packet for use by other testbenches. This is mostly
straightforward, except we need the ability to manually specify when
last should be asserted (to handle replays).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-28 22:26:05 -05:00
Sean Anderson e44d381c20 Add UART transmit module
I join everyone and their mother in creating my own UART. 8n1 only, and 2
baud rates. Accepts AXI-stream.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-28 22:26:05 -05:00
Sean Anderson 81de945030 Makefile: Silence warnings about array sensitivity
Icarus verilog complains if you are sensitive to every element in an
array:

rtl/mii_elastic_buffer.v:78: warning: @* is sensitive to all 5 words in array 'data'.

This makes sense if you intend to synthesize this array to a block RAM,
but not really if it's supposed to be registers. Silence this warning.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson e27d79b7c1 Add a README
It is high time to add some documentation.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson c5fc850587 Makefile: Define ICEPACK
This is necessary for creating bitstreams.

Fixes: 5cf02e9 ("Support building actual bitstreams")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson 165b60b7b2 Makefile: Add some missing modules
Add some modules to test with which were previously missing.

Fixes: b68e131 ("Add a basic hub")
Fixes: 0495ae3 ("Add TX MAC (most of it)")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson 45b134b1b2 Add examples
This adds an example of how to integrate the hub into a design. For the
moment, wishbone is disabled, but I plan to add a uart bridge in the
future.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson 8c0836406e Makefile: Make it easier to build files in other directories
Generally, most things (except .fst files) are independent of
directory. Fix up the few exceptions.
2023-02-20 23:34:10 -05:00
Sean Anderson dfd3d1f3b6 Add .bin to file extensions
Clean up/ignore .bin files.

Fixes: 5cf02e9 ("Support building actual bitstreams")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson 5f8c60518f Makefile: Make it easier to clean other directories
Create a list of extensions to clean, and then use wildcards to remove
the files. This will make it easier to clean other (nested) directories.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson f82fd2cac3 hub/phy_core: Export some status signals
Export some status signals which can be used for LEDs. Hopefully this
will deliver an authentic blinkenlights experience.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson b351beb9a0 Add hub
This adds a basic hub wrapper module which incorperates the core
introduced in b68e131 ("Add a basic hub"). For each port, it
instantiates a phy (itself using a phy_internal wrapper) and an elastic
buffer. A WISHBONE parameter is used to control whether to instantiate a
wishbone interface. When disabled, we just respond to any request with
err. I've ommitted a separate testbench for phy_internal, since it is
much easier to create a smoke test using the hub interface.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 23:34:10 -05:00
Sean Anderson cc29d2050c pmd_dp83223_rx: Don't use SB_IO for signal_detect
The flip-flops internal to the SB_IO can't have initial values and
can't be reset. So before the first clock the data out will be X. This
results in a simulation-synthesis mismatch, as sd_delay will be wrong
for one clock cycle. Fix this by removing the SB_IO cell, as the timing
of this signal isn't critical.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 18:39:58 -05:00
Sean Anderson 83d805bb79 tb: mdio_regs: Export wb_xfer
Convert xfer into a form which can be reused in other testbenches.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-20 18:39:58 -05:00
Sean Anderson fc3cce02ea Makefile: Retry P&R a few times
P&R can be a bit flakey. Retry a few times to get a good seed before
failing.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson 7c9ac42988 Add wishbone mux
This adds a simple wishbone mux. The idea is that each slave gets its
own address bit. This lends itself to extemely simple address decoding,
but uses up address space quickly. In theory, we could also give larger
addres space to some slaves, but currently lower bits have priority. The
testbench is also very simple. Since everything is combinatorial, we can
determine the outputs from the inputs exactly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson afbb64023e tb: Move BIT to util
This function may be useful for other testbenches.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson a179ccb9ab tb: hub_core: Remove references to Memory
This class is unused. Remove it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson 3b9efe2211 mii_elastic_buffer: Don't use memory access hack on valid/err
We can already probe the valid/err signals, so we don't need to
explicitly access them.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson eb8d854476 Silence warnings when converting memories to registers
There are several places where memories are used for parametrization
purposes, but I intend them to be synthesized to registers. Silence
warnings about them by explicitly annotating these variables.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson 0511de1e9c Makefile: Fix synthesis dependencies
Using -s /dev/stdin will add a dependency on it, and /dev/stdin is
always considered newer than the synthesis output. Just use multiple
-p options.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson d98e7b3adf Add LED blinker
This module will make it easier to observe internal signals which would
otherwise be too short to see, or would trigger too fast to distinguish.
Continuous triggered will cause blinking, so signals which are expected
to be high for a while (e.g. level-based and not edge-based) should not
use this module.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-18 22:48:36 -05:00
Sean Anderson 16b639aad2 Add MII elastic buffer
In order to move data between MIIs without implementing a MAC, we need
some kind of elastic buffer to bring the data into the transmit "clock
(enable) domain." Implement one. It's based on a classic shift-register
FIFO, with the main difference being the MII interfaces and the
elasticity (achieved by delaying asserting RX_DV until we reach the
WATERMARK). We use a register-based buffer because we only need to deal
with an under-/over-flow of 5 or so clocks for a 2000-byte packet. The
per-stage resource increase works out to 6 FFs and 1 LUT, which is
pretty much optimal.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-02-12 19:53:44 -05:00
Sean Anderson 5cf02e9490 Support building actual bitstreams
In addition to PNR-ing for per-module, post-placement simulation, we
also want to be able to do PNR for the purposes of generating a
bitstream. Refactor things a bit so we can (mostly) reuse the same
command line.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-22 16:26:35 -05:00
Sean Anderson b68e1312c4 Add a basic hub
This adds a basic clause 27 repeater (hub), mostly for test purposes.
It's effectively just the state machine in figure 27-4 and nothing else
(e.g. no partitioning or jabber detection). This is surprisingly simple.

Unfortunately, yosys doesn't allow memories in port declarations, even
for systemverilog. This complicates the implementation and testbench,
since we have to do the slicing ourselves. This is particularly awful
for the testbench, since

	module.signal[0].value != module.signal.value[0]

and module.signal can't be indexed by slices, and module.signal.value is
big endian (ugh ugh ugh). There is no clean solution here.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-01-21 17:39:25 -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