Skip to content

Commit ac90bd1

Browse files
committed
[update] picker demo code and dockerfile.full
1 parent f4f381c commit ac90bd1

3 files changed

Lines changed: 27 additions & 81 deletions

File tree

docker/Dockerfile.full

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ FROM ghcr.io/xs-mlvp/envbase:latest
33
USER user
44
WORKDIR /workspace
55

6-
RUN mkdir tutorial && \
7-
cd tutorial && \
8-
pip3 install pytoffee && \
9-
git clone https://github.com/SFangYy/tutorial_code.git --depth=1
6+
RUN pip3 install pytoffee && \
7+
git clone https://github.com/XS-MLVP/tutorial-records.git --depth=1 && \
8+
mv tutorial-records/tutorials/code-samples . && \
9+
cd .. && \
10+
rm -rf tutorial-records
11+
1012

11-
RUN git clone https://github.com/OpenXiangShan/XSPdb.git --depth=1 && \
12-
cd XSPdb && \
13-
make init
13+
RUN cd code-samples && \
14+
git clone https://github.com/OpenXiangShan/XSPdb.git --depth=1 xspdb && \
15+
cd xspdb && \
16+
make init && \
17+
rm -rf XSPython example && \
18+
wget https://github.com/XS-MLVP/tutorial-records/releases/download/v1.0.0/xspdb_with_bug.tar.gz && \
19+
tar zxvf xspdb_with_bug.tar.gz && \
20+
rm -rf xspdb_with_bug.tar.gz

tutorials/code-samples/picker/Adder/example.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,26 @@
55
def random_int():
66
return random.randint(-(2**127), 2**127 - 1) & ((1 << 128) - 1)
77

8+
def as_uint(x,nbits):
9+
return x & ((1 << nbits) - 1)
810

911
def main():
10-
dut = DUTAdder() # Assuming USE_VERILATOR
11-
12+
dut = DUTAdder() # Assuming USE_VERILATOR
1213
print("Initialized UTAdder")
13-
14+
1415
for c in range(11451):
15-
dut.a.value, dut.b.value, dut.cin.value = random_int(), random_int(), random_int() & 1
16-
#dut.Step(1)
17-
# def dut_cal():
18-
# dut.a.value, dut.b.value, dut.cin.value = i.a, i.b, i.cin
19-
# dut.Step(1)
20-
# o_dut.sum = dut.sum.value
21-
# o_dut.cout = dut.cout.value
22-
23-
#dut_cal()
24-
#ref_cal()
25-
26-
print(f"[cycle {dut.xclock.clk}] a=0x{dut.a.value:x}, b=0x{dut.b.value:x}, cin=0x{dut.cin.value:x}")
27-
dut.Step(1)
28-
#print(f"DUT: sum=0x{o_dut.sum:x}, cout=0x{o_dut.cout:x}")
29-
#print(f"REF: sum=0x{o_ref.sum:x}, cout=0x{o_ref.cout:x}")
30-
31-
#assert o_dut.sum == o_ref.sum, "sum mismatch"
16+
a, b, cin = random_int(), random_int(), random_int() & 1
17+
dut.a.value, dut.b.value, dut.cin.value = a, b, cin
18+
19+
dut.Step(1)
20+
print(f"[cycle {dut.xclock.clk}] a=0x{dut.a.value:x}, b=0x{dut.b.value:x}, cin=0x{dut.cin.value:x}, sum {as_uint(a+b+cin,128)}, dut_sum {as_uint(dut.sum.value,128)}")
21+
assert as_uint(dut.sum.value,128) == as_uint(a + b + cin, 128), "sum mismatch"
3222

3323
print("Test Passed, destroy UTAdder")
3424
dut.Finish() # When using VCS, DUT.Finish() will exit the program, so it should be the last line of the program
3525

36-
3726
if __name__ == "__main__":
3827
main()
28+
~
29+
~
30+
~

tutorials/code-samples/picker/Adder/release-vcs.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)