Skip to content

Commit

Permalink
Merge pull request #86 from chipsalliance/dev-goog
Browse files Browse the repository at this point in the history
Merge dev-goog into dev-integrate
  • Loading branch information
anjpar authored May 10, 2023
2 parents c1c2239 + 8c1a181 commit fc68dd2
Show file tree
Hide file tree
Showing 63 changed files with 4,662 additions and 578 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/build_tests_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import yaml

def main():

# Load and parse YAML description
file_name = "src/integration/stimulus/L0_regression.yml"
with open(file_name, "r") as fp:
yaml_root = yaml.safe_load(fp)

# Get test list
content = yaml_root["contents"][0]
tests = content["tests"]
paths = tests["paths"]

# Extract test names from paths
test_list = []
for path in paths:
parts = path.split("/")

for i, part in enumerate(parts):
if part == "test_suites" and i + 1 < len(parts):
test_list.append(parts[i+1])
break

# Output names
print(test_list)

if __name__ == "__main__":
main()
105 changes: 88 additions & 17 deletions .github/workflows/build-test-verilator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ on:

workflow_dispatch:

env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
RISCV_VERSION: v12.1.0
# TODO: To update to 5.006, clean up lint errors
VERILATOR_VERSION: v5.002
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1d

jobs:
build_and_test:
name: Verilator Smoke Test
build_tools:
name: Build Tools
runs-on: ubuntu-22.04

env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
RISCV_VERSION: v12.1.0
# TODO: To update to 5.006, clean up lint errors
VERILATOR_VERSION: v4.228
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1d

steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -113,14 +113,85 @@ jobs:
path: /opt/riscv
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}

- name: Setup riscv path
run: |
echo /opt/riscv/bin >> $GITHUB_PATH
build_matrix:
name: Build Smoke Test matrix
runs-on: ubuntu-22.04
needs: build_tools
outputs:
test_names: ${{ steps.output-matrix.outputs.test_names }}
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
sudo apt-get update -qy && sudo apt-get install -qy --no-install-recommends \
python3-minimal python3-yaml
- name: Build matrix
id: output-matrix
run: |
echo "test_names=$(python3 .github/scripts/build_tests_matrix.py)" >> $GITHUB_OUTPUT
build_and_test:
name: Verilator Smoke Test
runs-on: ubuntu-22.04
needs: build_matrix

strategy:
fail-fast: false
matrix:
test_name: ${{fromJSON(needs.build_matrix.outputs.test_names)}}

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'

- name: Restore Cargo index
uses: actions/cache/restore@v3
id: cargo_index_restore
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}

- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}

- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}

- name: Restore Risc V Toolchain
uses: actions/cache/restore@v3
id: riscv_restore
with:
path: /opt/riscv
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}

