Entity: usbdev_linkstate

Diagram

clk_48mhz_i rst_ni us_tick_i usb_sense_i usb_dp_i usb_dn_i usb_oe_i rx_jjj_det_i sof_valid_i link_disconnect_o link_connect_o link_reset_o link_active_o link_suspend_o link_resume_o host_lost_o [2:0] link_state_o

Description

Copyright lowRISC contributors. Licensed under the Apache License, Version 2.0, see LICENSE for details. SPDX-License-Identifier: Apache-2.0

Link state detection

Ports

Port name Direction Type Description
clk_48mhz_i input
rst_ni input
us_tick_i input
usb_sense_i input
usb_dp_i input
usb_dn_i input
usb_oe_i input
rx_jjj_det_i input
sof_valid_i input
link_disconnect_o output level
link_connect_o output level
link_reset_o output level
link_active_o output level
link_suspend_o output level
link_resume_o output pulse
host_lost_o output level
link_state_o output [2:0]

Signals

Name Type Description
link_state_d link_state_e
link_state_q link_state_e
see_pwr_sense logic
link_rst_timer_d logic [2:0] Reset FSM
link_rst_timer_q logic [2:0] Reset FSM
link_rst_state_d link_rst_state_e
link_rst_state_q link_rst_state_e
link_reset logic reset detected (level)
monitor_inac logic monitor link inactivity
link_inac_timer_d logic [11:0]
link_inac_timer_q logic [11:0]
link_inac_state_d link_inac_state_e
link_inac_state_q link_inac_state_e
ev_bus_active logic Events that are not triggered by a timeout
ev_bus_inactive logic Events that are triggered by timeout
ev_reset logic Events that are triggered by timeout
see_se0 logic If the PHY reflects the line state on rx pins when the device is driving then the usb_oe_i check isn't needed here. But it seems best to do the check to be robust in the face of different PHY designs.
line_se0_raw logic If the PHY reflects the line state on rx pins when the device is driving then the usb_oe_i check isn't needed here. But it seems best to do the check to be robust in the face of different PHY designs.
host_presence_timer logic [12:0] /////////////////////// Host loss detection // /////////////////////// host_lost if no sof in 4.096ms (supposed to be every 1ms) and the link is active

Constants

Name Type Value Description
SUSPEND_TIMEOUT logic [11:0] 12'd3000 3ms by spec
RESET_TIMEOUT logic [2:0] 3'd3 3us. Can be 2.5us - 10ms by spec

Types

Name Type Description
link_state_e enum logic [2:0] {
LinkDisconnect = 0,
LinkPowered = 1,
LinkPoweredSuspend = 2,
LinkActive = 3,
LinkActiveNoSOF = 5,
LinkSuspend = 4 }
link_rst_state_e enum logic [1:0] {
NoRst,
RstCnt,
RstPend }
link_inac_state_e enum logic [1:0] {
Active,
InactCnt,
InactPend }

Processes

Type: always_comb

Type: always_ff

Type: always_comb

Description
/////////////////// Reset detection // /////////////////// Here we clean up the SE0 signal and generate a signle ev_reset at the end of a valid reset

Type: always_ff

Type: always_comb

Description
////////////////// Idle detection // ////////////////// Here we clean up the idle signal and generate a signle ev_bus_inactive after the timer expires

Type: always_ff

Type: always_ff

Instantiations

Description
four ticks is a bit time
Could completely filter out 2-cycle EOP SE0 here but
does not seem needed