Skip to content

Commit 8a087cf

Browse files
Merge pull request #14 from UTOSS/boris/sv2v
Integrate `sv2v`
2 parents bd8c870 + ea089e7 commit 8a087cf

10 files changed

Lines changed: 97 additions & 21 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,18 @@ RUN umask 022 && \
2424
tar zxf - -C /usr/local --strip-components=1 && \
2525
chmod 755 /usr/local/bin
2626

27+
# install sv2v
28+
ARG SV2V_VERSION=0.0.13
29+
ARG SV2V_ZIP_NAME=sv2v-Linux.zip
30+
ARG SV2V_ZIP_URL=https://github.com/zachjs/sv2v/releases/download/v${SV2V_VERSION}/${SV2V_ZIP_NAME}
31+
ARG SV2V_ZIP_HASH="552799a1d76cd177b9b4cc63a3e77823a3d2a6eb4ec006569288abeff28e1ff8 ${SV2V_ZIP_NAME}"
32+
RUN mkdir /tmp/sv2v && \
33+
cd /tmp/sv2v && \
34+
wget ${SV2V_ZIP_URL} && \
35+
echo ${SV2V_ZIP_HASH} | sha256sum -c && \
36+
unzip ${SV2V_ZIP_NAME} && \
37+
chmod +x sv2v-Linux/sv2v && sudo cp sv2v-Linux/sv2v /usr/local/bin && \
38+
cd .. && rm -r /tmp/sv2v
39+
2740
# Install LibreLane
2841
RUN /ttsetup/venv/bin/pip install librelane==2.4.2
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Install sv2v'
2+
description: 'Install sv2v SystemVerilog to Verilog converter'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Install sv2v
7+
shell: bash
8+
run: |
9+
SV2V_VERSION=0.0.13
10+
SV2V_ZIP_NAME=sv2v-Linux.zip
11+
SV2V_ZIP_URL=https://github.com/zachjs/sv2v/releases/download/v${SV2V_VERSION}/${SV2V_ZIP_NAME}
12+
SV2V_ZIP_HASH="552799a1d76cd177b9b4cc63a3e77823a3d2a6eb4ec006569288abeff28e1ff8 ${SV2V_ZIP_NAME}"
13+
14+
mkdir /tmp/sv2v
15+
cd /tmp/sv2v
16+
wget ${SV2V_ZIP_URL}
17+
echo ${SV2V_ZIP_HASH} | sha256sum -c
18+
unzip ${SV2V_ZIP_NAME}
19+
chmod +x sv2v-Linux/sv2v
20+
sudo cp sv2v-Linux/sv2v /usr/local/bin
21+
rm -rf /tmp/sv2v

.github/workflows/docs.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,11 @@ jobs:
1313
with:
1414
submodules: recursive
1515

16+
- name: Install sv2v
17+
uses: ./.github/actions/install-sv2v
18+
19+
- name: sv2v
20+
run: make sv2v
21+
1622
- name: Build docs
1723
uses: TinyTapeout/tt-gds-action/docs@ttsky25b

