Skip to content

Commit e70a699

Browse files
committed
- Design fix
- Test fix - Makefile fix
1 parent 1da7f2c commit e70a699

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

src/tt_um_scorbetta_goa.v

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ module tt_um_scorbetta_goa
3030
input wire rst_n // reset_n - low to reset
3131
);
3232

33-
wire [7:0] counter;
33+
wire [7:0] counter;
34+
wire tt_rstn_i;
35+
wire fpga_rstn_i;
36+
37+
// Keep the design under reset if not enabled
38+
assign tt_rstn_i = ena & rst_n;
39+
assign fpga_rstn_i = ena & ui_in[`UI_IN_RESET];
3440

3541
// Use main clock to check power
3642
COUNTER #(
3743
.WIDTH (8)
3844
)
3945
COUNTER (
4046
.CLK (clk),
41-
.RSTN (rst_n),
47+
.RSTN (tt_rstn_i),
4248
.EN (ena),
4349
.VALUE (counter),
4450
.OVERFLOW () // Unused
@@ -50,7 +56,7 @@ module tt_um_scorbetta_goa
5056
// User design uses a custom clock, generated by remote FPGA
5157
NEURON_WRAPPER NEURON_WRAPPER (
5258
.CLK (ui_in[`UI_IN_CLOCK]),
53-
.RSTN (ui_in[`UI_IN_RESET]),
59+
.RSTN (fpga_rstn_i),
5460
.SCI_CSN (ui_in[`UI_IN_SCI_CSN]),
5561
.SCI_REQ (ui_in[`UI_IN_SCI_REQ]),
5662
.SCI_RESP (uo_out[`UO_OUT_SCI_RESP]),

test/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
.PHONY: clean
22

3-
VERILOG_SOURCES =
3+
VERILOG_SOURCES = tb.v
44
SRC_DIR = $(PWD)/../src
55
IVERILOG_ARGS =
66
COCOTB_PREFIX = $(shell cocotb-config --prefix)
77

88
ifneq ($(GATES),yes)
99

1010
VERILOG_SOURCES += $(shell ls $(SRC_DIR)/*.v | tr '\n' ' ' )
11-
VERILOG_SOURCES += tb.v
1211
IVERILOG_ARGS += -DCOCOTB_SIM=1 -s tb -I$(SRC_DIR) -g2012
1312

1413
else
1514

1615
VERILOG_SOURCES += $(PDK_ROOT)/sky130A/libs.ref/sky130_fd_sc_hd/verilog/primitives.v
1716
VERILOG_SOURCES += $(PDK_ROOT)/sky130A/libs.ref/sky130_fd_sc_hd/verilog/sky130_fd_sc_hd.v
1817
VERILOG_SOURCES += $(PWD)/gate_level_netlist.v
19-
IVERILOG_ARGS += -DFUNCTIONAL -DSIM -DUSE_POWER_PINS -DUNIT_DELAY=\#1
18+
IVERILOG_ARGS += -Ttyp -DFUNCTIONAL -DSIM -DUNIT_DELAY=\#1
2019

2120
endif
2221

test/tb.v

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ module tb
5959
);
6060

6161
tt_um_scorbetta_goa DUT (
62-
`ifdef GL_TEST
63-
.VPWR (1'b1),
64-
.VGND (1'b0),
65-
`endif
6662
.ui_in ({ ui_in_7, ui_in_6, ui_in_5, ui_in_4, ui_in_3, ui_in_2, ui_in_1, ui_in_0 }),
6763
.uo_out ({ uo_out_7, uo_out_6, uo_out_5, uo_out_4, uo_out_3, uo_out_2, uo_out_1, uo_out_0 }),
6864
.uio_in ({ uio_in_7, uio_in_6, uio_in_5, uio_in_4, uio_in_3, uio_in_2, uio_in_1, uio_in_0 }),
@@ -75,7 +71,7 @@ module tb
7571

7672
initial begin
7773
$dumpfile("dump.vcd");
78-
$dumpvars(0, tb.DUT);
74+
$dumpvars(0, tb);
7975
end
8076
endmodule
8177

test/test.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,33 @@ async def test(dut):
4343
dut.rst_n.value = 0
4444
dut.ui_in_1.value = 0 ;#UI_IN_RESET
4545
dut.ui_in_2.value = 1 ;#UI_IN_SCI_CSN
46+
dut.ui_in_3.value = 0 ;#UI_IN_SCI_REQ
4647
dut.ui_in_4.value = 0 ;#UI_IN_LOAD_IN
48+
dut.ui_in_5.value = 0 ;#UI_IN_LOAD_VALUE_IN
4749
dut.ui_in_6.value = 0 ;#UI_IN_SHIFT_OUT
4850
dut.ui_in_7.value = 0 ;#UI_IN_START
51+
dut.ena.value = 0
4952

5053
# Reset procedure
5154
for cycle in range(4):
5255
await RisingEdge(dut.clk)
5356
dut.rst_n.value = 1
5457
dut.ui_in_1.value = 1 ;#UI_IN_RESET
5558

59+
# Shim delay
60+
for cycle in range(10):
61+
await RisingEdge(dut.clk)
62+
63+
# Enable design
64+
dut.ena.value = 1
65+
5666
# Shim delay
5767
for cycle in range(4):
5868
await RisingEdge(dut.clk)
5969

70+
# Formally, we need to wait for neuron to be ready
71+
await wait_for_value(dut.ui_in_0, dut.uo_out_3, 1)
72+
6073
# From this point on, we use the clock generated from the FPGA as reference. Detailed interface
6174
# mapping through top-level GPIOs
6275
# CLK -> DUT.ui_in[0] -> tb.ui_in_0
@@ -146,16 +159,8 @@ async def test(dut):
146159
for _ in range(2):
147160
await RisingEdge(dut.ui_in_0)
148161

149-
# Verify accumulator
150-
threshold = 0.10
151-
dut_result = Fxp(val=f'0b{str(dut.DUT.NEURON_WRAPPER.NEURON.biased_acc_out.value.binstr)}', signed=True, n_word=width, n_frac=frac_bits, config=fxp_get_config())
152-
abs_err = fxp_abs_err(golden_model_acc, dut_result)
153-
quant_err = float(abs_err) / float(fxp_lsb) / fxp_quants
154-
#assert(quant_err <= threshold),print(f'Results for ACC differ more than {threshold*100}% LSBs: dut_result={dut_result},golden_result={golden_model_acc},abs_err={abs_err},quant_error={quant_err}')
155-
if quant_err > threshold:
156-
print(f'warn: Test #{test} - Results for ACC differ more than {threshold*100}% LSBs: dut_result={dut_result},golden_result={golden_model_acc},abs_err={abs_err},quant_error={quant_err}')
157-
158162
# Verify output
163+
threshold = 0.10
159164
dut_result_bin = ''
160165
dut.ui_in_6.value = 1
161166
for bdx in reversed(range(8)):

0 commit comments

Comments
 (0)