Skip to content

Commit

Permalink
load testbench memory
Browse files Browse the repository at this point in the history
  • Loading branch information
fhaus1 committed Nov 29, 2024
1 parent cdc75e7 commit b7cd0fa
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 2,815 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ target/sim/vsim/modelsim.ini
target/sim/vsim/transcript
target/sim/vsim/vsim.wlf
target/sim/vsim/work/
target/sim/vsim/work_newusb/

# Xilinx generated files
target/xilinx/build
Expand Down
18 changes: 18 additions & 0 deletions hw/newusb_tb/new_usb_tb.mem
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2022 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]>
//
/// Address memory map for the testbench. The system has byte-addressable memory.
/// All descriptors are 16-byte aligned, except isochronous TDs are 32-byte aligned.
/// All values are in hexadecimal and will be stored LsB first.
/// Isochrounous TDs need to be loaded in two separate lines.
/// Use the python script to generate connected EDs and TDs linked lists
/// and insert them down below.
///
/// Format: @Address dword0 dword1 dword2 dword3
/// Size: (Address AxiAddrWidth) (dword 32bit)

@0000A000 0000000A 0000000B 0000000C 0000000D
@0000ABCD 00000001 00000002 00000003 00000004
171 changes: 119 additions & 52 deletions hw/newusb_tb/new_usb_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,136 @@
// Fabian Hauser <[email protected]>
//
/// Testbench module for the direct SystemVerilog NewUSB OHCI.
/// The config port from new_usb_ohci is adapted to 32b Regbus, the DMA port to parametric AXI4.
/// The regbus is attached to a regbus driver to simulate the CPU.
/// The AXI4 is attached to the testbench memory axi_sim_mem, which loads test.mem.
/// The config port from new_usb_ohci is setup as a 32b Regbus slave, the DMA port as an AXI Lite master.
/// The regbus slave is attached to a regbus driver to simulate the system master.
/// The AXI Lite master (via a converter now a AXI4 master) is attached to the testbench memory axi_sim_mem, which loads .mem.

