Skip to content

Commit

Permalink
clean package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fhaus1 committed Nov 26, 2024
1 parent f006f76 commit 622f954
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 92 deletions.
26 changes: 1 addition & 25 deletions hw/newusb/new_usb_dmaoutputqueueED.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,7 @@
// Todo: status bits functionality
// Todo: stashing for bulk control?

package new_usb_dmaoutputqueueED_pkg;

typedef struct packed {
struct packed {
logic [10:0] MPS; // 26:16
logic F; // 15
logic K; // 14
logic S; // 13
logic [12:11] D; // 12:11
logic [10:7] EN; // 10:7
logic [6:0] FA; // 6:0
} status;
struct packed {
logic [27:0] address; // 31:4
logic C; // 1
logic H; // 0
} headTD;
struct packed {
logic [27:0] address; // 31:4
} nextED;
} endpoint_descriptor;

endpackage

module new_usb_dmaoutputqueueED import new_usb_dmaoutputqueueED_pkg::*; #(
module new_usb_dmaoutputqueueED import new_usb_ohci_pkg::*; #(
parameter int unsigned AxiDataWidth = 0,
parameter int unsigned DmaOutputQueueStages = 0
)(
Expand Down
20 changes: 2 additions & 18 deletions hw/newusb/new_usb_dmaoutputqueueTD.sv
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,9 @@
//
/// Output queue of the DMA for general transfer descriptors 4x32 bit buffering for isochronous 8x32

Check warning on line 7 in hw/newusb/new_usb_dmaoutputqueueTD.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb/new_usb_dmaoutputqueueTD.sv#L7

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_dmaoutputqueueTD.sv" range:{start:{line:7 column:101}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:7 column:101} end:{line:8}} text:"/// Output queue of the DMA for general transfer descriptors 4x32 bit buffering for isochronous 8x32\n"}
/// Todo: implement ISOCHRONOUS
/// Todo: implement listservicing
/// Todo: implement listservicing TDs

package new_usb_dmaoutputqueueTD_pkg;

typedef struct packed {
struct packed {
logic [27:0] address;
} nextTD;
} gen_transfer_descriptor;

typedef struct packed {
struct packed {
logic [27:0] address;
} nextTD;
} iso_transfer_descriptor;

endpackage

module new_usb_dmaoutputqueueTD import new_usb_dmaoutputqueueTD_pkg::*; (
module new_usb_dmaoutputqueueTD import new_usb_ohci_pkg::*; (
/// control
input logic clk_i,
input logic rst_ni,
Expand Down
3 changes: 0 additions & 3 deletions hw/newusb/new_usb_listservice.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// dma init x axi
// HCAA


// Todo: implement interrupt done, back to nonperiodic
// if interrupt done do periodic_frame 0

module new_usb_listservice import new_usb_ohci_pkg::*; (

Expand Down
42 changes: 0 additions & 42 deletions hw/newusb/new_usb_ohci.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,6 @@
/// 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,
// because the package values need to update the configuration inside newusb_regs.hjson.
package new_usb_ohci_pkg;

typedef enum int unsigned {
OFF = 0,
GLOBAL = 1,
INDIVIDUAL = 2
} state_activate;

typedef enum int unsigned {
DISABLE = 0,
ENABLE = 1
} state_permit;

typedef enum logic [1:0] {
BULK = 2'b00,
CONTROL = 2'b01,
ISOCHRONOUS = 2'b10,
INTERRUPT = 2'11
} channel;

typedef enum logic [1:0] {
ED = 2'b00,
GENTD = 2'b01,
ISOTD = 2'b10
} store_type;

// OHCI supports between 1-15 ports
localparam int unsigned NumPhyPorts = 2;
localparam state_activate OverProtect = OFF; // no overcurrent protection implemented yet
localparam state_activate PowerSwitching = OFF; // no power switching implemented yet
localparam state_permit InterruptRouting = DISABLE; // no system management interrupt (SMI) implemented yet
localparam state_permit RemoteWakeup = DISABLE; // no remote wakeup implemented yet
localparam state_permit OwnershipChange = DISABLE; // no ownership change implemented yet
localparam int unsigned FifoDepthPort = 1024; // test value
localparam int unsigned DmaLength = 128; // test value

// Todo: Maybe Crc16 input Byte size parameter with selectable parallel/pipelined processing, lookup table?

endpackage

module new_usb_ohci import new_usb_ohci_pkg::*; #(
/// DMA manager port parameters
parameter int unsigned AxiMaxReads = 0,
Expand Down
79 changes: 79 additions & 0 deletions hw/newusb/new_usb_ohci_pkg.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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]>
//
/// Changes inside this package need to be confirmed with a make hw-all,
/// because the package parameter values need to update the configuration inside newusb_regs.hjson.

package new_usb_ohci_pkg;

typedef enum int unsigned {
OFF = 0,
GLOBAL = 1,
INDIVIDUAL = 2
} state_activate;

typedef enum int unsigned {
DISABLE = 0,
ENABLE = 1
} state_permit;

typedef enum logic [1:0] {
BULK = 2'b00,
CONTROL = 2'b01,
ISOCHRONOUS = 2'b10,
INTERRUPT = 2'11
} channel;

typedef enum logic [1:0] {
ED = 2'b00,
GENTD = 2'b01,
ISOTD = 2'b10
} store_type;

typedef struct packed {
struct packed {
logic [27:0] address;
} nextTD;
} gen_transfer_descriptor;

typedef struct packed {
struct packed {
logic [27:0] address;
} nextTD;
} iso_transfer_descriptor;

typedef struct packed {
struct packed {
logic [10:0] MPS; // 26:16
logic F; // 15
logic K; // 14
logic S; // 13
logic [12:11] D; // 12:11
logic [10:7] EN; // 10:7
logic [6:0] FA; // 6:0
} status;
struct packed {
logic [27:0] address; // 31:4
logic C; // 1
logic H; // 0
} headTD;
struct packed {
logic [27:0] address; // 31:4
} nextED;
} endpoint_descriptor;

localparam int unsigned NumPhyPorts = 2; // OHCI supports between 1-15 ports
localparam state_activate OverProtect = OFF; // no overcurrent protection implemented yet
localparam state_activate PowerSwitching = OFF; // no power switching implemented yet
localparam state_permit InterruptRouting = DISABLE; // no system management interrupt (SMI) implemented yet
localparam state_permit RemoteWakeup = DISABLE; // no remote wakeup implemented yet
localparam state_permit OwnershipChange = DISABLE; // no ownership change implemented yet
localparam int unsigned FifoDepthPort = 1024; // test value
localparam int unsigned DmaLength = 128; // test value

// Todo: Maybe Crc16 input Byte size parameter with selectable parallel/pipelined processing, lookup table?

endpackage
6 changes: 3 additions & 3 deletions hw/newusb/new_usb_unpackdescriptors.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// and sends the next linked addresses back to listservice.
/// The address field inside the secondinED in the two-stage queue is sent to listservice.
/// The address of the first ED gets written into the respective current ED register as
/// soon it starts being processed.
/// soon it has been processed, two cycles before pop.
/// The module takes firstinED in the queue and sends its first TD address to listservice.
/// After processing the TD, it proceds to the next ED.

Expand Down Expand Up @@ -74,7 +74,7 @@ import new_usb_ohci_pkg::*; import new_usb_dmaoutputqueueED_pkg::*; #(

/// Exit sequence: served_td -> processed -> newcurrentED -> pop
// processed
assign processed.headTD.address = nextTD;
assign processed.headTD.address = nextTD; //nextTD from servedTD
assign processed_store_type_o = ED; // Todo:derive from ID stack firstin
assign processed_ed_store_o = pop_very_early;
// Todo: halt
Expand Down Expand Up @@ -199,4 +199,4 @@ import new_usb_ohci_pkg::*; import new_usb_dmaoutputqueueED_pkg::*; #(
.served_td_o(served_td)
);

endmodule
endmodule
2 changes: 1 addition & 1 deletion hw/newusb_regs/newusb_insert_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def extract_localparams(filename):

return localparams

localparams = extract_localparams("hw/newusb/new_usb_ohci.sv")
localparams = extract_localparams("hw/newusb/new_usb_ohci_pkg.sv")
localparams_without_macros = replace_macros(localparams)

'''
Expand Down

0 comments on commit 622f954

Please sign in to comment.