Skip to content

Commit

Permalink
Bump Croc used in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Jan 20, 2025
1 parent e767dc0 commit 07eece8
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 117 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
cache-name: cache-yosys
with:
path: tests/third_party/yosys
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.YOSYS_HASH }}-patched
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.YOSYS_HASH }}
- if: ${{ steps.cache-yosys.outputs.cache-hit != 'true' }}
name: Pull Yosys
run: |
Expand All @@ -43,7 +43,6 @@ jobs:
cd tests/third_party/yosys
make config-gcc
echo "ENABLE_ABC := 0" >> Makefile.conf
patch -p1 < ../cxxrtl-work-around-issue-3549.patch
make -j6
- name: Install Yosys
shell: bash
Expand Down Expand Up @@ -130,8 +129,8 @@ jobs:
# bender -d . script flist-plus --relative-path > croc.f
# /patch absolute paths in croc.f/
# tar --exclude='.git' --exclude='*/libs.doc/*' -cvf ../croc-checkout-250109-846ce38.tar .
CROC_CHECKOUT: 'croc-checkout-250111-062d1cc.tar.gz'
CROC_CHECKOUT_HASH: '9d8787cd495d1b5c749ebc28e866f2185a3b0009d9e52f2aab3bfddefe56fd97 croc-checkout-250111-062d1cc.tar.gz'
CROC_CHECKOUT: 'croc-checkout-250120-846ce380.tar.gz'
CROC_CHECKOUT_HASH: '6e7b193fe51c3fe3dad00a675c729b9e12d1fc3c72e8d06c580d92fdeba64403 croc-checkout-250120-846ce380.tar.gz'
steps:
- name: Install Dependencies
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions tests/croc_boot/debugger.tcl_
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
adapter driver remote_bitbang
remote_bitbang host /tmp/croc-jtag-bitbang.sock
jtag newtap auto0 cpu -irlen 5 -expected-id 0x10000db3
jtag newtap auto0 cpu -irlen 5 -expected-id 0x0c0c5db3
target create auto0 riscv -chain-position auto0.cpu

riscv set_ir idcode 0x1
Expand All @@ -10,7 +10,7 @@ init