module new_usb_tb import new_usb_ohci_pkg::*; #(
/// parameters
`timescale 1ps/1ps

module new_usb_tb #(
/// DMA manager port parameters
parameter int unsigned AxiMaxReads = 0,
parameter int unsigned AxiAddrWidth = 32,
parameter int unsigned AxiDataWidth = 32, // 32|64|128 causes 4|2|1 stages in the dmaoutputqueueED

Check warning on line 18 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L18

Line length exceeds max: 100; is: 101 [Style: line-length] [line-length]
Raw output
message:"Line length exceeds max: 100; is: 101 [Style: line-length] [line-length]" location:{path:"hw/newusb_tb/new_usb_tb.sv" range:{start:{line:18 column:101}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
parameter int unsigned AxiIdWidth = 0,
parameter int unsigned AxiUserWidth = 0,
/// 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,
);



logic [AxiAddrWidth-1:0] address;
logic [31:0] dword [3:0];

Check warning on line 39 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L39

Unpacked dimension range must be declared in big-endian ([0:N-1]) order. Declare zero-based big-endian unpacked dimensions sized as [N]. [Style: unpacked-ordering] [unpacked-dimensions-range-ordering]
Raw output
message:"Unpacked dimension range must be declared in big-endian ([0:N-1]) order.  Declare zero-based big-endian unpacked dimensions sized as [N]. [Style: unpacked-ordering] [unpacked-dimensions-range-ordering]" location:{path:"hw/newusb_tb/new_usb_tb.sv" range:{start:{line:39 column:21}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
reg [7:0] mem [logic [AxiAddrWidth-1:0]];
integer file, status, i, j;
string line;

initial begin
$readmemh("new_usb_tb_mem.mem", i_axi_sim_mem.mem);
end

Check warning on line 45 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L45

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_tb/new_usb_tb.sv" range:{start:{line:45 column:1}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:45 column:1} end:{line:46}} text:"\n"}
file = $fopen("../../../hw/newusb_tb/new_usb_tb.mem", "r");
if (file == 0) begin
$display("Failed to open file.");
$finish;
end

new_usb_ohci #(
/// DMA manager port parameters
.AxiMaxReads(),
.AxiAddrWidth(),
.AxiDataWidth(), // 32|64|128 causes 4|2|1 stages in the dmaoutputqueueED
.AxiIdWidth(),
.AxiUserWidth(),
/// Default User and ID presented on DMA manager AR, AW, W channels.
/// In most systems, these can or should be left at '0.
.AxiId(),
.AxiUser(),
/// SoC interface types
.reg_req_t(),
.reg_rsp_t(),
.axi_req_t(),
.axi_rsp_t()
) i_new_usb_ohci (
/// SoC clock and reset
.soc_clk_i(),
.soc_rst_ni(),
/// Control subordinate port
.ctrl_req_i(),
.ctrl_rsp_o(),
/// DMA manager port
.dma_req_o(),
.dma_rsp_i(),
/// Interrupt
.intr_o(),
/// PHY clock and reset
.phy_clk_i(),
.phy_rst_ni(),
/// PHY IO
.phy_dm_i(),
.phy_dm_o(),
.phy_dm_oe_o(),
.phy_dp_i(),
.phy_dp_o(),
.phy_dp_oe_o()
);
while (!$feof(file)) begin
// Read a line
status = $fgets(line, file);

axi_sim_mem #(
// Skip empty lines or lines that start with "/"
if (line[0] == "/" || line[0] == "\n" || line[0] == " " || line[0] == "\0") begin
// $display("comment line");
continue;
end
// Try to parse the address and data
status = $sscanf(line, "@%h %h %h %h %h", address, dword[0], dword[1], dword[2], dword[3]);

Check warning on line 63 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L63

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_tb/new_usb_tb.sv" range:{start:{line:63 column:1}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:63 column:1} end:{line:64}} text:"\n"}
if (status == 5) begin // Successfully read 5 values
for (i = 0; i < 4; i++) begin
mem[address + i * 4 + 0] = dword[i][7:0]; // LSB to lowest address
mem[address + i * 4 + 1] = dword[i][15:8];

Check warning on line 67 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L67

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_tb/new_usb_tb.sv" range:{start:{line:67 column:59}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:67 column:59} end:{line:69}} text:"                mem[address + i * 4 + 1] = dword[i][15:8];\n                mem[address + i * 4 + 2] = dword[i][23:16];\n"}
mem[address + i * 4 + 2] = dword[i][23:16];

Check warning on line 68 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L68

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_tb/new_usb_tb.sv" range:{start:{line:68 column:60}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
mem[address + i * 4 + 3] = dword[i][31:24]; // MSB to highest address
$display("Written into mem: @%h %h", address + i*4, dword[i]);
end
end

Check warning on line 72 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L72

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_tb/new_usb_tb.sv" range:{start:{line:72 column:12}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:72 column:12} end:{line:73}} text:"        end\n"}
else begin
$display("Invalid data format in line: %s", line);
end

) i_axi_sim_mem (
if ($feof(file)) begin
break;
end
end

$fclose(file);
#1000;
$finish;
end


// axi_sim_mem #(
//

Check warning on line 89 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L89

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_tb/new_usb_tb.sv" range:{start:{line:89 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"} suggestions:{range:{start:{line:89 column:3} end:{line:95}} text:"//\n//\n//\n//\n//\n//\n"}
// ) i_axi_sim_mem (
//

Check warning on line 91 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L91

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_tb/new_usb_tb.sv" range:{start:{line:91 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
// );
//

Check warning on line 93 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L93

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_tb/new_usb_tb.sv" range:{start:{line:93 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
//

Check warning on line 94 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L94

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_tb/new_usb_tb.sv" range:{start:{line:94 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
// //Todo:regbusdriver
//

Check warning on line 96 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L96

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_tb/new_usb_tb.sv" range:{start:{line:96 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
//

Check warning on line 97 in hw/newusb_tb/new_usb_tb.sv

View workflow job for this annotation

GitHub Actions / verible-verilog-lint

[verible-verilog-lint] hw/newusb_tb/new_usb_tb.sv#L97

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_tb/new_usb_tb.sv" range:{start:{line:97 column:3}}} severity:WARNING source:{name:"verible-verilog-lint" url:"https://github.com/chipsalliance/verible"}
// new_usb_ohci #(
// /// DMA manager port parameters
// .AxiMaxReads,
// .AxiAddrWidth,
// .AxiDataWidth, // 32|64|128 causes 4|2|1 stages in the dmaoutputqueueED
// .AxiIdWidth,
// .AxiUserWidth,
// /// Default User and ID presented on DMA manager AR, AW, W channels.
// /// In most systems, these can or should be left at '0.
// .AxiId,
// .AxiUser,
// /// SoC interface types
// .reg_req_t(),
// .reg_rsp_t(),
// .axi_req_t(),
// .axi_rsp_t()
// ) i_new_usb_ohci (
// /// SoC clock and reset
// .soc_clk_i(),
// .soc_rst_ni(),
// /// Control subordinate port
// .ctrl_req_i(),
// .ctrl_rsp_o(),
// /// DMA manager port
// .dma_req_o(),
// .dma_rsp_i(),
// /// Interrupt
// .intr_o(),
// /// PHY clock and reset
// .phy_clk_i(),
// .phy_rst_ni(),
// /// PHY IO
// .phy_dm_i(),
// .phy_dm_o(),
// .phy_dm_oe_o(),
// .phy_dp_i(),
// .phy_dp_o(),
// .phy_dp_oe_o()
// );

);

//Todo:regbusdriver


endmodule
endmodule
12 changes: 0 additions & 12 deletions hw/newusb_tb/new_usb_tb_addr_mem.txt

This file was deleted.

Loading

0 comments on commit b7cd0fa

Please sign in to comment.