-
Notifications
You must be signed in to change notification settings - Fork 15
Axi4 passive vip #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Axi4 passive vip #391
Changes from all commits
5b30a72
899df46
27f6c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| CAPI=2: | ||
| # Copyright lowRISC contributors (COSMIC project). | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name : lowrisc:dv:axi4_vip:0.1 | ||
|
|
||
| filesets: | ||
| files_dv: | ||
| files: | ||
| - axi4_vip_if.sv | ||
| - axi4_vip_pkg.sv | ||
| - axi4_vip_defines.svh: {is_include_file: true} | ||
| - axi4_vip_types.svh: {is_include_file: true} | ||
| - axi4_vip_cfg.svh: {is_include_file: true} | ||
| - axi4_vip_item.svh: {is_include_file: true} | ||
| - axi4_vip_driver.svh: {is_include_file: true} | ||
| - axi4_vip_sequencer.svh: {is_include_file: true} | ||
| - axi4_vip_monitor.svh: {is_include_file: true} | ||
| - axi4_vip_manager_agent.svh: {is_include_file: true} | ||
| - axi4_vip_subordinate_agent.svh: {is_include_file: true} | ||
| - axi4_vip_env.svh: {is_include_file: true} | ||
| file_type: systemVerilogSource | ||
|
|
||
| targets: | ||
| default: | ||
| filesets: | ||
| - files_dv |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| class axi4_vip_cfg extends uvm_object; | ||
|
|
||
| // Currently this is a passive VIP (monitor only) | ||
| string m_inst_id = "AXI4"; | ||
| bit m_has_manager = 0; | ||
| uvm_active_passive_enum m_manager_active_passive = UVM_PASSIVE; | ||
| bit m_has_subordinate = 0; | ||
| uvm_active_passive_enum m_subordinate_active_passive = UVM_PASSIVE; | ||
|
|
||
| // Future placeholders | ||
| bit m_has_coverage = 0; | ||
| bit m_has_checker = 0; | ||
|
|
||
| // actual bus widths (<= max defines) | ||
| int unsigned m_id_width = 16; | ||
| int unsigned m_addr_width = 64; | ||
| int unsigned m_data_width = 1024; | ||
| int unsigned m_user_width = 32; | ||
| int unsigned m_region_width = 8; | ||
| int unsigned m_qos_width = 8; | ||
|
|
||
| `uvm_object_utils_begin(axi4_vip_cfg) | ||
| `uvm_field_string(m_inst_id, UVM_DEFAULT | UVM_STRING) | ||
| `uvm_field_int(m_has_manager, UVM_DEFAULT) | ||
| `uvm_field_int(m_has_subordinate, UVM_DEFAULT) | ||
| `uvm_field_int(m_has_coverage, UVM_DEFAULT) | ||
| `uvm_field_int(m_has_checker, UVM_DEFAULT) | ||
| `uvm_field_enum(uvm_active_passive_enum, m_manager_active_passive, UVM_DEFAULT) | ||
| `uvm_field_enum(uvm_active_passive_enum, m_subordinate_active_passive, UVM_DEFAULT) | ||
| `uvm_field_int(m_id_width, UVM_DEFAULT) | ||
| `uvm_field_int(m_addr_width, UVM_DEFAULT) | ||
| `uvm_field_int(m_data_width, UVM_DEFAULT) | ||
| `uvm_field_int(m_user_width, UVM_DEFAULT) | ||
| `uvm_field_int(m_region_width, UVM_DEFAULT) | ||
| `uvm_field_int(m_qos_width, UVM_DEFAULT) | ||
| `uvm_object_utils_end | ||
|
|
||
| // External Method Declarations | ||
| extern function new(string name = "axi4_vip_cfg"); | ||
|
|
||
| extern virtual function void set_config( | ||
| string inst_id = "", bit has_manager = 0, uvm_active_passive_enum manager_active_passive = UVM_PASSIVE, | ||
| bit has_subordinate = 0, uvm_active_passive_enum subordinate_active_passive = UVM_PASSIVE, bit has_coverage = 0, | ||
| bit has_checker = 0, int unsigned id_width = 16, int unsigned addr_width = 64, int unsigned data_width = 1024, | ||
| int unsigned user_width = 32, int unsigned region_width = 8, int unsigned qos_width = 8); | ||
|
|
||
| endclass : axi4_vip_cfg | ||
|
|
||
| // External Method Implementations | ||
| function axi4_vip_cfg::new(string name = "axi4_vip_cfg"); | ||
| super.new(name); | ||
| endfunction : new | ||
|
|
||
| function void axi4_vip_cfg::set_config( | ||
| string inst_id = "", bit has_manager = 0, uvm_active_passive_enum manager_active_passive = UVM_PASSIVE, | ||
| bit has_subordinate = 0, uvm_active_passive_enum subordinate_active_passive = UVM_PASSIVE, bit has_coverage = 0, | ||
| bit has_checker = 0, int unsigned id_width = 16, int unsigned addr_width = 64, int unsigned data_width = 1024, | ||
| int unsigned user_width = 32, int unsigned region_width = 8, int unsigned qos_width = 8); | ||
| m_inst_id = inst_id; | ||
| m_has_manager = has_manager; | ||
| m_manager_active_passive = manager_active_passive; | ||
| m_has_subordinate = has_subordinate; | ||
| m_subordinate_active_passive = subordinate_active_passive; | ||
| m_has_coverage = has_coverage; | ||
| m_has_checker = has_checker; | ||
| m_id_width = id_width; | ||
| m_addr_width = addr_width; | ||
| m_data_width = data_width; | ||
| m_user_width = user_width; | ||
| m_region_width = region_width; | ||
| m_qos_width = qos_width; | ||
| endfunction : set_config | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // maximum supported bus widths | ||
| `define AXI4_MAX_ID_WIDTH 16 | ||
| `define AXI4_MAX_ADDR_WIDTH 64 | ||
| `define AXI4_MAX_DATA_WIDTH 1024 | ||
| `define AXI4_MAX_USER_WIDTH 32 | ||
| `define AXI4_MAX_REGION_WIDTH 8 | ||
| `define AXI4_MAX_QOS_WIDTH 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| class axi4_vip_driver extends uvm_driver #(axi4_vip_item); | ||
|
|
||
| `uvm_component_utils(axi4_vip_driver) | ||
|
|
||
| axi4_vip_cfg m_cfg; | ||
| virtual axi4_vip_if vif; | ||
|
|
||
| // External Method Declarations | ||
| extern function new(string name, uvm_component parent); | ||
| extern function void build_phase(uvm_phase phase); | ||
| extern task run_phase(uvm_phase phase); | ||
|
|
||
| endclass : axi4_vip_driver | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // External Method Implementations | ||
| //------------------------------------------------------------------------------ | ||
|
|
||
| function axi4_vip_driver::new(string name, uvm_component parent); | ||
| super.new(name, parent); | ||
| endfunction : new | ||
|
|
||
| function void axi4_vip_driver::build_phase(uvm_phase phase); | ||
| super.build_phase(phase); | ||
| if (! uvm_config_db #(axi4_vip_cfg)::get(this, "", "m_cfg", m_cfg)) begin | ||
| `uvm_fatal("NOCFG", {"Configuration item must be set for: ", get_full_name(), "m_cfg"}) | ||
| end | ||
|
|
||
| if (! uvm_config_db #(virtual interface axi4_vip_if)::get(this, get_full_name(),"vif", vif)) begin | ||
| `uvm_fatal("NOVIF",{"virtual interface must be set for: ",get_full_name(),".vif"}) | ||
| end | ||
| endfunction : build_phase | ||
|
|
||
| task axi4_vip_driver::run_phase(uvm_phase phase); | ||
| forever begin | ||
| // TODO: Placeholder | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What needs to go here? Do we need a driver initially if we are just monitoring?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UVM VIPs have driver, monitor and sequencer. In case of UVM_PASSIVE mode, the driver and the sequncer are not instantiated. This is just a placeholder for UVM_ACTIVE mode. |
||
| seq_item_port.get_next_item(req); | ||
| seq_item_port.item_done(); | ||
| end | ||
| endtask : run_phase | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| class axi4_vip_env extends uvm_env; | ||
|
|
||
| `uvm_component_utils(axi4_vip_env) | ||
|
|
||
| axi4_vip_cfg m_cfg; | ||
|
|
||
| axi4_vip_manager_agent m_manager; | ||
| axi4_vip_subordinate_agent m_subordinate; | ||
|
|
||
| // External Method Declarations | ||
| extern function new(string name, uvm_component parent); | ||
| extern function void build_phase(uvm_phase phase); | ||
|
|
||
| endclass : axi4_vip_env | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // External Method Implementations | ||
| //------------------------------------------------------------------------------ | ||
|
|
||
| function axi4_vip_env::new(string name, uvm_component parent); | ||
| super.new(name, parent); | ||
| endfunction : new | ||
|
|
||
| function void axi4_vip_env::build_phase(uvm_phase phase); | ||
| super.build_phase(phase); | ||
|
|
||
| if (! uvm_config_db #(axi4_vip_cfg)::get(this, "", "m_cfg", m_cfg)) begin | ||
| `uvm_fatal("NOCFG", {"Configuration item must be set for: ", get_full_name(), "m_cfg"}) | ||
| end | ||
|
|
||
| if (m_cfg.m_has_manager == 1) begin | ||
| m_manager = axi4_vip_manager_agent::type_id::create("m_manager", this); | ||
| end | ||
|
|
||
| if (m_cfg.m_has_subordinate == 1) begin | ||
| m_subordinate = axi4_vip_subordinate_agent::type_id::create("m_subordinate", this); | ||
| end | ||
| endfunction : build_phase |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| interface axi4_vip_if #( | ||
| parameter int ID_WIDTH = 4, | ||
| parameter int ADDR_WIDTH = 32, | ||
| parameter int DATA_WIDTH = 64, | ||
| parameter int USER_WIDTH = 8, | ||
| parameter int REGION_WIDTH = 4, | ||
| parameter int QOS_WIDTH = 4 | ||
| ) ( | ||
| input logic aclk, | ||
| input logic aresetn | ||
| ); | ||
|
|
||
| // write address channel | ||
| logic awvalid; | ||
| logic awready; | ||
| logic [ ID_WIDTH-1:0] awid; | ||
| logic [ ADDR_WIDTH-1:0] awaddr; | ||
| logic [ 7:0] awlen; | ||
| logic [ 2:0] awsize; | ||
| logic [ 1:0] awburst; | ||
| logic awlock; | ||
| logic [ 3:0] awcache; | ||
| logic [ 2:0] awprot; | ||
| logic [ QOS_WIDTH-1:0] awqos; | ||
| logic [ REGION_WIDTH-1:0] awregion; | ||
| logic [ USER_WIDTH-1:0] awuser; | ||
|
|
||
| // write data channel | ||
| logic wvalid; | ||
| logic wready; | ||
| logic [ DATA_WIDTH-1:0] wdata; | ||
| logic [(DATA_WIDTH/8)-1:0] wstrb; | ||
| logic wlast; | ||
| logic [ USER_WIDTH-1:0] wuser; | ||
|
|
||
| // write response channel | ||
| logic bvalid; | ||
| logic bready; | ||
| logic [ ID_WIDTH-1:0] bid; | ||
| logic [ 1:0] bresp; | ||
| logic [ USER_WIDTH-1:0] buser; | ||
|
|
||
| // read address channel | ||
| logic arvalid; | ||
| logic arready; | ||
| logic [ ID_WIDTH-1:0] arid; | ||
| logic [ ADDR_WIDTH-1:0] araddr; | ||
| logic [ 7:0] arlen; | ||
| logic [ 2:0] arsize; | ||
| logic [ 1:0] arburst; | ||
| logic arlock; | ||
| logic [ 3:0] arcache; | ||
| logic [ 2:0] arprot; | ||
| logic [ QOS_WIDTH-1:0] arqos; | ||
| logic [ REGION_WIDTH-1:0] arregion; | ||
| logic [ USER_WIDTH-1:0] aruser; | ||
|
|
||
| // read data channel | ||
| logic rvalid; | ||
| logic rready; | ||
| logic [ ID_WIDTH-1:0] rid; | ||
| logic [ DATA_WIDTH-1:0] rdata; | ||
| logic [ 1:0] rresp; | ||
| logic rlast; | ||
| logic [ USER_WIDTH-1:0] ruser; | ||
|
|
||
| // manager clocking block | ||
| clocking manager_cb @(posedge aclk); | ||
|
|
||
| // write address | ||
| output awvalid, awid, awaddr, awlen, awsize, awburst; | ||
|
rswarbrick marked this conversation as resolved.
|
||
| output awlock, awcache, awprot, awqos, awregion, awuser; | ||
| input awready; | ||
|
|
||
| // write data | ||
| output wvalid, wdata, wstrb, wlast, wuser; | ||
| input wready; | ||
|
|
||
| // write response | ||
| input bvalid, bid, bresp, buser; | ||
| output bready; | ||
|
|
||
| // read address | ||
| output arvalid, arid, araddr, arlen, arsize, arburst; | ||
| output arlock, arcache, arprot, arqos, arregion, aruser; | ||
| input arready; | ||
|
|
||
| // read data | ||
| input rvalid, rid, rdata, rresp, rlast, ruser; | ||
| output rready; | ||
|
|
||
| endclocking | ||
|
|
||
|
|
||
| // subordinate clocking block | ||
| clocking subordinate_cb @(posedge aclk); | ||
|
|
||
| // write address | ||
| input awvalid, awid, awaddr, awlen, awsize, awburst; | ||
| input awlock, awcache, awprot, awqos, awregion, awuser; | ||
| output awready; | ||
|
|
||
| // write data | ||
| input wvalid, wdata, wstrb, wlast, wuser; | ||
| output wready; | ||
|
|
||
| // write response | ||
| output bvalid, bid, bresp, buser; | ||
| input bready; | ||
|
|
||
| // read address | ||
| input arvalid, arid, araddr, arlen, arsize, arburst; | ||
| input arlock, arcache, arprot, arqos, arregion, aruser; | ||
| output arready; | ||
|
|
||
| // read data | ||
| output rvalid, rid, rdata, rresp, rlast, ruser; | ||
| input rready; | ||
|
|
||
| endclocking | ||
|
|
||
|
|
||
| // monitor clocking block | ||
| clocking monitor_cb @(posedge aclk); | ||
|
|
||
| input awvalid, awready, awid, awaddr, awlen, awsize, awburst; | ||
| input awlock, awcache, awprot, awqos, awregion, awuser; | ||
|
|
||
| input wvalid, wready, wdata, wstrb, wlast, wuser; | ||
|
|
||
| input bvalid, bready, bid, bresp, buser; | ||
|
|
||
| input arvalid, arready, arid, araddr, arlen, arsize, arburst; | ||
| input arlock, arcache, arprot, arqos, arregion, aruser; | ||
|
|
||
| input rvalid, rready, rid, rdata, rresp, rlast, ruser; | ||
|
|
||
| endclocking | ||
|
|
||
| endinterface | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the Max defines here for the values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not really matter, but I can add it.