halt
load_image helloworld.ihex
reg pc 0x10000080
reg pc 0x10000000
resume
halt
if {[read_memory 0x03000008 32 1] != 7} {
Expand Down
44 changes: 31 additions & 13 deletions tests/croc_boot/helloworld.ihex
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
:020000041000EA
:10008000970100009381C1091381016E9300000064
:10009000130200009302000013030000930300000A
:1000A00013040000930400001305000093050000F2
:1000B00013060000930600001307000093070000DA
:1000C000EF004001970200F3938242F423A0A200C4
:1000D00073005010130101FE232E8100130401024E
:1000E000930750002326F4FE9307A0002324F4FE78
:1000F000930780002322F4FE0327C4FE832784FE97
:100100003307F700832744FEB307F7401385070042
:0C0110000324C1011301010267800000FC
:040000051000008067
:00000001FF
:020000041000EA
:100000009701000083A10119170100000321C11805
:10001000930000001302000093020000130300008D
:100020009303000013040000930400001305000074
:10003000930500001306000093060000130700005C
:1000400093070000EF0000149702000083A202153E
:0800500023A0A2007300501070
:10005800B727000323820700130700F82386E70069
:10006800130750002380E70023820700130730009E
:100078002386E700130770FC2384E70013070002B8
:100088002388E70067800000B727000303C54701FE
:100098001375150067800000372700038347470161
:1000A80093F70702E38C07FE2300A7006780000090
:1000B800130101FF2324810023229100232611002C
:1000C80013040500B304B500631C94008320C10029
:1000D800032481008324410013010101678000008B
:1000E8000345040013041400EFF01FFB6FF0DFFD5D
:1000F800372700038347470193F70702E38C07FE7E
:100108008347470193F70704E38607FE67800000EB
:10011800130101FF23261100EFF01FF7E30E05FE80
:100128008320C100B727000303C50700130101019D
:1001380067800000130101FF23248100232291001E
:100148002326110013040500B304B500631C9400B2
:100158008320C1000324810083244100130101018D
:1001680067800000EFF0DFFA2300A40013041400F6
:100178006FF0DFFD6FF05FF26FF09FF9130570000D
:04018800678000008C
:10018C000000000098010010000800100800000397
:08019C00FFFFFFFF000000005F
:0400000510000000E7
:00000001FF
48 changes: 27 additions & 21 deletions tests/croc_boot/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,35 @@ int main(int argc, const char *argv[]) {
}

cxxrtl_design::p_croc__soc top;
top.p_irq0__i.set(false);
top.p_test__enable__i.set(false);
top.p_gclk.set(false);
top.step();

auto step = [&](){
top.p_gclk.set(true);
top.step();
top.p_gclk.set(false);
top.step();
};
top.p_testmode__i.set(false);
top.p_rst__ni.set(false);
top.p_clk__i.set(false);
top.step();
step();
top.p_clk__i.set(true);
top.step();
step();
top.p_rst__ni.set(true);
top.step();
step();
top.p_fetch__en__i.set(true);
step();
for (int i = 0; i < 10; i++) {
top.p_clk__i.set(false);
top.step();
step();
top.p_clk__i.set(true);
top.step();
step();
}

auto& fetch_en = top.p_i__croc_2e_i__soc__ctrl_2e_u__fetchen_2e_q;
auto& mem = top.memory_p_i__croc_2e_gen__sram__bank_5b_0_5d__2e_i__sram_2e_sram;

fetch_en.curr.set(1);
fetch_en.next.set(1);
mem[0x80].set(0x10500073u); // wfi
mem[0x84].set(0xffdff06fu); // jal x0, -4

top.p_clk__i.set(false);
top.step();
auto& mem = top.cell_p_i__croc.cell_p_gen__sram__bank_5b_0_5d__2e_i__sram.memory_p_sram;
mem[0x0].set(0x10500073u); // wfi
mem[0x1].set(0xffdff06fu); // jal x0, -4

while (1) {
char c;
Expand All @@ -102,7 +105,6 @@ int main(int argc, const char *argv[]) {
case '0' ... '7': // tck tms tdi
c -= '0';
top.p_jtag__tck__i.set((c & 4) != 0);
top.step();
top.p_jtag__tdi__i.set((c & 1) != 0);
top.p_jtag__tms__i.set((c & 2) != 0);
break;
Expand All @@ -116,11 +118,15 @@ int main(int argc, const char *argv[]) {
continue;
}

top.step();
step();

top.p_clk__i.set(true);
top.step();
step();
top.p_clk__i.set(false);
top.step();
step();
top.p_clk__i.set(true);
step();
top.p_clk__i.set(false);
step();
}
}
34 changes: 29 additions & 5 deletions tests/croc_boot/prepare.ys_
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
read_slang --top croc_soc -F ../third_party/croc/croc.f \
-D SYNTHESIS -D COMMON_CELLS_ASSERTS_OFF --compat-mode \
--allow-use-before-declare --keep-hierarchy -D TARGET_SYNTHESIS
read_slang --top croc_soc -F ../../../croc/croc.f \
-D SYNTHESIS -D COMMON_CELLS_ASSERTS_OFF \
--allow-use-before-declare -D TARGET_SYNTHESIS \
--keep-hierarchy
hierarchy -top croc_soc
stat
check -assert
prep -nomem
async2sync
opt -mux_undef
setattr -mod -set keep_hierarchy 1

clk2fflogic
chtype -map $ff __ff

read_verilog -icells <<EOF
(* do_flatten *)
module __ff (D, Q, gclk);
parameter WIDTH = 1;
input gclk;
input [WIDTH-1:0] D;
output reg [WIDTH-1:0] Q;
$dff #(.CLK_POLARITY(1), .WIDTH(WIDTH)) dff(.D(D), .Q(Q), .CLK(gclk));
endmodule
EOF

add -global_input gclk 1
hierarchy -top croc_soc
flatten
stat

bwmuxmap
write_cxxrtl croc_soc.cc
write_cxxrtl -noflatten -g0 croc_soc.cc
exec -- g++ -std=c++14 -o main main.cc -I `yosys-config --datdir`/include/backends/cxxrtl/runtime -Wno-shift-count-overflow -Wno-array-bounds -O1
8 changes: 3 additions & 5 deletions tests/croc_boot/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ set -ex
TEST_DIR="$(dirname "${BASH_SOURCE[0]}")"
PLUGIN="$(realpath "$TEST_DIR/../../build/slang.so")"
CROC_PATH="$(realpath "$TEST_DIR/../third_party/croc/")"
rm -rf /tmp/croc-jtag-bitbang.sock
(cd "$TEST_DIR" &&
yosys -m ../../build/slang.so -s prepare.ys_ && \
g++ -std=c++14 -o main main.cc -I `yosys-config --datdir`/include/backends/cxxrtl/runtime \
-Wno-shift-count-overflow -Wno-array-bounds -O3)
rm -f /tmp/croc-jtag-bitbang.sock
"$TEST_DIR/main" /tmp/croc-jtag-bitbang.sock
yosys -m ../../build/slang.so -s prepare.ys_ &&
./main /tmp/croc-jtag-bitbang.sock)
(cd "$TEST_DIR" &&
openocd -f debugger.tcl_ -d)
67 changes: 0 additions & 67 deletions tests/third_party/cxxrtl-work-around-issue-3549.patch

This file was deleted.

0 comments on commit 07eece8

Please sign in to comment.