Skip to content

Commit

Permalink
new_usb added (empty shell)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhaus1 committed Oct 29, 2024
1 parent df893ce commit 5cc41fb
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 20 deletions.
1 change: 1 addition & 0 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sources:
- hw/regs/cheshire_reg_top.sv
- hw/newusb_regs/newusb_reg_pkg.sv
- hw/newusb_regs/newusb_reg_top.sv
- hw/newusb/new_usb_ohci.sv
- hw/cheshire_pkg.sv
- hw/cheshire_soc.sv

Expand Down
1 change: 1 addition & 0 deletions hw/cheshire_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ package cheshire_pkg;
localparam int unsigned SlinkMaxClkDiv = 1 << serial_link_single_channel_reg_pkg::Log2MaxClkDiv;
localparam int unsigned ClintNumCores = clint_reg_pkg::NumCores;
localparam int unsigned UsbNumPorts = spinal_usb_ohci_pkg::NumPhyPorts;
localparam int unsigned NewUsbNumPorts = new_usb_ohci_pkg::NumPhyPorts;

// Default JTAG ID code type
typedef struct packed {
Expand Down
87 changes: 67 additions & 20 deletions hw/cheshire_soc.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1718,36 +1718,83 @@ module cheshire_soc import cheshire_pkg::*; #(
///////////////
// New USB //
///////////////

Check warning on line 1721 in hw/cheshire_soc.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/cheshire_soc.sv#L1721

Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces]
Raw output
message:"Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces]"  location:{path:"hw/cheshire_soc.sv"  range:{start:{line:1721  column:1}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}  suggestions:{range:{start:{line:1721  column:1}  end:{line:1722}}  text:"\n"}
if (Cfg.NewUsb) begin : gen_new_usb

// TODO: USB has no internal error handling, so it should have a bus error unit.

newusb_reg_top #(
.reg_req_t ( reg_req_t ),
.reg_rsp_t ( reg_rsp_t )
) i_regs (
.clk_i,
.rst_ni,
.reg_req_i ( reg_out_req[RegOut.new_usb] ),
.reg_rsp_o ( reg_out_rsp[RegOut.new_usb] ),
.reg2hw ( /* NC */ ),
.hw2reg ( '0 ),
.devmode_i ( 1'b1 )
new_usb_ohci #(
.AxiMaxReads ( Cfg.UsbDmaMaxReads ),
.AxiAddrWidth ( Cfg.AddrWidth ),
.AxiDataWidth ( Cfg.AxiDataWidth ),
.AxiIdWidth ( Cfg.AxiMstIdWidth ),
.AxiUserWidth ( Cfg.AxiUserWidth ),
.AxiId ( '0 ),
.AxiUser ( Cfg.AxiUserDefault ),
.AxiAddrDomain ( Cfg.UsbAddrDomain ),
.AxiAddrMask ( Cfg.UsbAddrMask ),
.reg_req_t ( reg_req_t ),
.reg_rsp_t ( reg_rsp_t ),
.axi_req_t ( axi_mst_req_t ),
.axi_rsp_t ( axi_mst_rsp_t )
) i_new_usb_ohci (
.soc_clk_i ( clk_i ),
.soc_rst_ni ( rst_ni ),
.ctrl_req_i ( reg_out_req[RegOut.new_usb] ),
.ctrl_rsp_o ( reg_out_rsp[RegOut.new_usb] ),
.dma_req_o ( axi_in_req[AxiIn.new_usb] ),
.dma_rsp_i ( axi_in_rsp[AxiIn.new_usb] ),
.intr_o ( intr.intn.usb ),
.phy_clk_i ( usb_clk_i ),
.phy_rst_ni ( usb_rst_ni ),
.phy_dm_i ( usb_dm_i ),
.phy_dm_o ( usb_dm_o ),
.phy_dm_oe_o ( usb_dm_oe_o ),
.phy_dp_i ( usb_dp_i ),
.phy_dp_o ( usb_dp_o ),
.phy_dp_oe_o ( usb_dp_oe_o )
);

// DMA port tied-off
assign axi_in_req[AxiIn.new_usb] = '0;

// IRQ tied-off
assign intr.intn.new_usb = '0;
end else begin : gen_no_usb

end else begin : gen_no_new_usb
assign usb_dm_o = '0;
assign usb_dm_oe_o = '0;
assign usb_dp_o = '0;
assign usb_dp_oe_o = '0;

// tie-off other signals (USB PHY, IRQs)
assign intr.intn.new_usb = '0;
assign intr.intn.new_usb = 0;

end

//if (Cfg.NewUsb) begin : gen_new_usb
//
//
// newusb_reg_top #(
// .reg_req_t ( reg_req_t ),
// .reg_rsp_t ( reg_rsp_t )
// ) i_regs (
// .clk_i,
// .rst_ni,
// .reg_req_i ( reg_out_req[RegOut.new_usb] ), //SW HCD
// .reg_rsp_o ( reg_out_rsp[RegOut.new_usb] ), //SW HCD
// .reg2hw ( /* NC */ ), //HW HC
// .hw2reg ( '0 ), //HW HC
// .devmode_i ( 1'b1 )
// );
//
// // DMA port tied-off
// assign axi_in_req[AxiIn.new_usb] = '0;
//
// // IRQ tied-off
// assign intr.intn.new_usb = '0;
//
//end else begin : gen_no_new_usb
//
// // tie-off other signals (USB PHY, IRQs)
// assign intr.intn.new_usb = '0;
//
//end

//////////////////
// Assertions //
//////////////////
Expand Down
96 changes: 96 additions & 0 deletions hw/newusb/new_usb_ohci.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2024 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

// Fabian Hauser <[email protected]>

/// Main module for the direct SystemVerilog New USB OHCI, configured for AXI4 buses.
/// The config port is adapted to 32b Regbus, the DMA port to parametric AXI4.
/// The IOs are bundled into PULP structs and arrays to simplify connection.


// Changes inside this package need to be confirmed with a make hw-all,

Check warning on line 12 in hw/newusb/new_usb_ohci.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb/new_usb_ohci.sv#L12

Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces]
Raw output
message:"Remove trailing spaces. [Style: trailing-spaces] [no-trailing-spaces]"  location:{path:"hw/newusb/new_usb_ohci.sv"  range:{start:{line:12  column:72}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}  suggestions:{range:{start:{line:12  column:72}  end:{line:13}}  text:"// Changes inside this package need to be confirmed with a make hw-all,\n"}
// because the package values need to influence the configuration inside newusb_regs.hjson.
package new_usb_ohci_pkg;

Check warning on line 14 in hw/newusb/new_usb_ohci.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb/new_usb_ohci.sv#L14

Package declaration name must match the file name (ignoring optional "_pkg" file name suffix). declaration: "new_usb_ohci_pkg" vs. basename(file): "new_usb_ohci" [Style: file-names] [package-filename]
Raw output
message:"Package declaration name must match the file name (ignoring optional \"_pkg\" file name suffix).  declaration: \"new_usb_ohci_pkg\" vs. basename(file): \"new_usb_ohci\" [Style: file-names] [package-filename]"  location:{path:"hw/newusb/new_usb_ohci.sv"  range:{start:{line:14  column:9}}}  severity:WARNING  source:{name:"verible-verilog-lint"  url:"https://github.com/chipsalliance/verible"}
//Supports between 1-15 ports
localparam int unsigned NumPhyPorts = 8;
//To Do: Overcurrent protection global/individual
// 0: off
// 1: global
// 2: individual
//To Do: Power switching protection global/individual
// 0: off
// 1: global
// 2: individual
//To Do: Fifodepth
//To Do: Usb Dmalength
//To Do: Beats per Dmalength
//To Do: words per Beat
endpackage

module new_usb_ohci import new_usb_ohci_pkg::*; #(
/// DMA manager port parameters
parameter int unsigned AxiMaxReads = 0,
parameter int unsigned AxiAddrWidth = 0,
parameter int unsigned AxiDataWidth = 0,
parameter int unsigned AxiIdWidth = 0,
parameter int unsigned AxiUserWidth = 0,
/// The current controller can only address a 32b address space.
/// This parameter can statically add a domain and mask for the lower bits.
parameter logic [AxiAddrWidth-1:0] AxiAddrDomain = '0,
parameter logic [AxiAddrWidth-1:0] AxiAddrMask = 'hFFFF_FFFF,
/// Default User and ID presented on DMA manager AR, AW, W channels.
/// In most systems, these can or should be left at '0.
parameter logic [AxiIdWidth-1:0] AxiId = '0,
parameter logic [AxiUserWidth-1:0] AxiUser = '0,
/// SoC interface types
parameter type reg_req_t = logic,
parameter type reg_rsp_t = logic,
parameter type axi_req_t = logic,
parameter type axi_rsp_t = logic
) (
/// SoC clock and reset
input logic soc_clk_i,
input logic soc_rst_ni,
/// Control subordinate port
input reg_req_t ctrl_req_i,
output reg_rsp_t ctrl_rsp_o,
/// DMA manager port
output axi_req_t dma_req_o,
input axi_rsp_t dma_rsp_i,
/// Interrupt
output logic intr_o,
/// PHY clock and reset
input logic phy_clk_i,
input logic phy_rst_ni,
/// PHY IO
input logic [NumPhyPorts-1:0] phy_dm_i,
output logic [NumPhyPorts-1:0] phy_dm_o,
output logic [NumPhyPorts-1:0] phy_dm_oe_o,
input logic [NumPhyPorts-1:0] phy_dp_i,
output logic [NumPhyPorts-1:0] phy_dp_o,
output logic [NumPhyPorts-1:0] phy_dp_oe_o
);

newusb_reg_top #(
.reg_req_t ( reg_req_t ),
.reg_rsp_t ( reg_rsp_t )
) i_regs (
.clk_i ( soc_clk_i ),
.rst_ni ( soc_rst_ni ),
.reg_req_i ( ctrl_req_i ), //SW HCD
.reg_rsp_o ( ctrl_rsp_o ), //SW HCD
.reg2hw ( /* NC */ ), //HW HC
.hw2reg ( '0 ), //HW HC
.devmode_i ( 1'b1 )
);

assign dma_req_o = '0;
// IRQ tied-off
assign intr_o = '0;

// assign usb_dm_o = '0;
// assign usb_dm_oe_o = '0;
// assign usb_dp_o = '0;
// assign usb_dp_oe_o = '0;
endmodule

0 comments on commit 5cc41fb

Please sign in to comment.