[ci, bazel] Bring englishbreakfast systemtest under Bazel control

Signed-off-by: Miles Dai <milesdai@google.com>
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 6c39835..5cc17e4 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -287,6 +287,25 @@
         --napoleon-docstrings
     displayName: Execute tests
 
+# TODO: change this name and replace sw_build_englishbreakfast and execute_verilated_tests_englishbreakfast
+# once testing shows it's stable
+- job: bazel_build_and_execute_verilated_tests_englishbreakfast
+  displayName: Build and execute tests on the Verilated English Breakfast toplevel design with Bazel
+  pool:
+    vmImage: ubuntu-18.04
+  dependsOn: chip_englishbreakfast_verilator
+  steps:
+  - template: ci/install-package-dependencies.yml
+  - template: ci/download-artifacts-template.yml
+    parameters:
+      downloadPartialBuildBinFrom:
+        - chip_englishbreakfast_verilator
+  - bash: |
+      . util/build_consts.sh
+      ci/scripts/run-english-breakfast-verilator-tests.sh
+    displayName: Execute tests
+    continueOnError: true #TODO: remove this line once this job is proven to be stable
+
 - job: otbn_standalone_tests
   displayName: Run OTBN Smoke Test
   dependsOn: lint
diff --git a/ci/scripts/build-chip-verilator.sh b/ci/scripts/build-chip-verilator.sh
index 3fffd05..654d183 100755
--- a/ci/scripts/build-chip-verilator.sh
+++ b/ci/scripts/build-chip-verilator.sh
@@ -21,11 +21,14 @@
         fileset=fileset_top
         fusesoc_core=lowrisc:dv:chip_verilator_sim
         vname=Vchip_sim_tb
+        verilator_options="--threads 4"
         ;;
     englishbreakfast)
         fileset=fileset_topgen
         fusesoc_core=lowrisc:systems:chip_englishbreakfast_verilator
         vname=Vchip_englishbreakfast_verilator
+        # Englishbreakfast on CI runs on a 2-core CPU
+        verilator_options="--threads 2"
 
         util/topgen-fusesoc.py --files-root=. --topname=top_englishbreakfast
         ;;
@@ -48,7 +51,7 @@
   run --flag=$fileset --target=sim --setup --build \
   --build-root="$OBJ_DIR/hw" \
   $fusesoc_core \
-  --verilator_options="--threads 4"
+  --verilator_options="${verilator_options}"
 
 cp "$OBJ_DIR/hw/sim-verilator/${vname}" \
    "$BIN_DIR/hw/top_${tl}/Vchip_${tl}_verilator"
diff --git a/ci/scripts/run-english-breakfast-verilator-tests.sh b/ci/scripts/run-english-breakfast-verilator-tests.sh
new file mode 100755
index 0000000..0f29cdc
--- /dev/null
+++ b/ci/scripts/run-english-breakfast-verilator-tests.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+# Only a single test is supported on English Breakfast (EB).
+# Currently, Bazel cannot build the EB Verilator model, so we only build the test with Bazel and then use opentitantool directly
+# EB Verilator model is built in a previous CI step
+
+set -e
+
+. util/build_consts.sh
+
+# Cleaning is necessary for the find commands below to work correctly
+ci/bazelisk.sh clean
+
+# Build the modified EB software.
+./hw/top_englishbreakfast/util/prepare_sw.py --bazel -b
+
+# Build some other dependencies.
+ci/bazelisk.sh build //sw/host/opentitantool //hw/ip/otp_ctrl/data:rma_image_verilator
+
+# Run the one test.
+# This needs to be run outside the bazel sandbox, so we do not use `bazel run`
+bazel-bin/sw/host/opentitantool/opentitantool \
+    --rcfile="" \
+    --logging=info \
+    --interface=verilator \
+    --conf=sw/host/opentitantool/config/opentitan_verilator.json \
+    --verilator-bin=$BIN_DIR/hw/top_englishbreakfast/Vchip_englishbreakfast_verilator \
+    --verilator-rom=$(find bazel-out/* -name 'test_rom_sim_verilator.32.vmem') \
+    --verilator-flash=$(find bazel-out/* -name 'aes_smoketest_prog_sim_verilator.64.scr.vmem') \
+    console \
+    --exit-failure="(FAIL|FAULT).*\n" \
+    --exit-success="PASS.*\n" \
+    --timeout=3600s
diff --git a/hw/top_englishbreakfast/util/prepare_sw.py b/hw/top_englishbreakfast/util/prepare_sw.py
index 47aa5e3..00bda24 100755
--- a/hw/top_englishbreakfast/util/prepare_sw.py
+++ b/hw/top_englishbreakfast/util/prepare_sw.py
@@ -31,7 +31,7 @@
 BAZEL_BINARIES = [
     '//sw/device/lib/testing/test_rom',
     '//sw/device/sca:aes_serial',
-    '//sw/device/tests:aes_smoketest',
+    '//sw/device/tests:aes_smoketest_prog',
     '//sw/device/examples/hello_world',
 ]
 
@@ -157,7 +157,7 @@
     # Build the software including test_rom to enable the FPGA build.
     if args.bazel:
         shell_out([
-            'bazel', 'build',
+            REPO_TOP / 'bazelisk.sh', 'build',
             '--copt=-DOT_IS_ENGLISH_BREAKFAST_REDUCED_SUPPORT_FOR_INTERNAL_USE_ONLY_',
         ] + BAZEL_BINARIES)
     else:
diff --git a/rules/opentitan.bzl b/rules/opentitan.bzl
index c7086d1..285c8f0 100644
--- a/rules/opentitan.bzl
+++ b/rules/opentitan.bzl
@@ -579,7 +579,7 @@
             name = vmem_name,
             bin = bin_name,
             platform = platform,
-            word_size = 32, 
+            word_size = 32,
         )
 
         # Generate Scrambled ROM VMEM