.github/workflows/gds.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ jobs:
2121
with:
2222
script: |
2323
const comment = `👋 Hello! Before merging this PR, you can use the \`run-gds\` label to start the GDS workflow.
24-
24+
2525
⚠️ **Important:** The GDS workflow takes a long time (~1 hour) and consumes significant CI runtime quota.
26-
26+
2727
**Before running the GDS workflow:**
2828
1. Make sure you've run the hardening command locally first:
2929
\`\`\`bash
3030
./tt/tt_tool.py --harden
3131
\`\`\`
3232
2. Verify that the hardening command succeeded without errors
33-
33+
3434
**To run the GDS workflow:**
3535
- Add the \`run-gds\` label to this PR
3636
- The workflow will run automatically
3737
- It will also re-run on subsequent pushes while the label remains attached
38-
38+
3939
📚 For more information about the hardening command, see the [TinyTapeout GDS Action](https://github.com/TinyTapeout/tt-gds-action/blob/0d3300e15eda42ae3a24a2bd36433bdd20b32a9f/action.yml#L101-L103).`;
40-
40+
4141
github.rest.issues.createComment({
4242
issue_number: context.issue.number,
4343
owner: context.repo.owner,
@@ -55,6 +55,12 @@ jobs:
5555
with:
5656
submodules: recursive
5757

58+
- name: Install sv2v
59+
uses: ./.github/actions/install-sv2v
60+
61+
- name: sv2v
62+
run: make sv2v
63+
5864
- name: Build GDS
5965
uses: TinyTapeout/tt-gds-action@ttsky25b
6066
with:

.github/workflows/test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323
shell: bash
2424
run: pip install -r test/requirements.txt
2525

26+
- name: Install sv2v
27+
uses: ./.github/actions/install-sv2v
28+
29+
- name: sv2v
30+
run: make sv2v
31+
2632
- name: Run tests
2733
run: |
2834
cd test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
.idea
3+
*.sv2v.v
34
*.vcd
45
*.fst
56
*.fst.hier

.submodules/utoss-risc-v

Submodule utoss-risc-v updated 66 files

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Convert SystemVerilog (.sv) files to Verilog (.v) using sv2v
2+
3+
SV_FILES := $(shell find src/ -follow -name "*.sv" -type f 2>/dev/null | grep -v '/src/src')
4+
INCLUDE_FLAGS := -I src/utoss-risc-v/
5+
DEFINE_FLAGS := -DUTOSS_RISCV_HARDENING
6+
V_FILES := $(SV_FILES:.sv=.sv2v.v)
7+
8+
.PHONY: sv2v tt clean help
9+
10+
sv2v:
11+
@mkdir -p .sv2v_temp
12+
@sv2v $(INCLUDE_FLAGS) $(DEFINE_FLAGS) $(SV_FILES) -w .sv2v_temp
13+
@for svfile in $(SV_FILES); do \
14+
module_name=$$(basename "$$svfile" .sv); \
15+
if [ -f ".sv2v_temp/$$module_name.v" ]; then \
16+
mv ".sv2v_temp/$$module_name.v" "$$(dirname "$$svfile")/$$module_name.sv2v.v"; \
17+
fi; \
18+
done
19+
@rm -rf .sv2v_temp
20+
21+
tt: sv2v
22+
./tt/tt_tool.py --create-user-config
23+
./tt/tt_tool.py --harden
24+
25+
clean:
26+
@rm -f $(V_FILES)

info.yaml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project:
88
clock_hz: 0 # Clock frequency in Hz (or 0 if not applicable)
99

1010
# How many tiles your design occupies? A single tile is about 167x108 uM.
11-
tiles: "4x2" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2
11+
tiles: "8x2" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2
1212

1313
# Your top module name must start with "tt_um_". Make it unique by including your github username:
1414
top_module: "tt_um_utoss_riscv"
@@ -17,19 +17,16 @@ project:
1717
# Source files must be in ./src and you must list each source file separately, one per line.
1818
# Don't forget to also update `PROJECT_SOURCES` in test/Makefile.
1919
source_files:
20-
- "tt_um_utoss_riscv.sv"
21-
- "MA.sv"
22-
- "utoss-risc-v/src/ALU_ALUdecoder/ALU.v"
23-
- "utoss-risc-v/src/ALU_ALUdecoder/ALUdecoder.sv"
24-
- "utoss-risc-v/src/ControlFSM.sv"
25-
- "utoss-risc-v/src/fetch.sv"
26-
- "utoss-risc-v/src/Instruction_Decode/Instruction_Decode.sv"
27-
- "utoss-risc-v/src/Instruction_Decode/MemoryLoader.sv"
28-
- "utoss-risc-v/src/Instruction_Decode/RegisterFile.v"
29-
- "utoss-risc-v/src/params.svh"
30-
- "utoss-risc-v/src/types.svh"
31-
- "utoss-risc-v/src/utils.svh"
32-
- "utoss-risc-v/src/utoss_riscv.sv"
20+
- "tt_um_utoss_riscv.sv2v.v"
21+
- "MA.sv2v.v"
22+
- "utoss-risc-v/src/ALU_ALUdecoder/ALU.sv2v.v"
23+
- "utoss-risc-v/src/ALU_ALUdecoder/ALUdecoder.sv2v.v"
24+
- "utoss-risc-v/src/ControlFSM.sv2v.v"
25+
- "utoss-risc-v/src/fetch.sv2v.v"
26+
- "utoss-risc-v/src/Instruction_Decode/Instruction_Decode.sv2v.v"
27+
- "utoss-risc-v/src/Instruction_Decode/MemoryLoader.sv2v.v"
28+
- "utoss-risc-v/src/Instruction_Decode/registerFile.v"
29+
- "utoss-risc-v/src/utoss_riscv.sv2v.v"
3330

3431
# The pinout of your project. Leave unused pins blank. DO NOT delete or add any pins.
3532
# This section is for the datasheet/website. Use descriptive names (e.g., RX, TX, MOSI, SCL, SEG_A, etc.).

test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SIM ?= icarus
66
FST ?= -fst # Use more efficient FST format
77
TOPLEVEL_LANG ?= verilog
88
SRC_DIR = $(PWD)/../src
9-
PROJECT_SOURCES = tt_um_utoss_riscv.sv MA.sv utoss-risc-v/src/ALU_ALUdecoder/ALU.v utoss-risc-v/src/ALU_ALUdecoder/ALUdecoder.sv utoss-risc-v/src/ControlFSM.sv utoss-risc-v/src/fetch.sv utoss-risc-v/src/Instruction_Decode/Instruction_Decode.sv utoss-risc-v/src/Instruction_Decode/MemoryLoader.sv utoss-risc-v/src/Instruction_Decode/RegisterFile.v utoss-risc-v/src/params.svh utoss-risc-v/src/types.svh utoss-risc-v/src/utils.svh utoss-risc-v/src/utoss_riscv.sv
9+
PROJECT_SOURCES = tt_um_utoss_riscv.sv MA.sv utoss-risc-v/src/ALU_ALUdecoder/ALU.sv utoss-risc-v/src/ALU_ALUdecoder/ALUdecoder.sv utoss-risc-v/src/ControlFSM.sv utoss-risc-v/src/fetch.sv utoss-risc-v/src/Instruction_Decode/Instruction_Decode.sv utoss-risc-v/src/Instruction_Decode/MemoryLoader.sv utoss-risc-v/src/Instruction_Decode/registerFile.v utoss-risc-v/src/params.svh utoss-risc-v/src/types.svh utoss-risc-v/src/utils.svh utoss-risc-v/src/utoss_riscv.sv
1010
COMPILE_ARGS += -DUTOSS_RISCV_HARDENING
1111

1212
ifneq ($(GATES),yes)

0 commit comments

Comments
 (0)