- name: Setup verilator path
run: |
echo /opt/verilator/bin >> $GITHUB_PATH
- name: Setup riscv path
run: |
echo /opt/riscv/bin >> $GITHUB_PATH
- name: Run Caliptra Verilator Smoke Test
run: |
# TODO: Add the run_verilator_l0_regression.py script.
# Running a simple test to make sure that there aren't any elaboration issues
CALIPTRA_ROOT=$(pwd)
cd tools/scripts
make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT TESTNAME=smoke_test_kv_uds_reset
make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT TESTNAME=${{ matrix.test_name }} | tee output.log
# Search the last 30 lines of the output for "TESTCASE PASSED"
tail -n 30 output.log | grep "TESTCASE PASSED"
# grep will return 0 if the search term is found, and 1 otherwise
# A non-zero value will cause the github action to fail.
exit $?
41 changes: 36 additions & 5 deletions src/csrng/data/csrng.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,43 @@
hwaccess: "hro",
hwqe: "true",
fields: [
{ bits: "31:0",
name: "CMD_REQ",
{ bits: "3:0",
name: "acmd",
desc: '''
Application Command: Selects one of five operations to perform.
The commands supported are instantiate, reseed, generate, update,
and uninstantiate. Each application interface port used by peripheral
hardware commands a unique instance number in CSRNG.
'''
}
{ bits: "7:4",
name: "clen",
desc: '''
Command Length: Number of 32-bit words that can optionally be appended
to the command. A value of zero will only transfer the command header.
A value of 4'hc will transfer the header plus an additional twelve
32-bit words of data.
'''
}
{ bits: "11:8",
name: "flag0",
desc: '''
Command Flag0: flag0 is associated with current command. Setting this
field to kMultiBitBool4True will enable flag0 to be enabled. Note that
flag0 is used for the instantiate and reseed commands only, for all other commands its value is ignored.
'''
}
{ bits: "24:12",
name: "glen",
desc: '''
Writing this request with defined CSRNG commands will initiate all
possible CSRNG actions. The application interface must wait for the
"ack" to return before issuing new commands.
Generate Length: Only defined for the generate command, this field
is the total number of cryptographic entropy blocks requested. Each
unit represents 128 bits of entropy returned. The NIST reference name
is max_number_of_bit_per_request, and this field size supports the
maximum size of 219 bits. For the maximum size, this field should be
set to 4096, resulting in a max_number_of_bit_per_request value of
4096 x 128 bits. For a smaller example, a value of 8 would return
a total of 1024 bits.
'''
}
]
Expand Down
21 changes: 18 additions & 3 deletions src/csrng/data/csrng.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,24 @@
"hwqe": "true",
"fields": [
{
"bits": "31:0",
"name": "CMD_REQ",
"desc": "Writing this request with defined CSRNG commands will initiate all\npossible CSRNG actions. The application interface must wait for the\n\"ack\" to return before issuing new commands."
"bits": "3:0",
"name": "acmd",
"desc": "Application Command: Selects one of five operations to perform.\nThe commands supported are instantiate, reseed, generate, update,\nand uninstantiate. Each application interface port used by peripheral\nhardware commands a unique instance number in CSRNG."
},
{
"bits": "7:4",
"name": "clen",
"desc": "Command Length: Number of 32-bit words that can optionally be appended\nto the command. A value of zero will only transfer the command header.\nA value of 4'hc will transfer the header plus an additional twelve\n32-bit words of data."
},
{
"bits": "11:8",
"name": "flag0",
"desc": "Command Flag0: flag0 is associated with current command. Setting this\nfield to kMultiBitBool4True will enable flag0 to be enabled. Note that\nflag0 is used for the instantiate and reseed commands only, for all other commands its value is ignored."
},
{
"bits": "24:12",
"name": "glen",
"desc": "Generate Length: Only defined for the generate command, this field\nis the total number of cryptographic entropy blocks requested. Each\nunit represents 128 bits of entropy returned. The NIST reference name\nis max_number_of_bit_per_request, and this field size supports the\nmaximum size of 219 bits. For the maximum size, this field should be\nset to 4096, resulting in a max_number_of_bit_per_request value of\n4096 x 128 bits. For a smaller example, a value of 8 would return\na total of 1024 bits."
}
]
},
Expand Down
35 changes: 30 additions & 5 deletions src/csrng/data/csrng.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,36 @@ addrmap csrng {
} CTRL @ 0x14;
reg {
field {
desc = "Writing this request with defined CSRNG commands will initiate all
possible CSRNG actions. The application interface must wait for the
\"ack\" to return before issuing new commands.";
desc = "Application Command: Selects one of five operations to perform.
The commands supported are instantiate, reseed, generate, update,
and uninstantiate. Each application interface port used by peripheral
hardware commands a unique instance number in CSRNG.";
sw = w;
} CMD_REQ[31:0];
} acmd[3:0];
field {
desc = "Command Length: Number of 32-bit words that can optionally be appended
to the command. A value of zero will only transfer the command header.
A value of 4'hc will transfer the header plus an additional twelve
32-bit words of data.";
sw = w;
} clen[7:4];
field {
desc = "Command Flag0: flag0 is associated with current command. Setting this
field to kMultiBitBool4True will enable flag0 to be enabled. Note that
flag0 is used for the instantiate and reseed commands only, for all other commands its value is ignored.";
sw = w;
} flag0[11:8];
field {
desc = "Generate Length: Only defined for the generate command, this field
is the total number of cryptographic entropy blocks requested. Each
unit represents 128 bits of entropy returned. The NIST reference name
is max_number_of_bit_per_request, and this field size supports the
maximum size of 219 bits. For the maximum size, this field should be
set to 4096, resulting in a max_number_of_bit_per_request value of
4096 x 128 bits. For a smaller example, a value of 8 would return
a total of 1024 bits.";
sw = w;
} glen[24:12];
} CMD_REQ @ 0x18;
reg {
field {
Expand Down Expand Up @@ -424,4 +449,4 @@ addrmap csrng {
sw = r;
} MAIN_SM_STATE[7:0] = 0x4E;
} MAIN_SM_STATE @ 0x40;
};
};
23 changes: 22 additions & 1 deletion src/integration/config/caliptra_top_tb.vf
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ ${CALIPTRA_ROOT}/src/kmac/rtl/keccak_round.sv
${CALIPTRA_ROOT}/src/kmac/rtl/keccak_2share.sv
${CALIPTRA_ROOT}/src/kmac/rtl/sha3pad.sv
${CALIPTRA_ROOT}/src/kmac/rtl/sha3.sv
${CALIPTRA_ROOT}/src/prim_generic/rtl/prim_generic_flop_en.sv
${CALIPTRA_ROOT}/src/prim_generic/rtl/prim_generic_flop.sv
${CALIPTRA_ROOT}/src/prim_generic/rtl/prim_generic_buf.sv
${CALIPTRA_ROOT}/src/prim/rtl/prim_flop_en.sv
${CALIPTRA_ROOT}/src/prim/rtl/prim_flop_2sync.sv
${CALIPTRA_ROOT}/src/prim/rtl/prim_lfsr.sv
${CALIPTRA_ROOT}/src/prim/rtl/prim_mubi4_sync.sv
Expand Down Expand Up @@ -286,4 +288,23 @@ ${CALIPTRA_ROOT}/src/csrng/rtl/csrng_block_encrypt.sv
${CALIPTRA_ROOT}/src/csrng/rtl/csrng_state_db.sv
${CALIPTRA_ROOT}/src/csrng/rtl/csrng_cmd_stage.sv
${CALIPTRA_ROOT}/src/csrng/rtl/csrng.sv
${CALIPTRA_ROOT}/src/integration/rtl/caliptra_top.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_reg_pkg.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_cmd_pkg.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_byte_merge.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_byte_select.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_command_queue.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_core.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_data_fifos.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_fsm.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_reg_top.sv
${CALIPTRA_ROOT}/src/spi_host/rtl/spi_host_shift_register.sv
${CALIPTRA_ROOT}/src/spi_host/tb/spi_device_pkg.sv
${CALIPTRA_ROOT}/src/spi_host/tb/spiflash.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart_tx.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart_reg_pkg.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart_reg_top.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart_rx.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart.sv
${CALIPTRA_ROOT}/src/uart/rtl/uart_core.sv
${CALIPTRA_ROOT}/src/integration/rtl/caliptra_top.sv
2 changes: 2 additions & 0 deletions src/integration/config/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ requires:
- soc_ifc_top
- entropy_src
- csrng
- spi_host
- uart
targets:
rtl:
directories: [$COMPILE_ROOT/rtl]
Expand Down
3 changes: 1 addition & 2 deletions src/integration/rtl/caliptra_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#ifndef CALIPTRA_REG_HEADER
#define CALIPTRA_REG_HEADER


#define CLP_BASE_ADDR (0x0)
#define CLP_DOE_REG_BASE_ADDR (0x10000000)
#define CLP_DOE_REG_DOE_IV_0 (0x10000000)
Expand Down Expand Up @@ -5591,4 +5590,4 @@
#define SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_SOC_REQ_LOCK_INTR_COUNT_INCR_R_PULSE_MASK (0x1)


#endif
#endif
4 changes: 4 additions & 0 deletions src/integration/rtl/caliptra_reg.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ addrmap clp {

sha256_reg sha256_reg @ 0x1002_8000;

spi_host spi_host_reg @ 0x2000_0000;

uart uart @ 0x2000_1000;

csrng csrng_reg @ 0x2000_2000;

entropy_src entropy_src_reg @ 0x2000_3000;
Expand Down
Loading

0 comments on commit fc68dd2

Please sign in to comment.