From 5d77ef0a02a40ec0e7566fe9c257be2b699a7871 Mon Sep 17 00:00:00 2001 From: "sem24h18 Fabian Hauser (fhauser)" <146116057+fhaus1@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:55:23 +0100 Subject: [PATCH] fix tb_nonperiodiccounter --- Bender.yml | 1 + hw/newusb/new_usb_nonperiodiccounter.sv | 7 ++++--- hw/newusb_tb/tb_new_usb_nonperiodiccounter.sv | 13 +++++++++++++ target/sim/vsim/start.newusb_nonperiodiccounter.tcl | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Bender.yml b/Bender.yml index d1330e49..d65b3069 100644 --- a/Bender.yml +++ b/Bender.yml @@ -46,6 +46,7 @@ sources: - hw/newusb_regs/newusb_reg_pkg.sv - hw/newusb_regs/newusb_reg_top.sv - hw/newusb/new_usb_ohci_pkg.sv + - hw/newusb/new_usb_nonperiodiccounter.sv - hw/newusb/new_usb_ohci.sv - hw/cheshire_pkg.sv - hw/cheshire_soc.sv diff --git a/hw/newusb/new_usb_nonperiodiccounter.sv b/hw/newusb/new_usb_nonperiodiccounter.sv index ab448bee..cea813cf 100644 --- a/hw/newusb/new_usb_nonperiodiccounter.sv +++ b/hw/newusb/new_usb_nonperiodiccounter.sv @@ -23,6 +23,7 @@ module new_usb_nonperiodiccounter ( logic [1:0] count; logic restart_counter; + logic en_i; counter #(.WIDTH(2), .STICKY_OVERFLOW(1'b1)) i_counter ( .clk_i, @@ -36,7 +37,7 @@ module new_usb_nonperiodiccounter ( .overflow_o(counter_overflown_o) ); - assign counter_is_threshold_i = (count == 2'b00); + assign counter_is_threshold_o = (count == 2'b00); // create enable, one pulse for one count logic served_control_td_prev; @@ -47,7 +48,7 @@ module new_usb_nonperiodiccounter ( logic served_bulk_td_prev; logic reloadcbsr; `FF(served_bulk_td_prev, served_bulk_td_i, 1'b0) - restart_counter = served_bulk_td_i && ~served_bulk_td_prev; - assign reload_cbsr = (restart_counter || !rst_ni); + assign restart_counter = served_bulk_td_i && ~served_bulk_td_prev; + assign reload_cbsr = (restart_counter || ~rst_ni); endmodule \ No newline at end of file diff --git a/hw/newusb_tb/tb_new_usb_nonperiodiccounter.sv b/hw/newusb_tb/tb_new_usb_nonperiodiccounter.sv index 5bd27c95..02347268 100644 --- a/hw/newusb_tb/tb_new_usb_nonperiodiccounter.sv +++ b/hw/newusb_tb/tb_new_usb_nonperiodiccounter.sv @@ -34,4 +34,17 @@ initial begin rst_ni = 1; end +logic overflow; +logic threshold; + +new_usb_nonperiodiccounter i_nonperiodiccounter ( + .clk_i, + .rst_ni, + .served_bulk_td_i(1'b0), // successfully served bulk transfer descriptor + .served_control_td_i(1'b1), // successfully served control transfer descriptor + .cbsr_i(2'b11), + .counter_overflown_o(overflow), // enough control EDs served + .counter_is_threshold_o(threshold) // signals last control ED to send for listservice +); + endmodule diff --git a/target/sim/vsim/start.newusb_nonperiodiccounter.tcl b/target/sim/vsim/start.newusb_nonperiodiccounter.tcl index 6a240606..15aef572 100755 --- a/target/sim/vsim/start.newusb_nonperiodiccounter.tcl +++ b/target/sim/vsim/start.newusb_nonperiodiccounter.tcl @@ -12,5 +12,7 @@ set NumericStdNoWarnings 1 eval vsim -c ${TESTBENCH} -t 1ps -vopt -voptargs="+acc" add wave -position insertpoint sim:/tb_new_usb_nonperiodiccounter/clk_i add wave -position insertpoint sim:/tb_new_usb_nonperiodiccounter/rst_ni +add wave -position insertpoint sim:/tb_new_usb_nonperiodiccounter/overflow +add wave -position insertpoint sim:/tb_new_usb_nonperiodiccounter/threshold run 1us \ No newline at end of file