From 1fcb70209582fd05c03919b31502deb2b7af472a Mon Sep 17 00:00:00 2001 From: Chat <63841542+ChillZero@users.noreply.github.com> Date: Thu, 14 May 2026 19:58:51 -0700 Subject: Add simple_alu RTL and formal verification - simple_alu.sv: 32-bit ALU with add/sub, 33-bit extended overflow detection, and active-low synchronous reset - simple_alu_bind.sv: attaches checker to simple_alu without modifying RTL - simple_alu_top_fv.sv: replace bind (unsupported in open-source Yosys) with explicit wrapper that instantiates DUT and checker side-by-side - simple_alu_fv.sv: bind-based checker module observing DUT signals - simple_alu.sby: SymbiYosys config running BMC and cover tasks - README.md: verification plan tracking implemented and planned properties - .gitignore: exclude SymbiYosys output directories --- .gitignore | 5 +++ rtl/regfile.sv | 0 rtl/simple_alu.sv | 44 ++++++++++++++++++++++++ verif/formal/simple_alu/README.md | 23 +++++++++++++ verif/formal/simple_alu/simple_alu.sby | 22 ++++++++++++ verif/formal/simple_alu/simple_alu_bind.sv | 15 ++++++++ verif/formal/simple_alu/simple_alu_fv.sv | 51 ++++++++++++++++++++++++++++ verif/formal/simple_alu/simple_alu_top_fv.sv | 29 ++++++++++++++++ verif/uvm/env.sv | 0 9 files changed, 189 insertions(+) create mode 100644 rtl/regfile.sv create mode 100644 rtl/simple_alu.sv create mode 100644 verif/formal/simple_alu/README.md create mode 100644 verif/formal/simple_alu/simple_alu.sby create mode 100644 verif/formal/simple_alu/simple_alu_bind.sv create mode 100644 verif/formal/simple_alu/simple_alu_fv.sv create mode 100644 verif/formal/simple_alu/simple_alu_top_fv.sv create mode 100644 verif/uvm/env.sv diff --git a/.gitignore b/.gitignore index 59a8a35..ad3001c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,8 @@ *.swo .vscode .claude/ + +# SymbiYosys output +verif/formal/simple_alu/simple_alu/ +verif/formal/simple_alu/simple_alu_bmc/ +verif/formal/simple_alu/simple_alu_cover/ diff --git a/rtl/regfile.sv b/rtl/regfile.sv new file mode 100644 index 0000000..e69de29 diff --git a/rtl/simple_alu.sv b/rtl/simple_alu.sv new file mode 100644 index 0000000..8dc0586 --- /dev/null +++ b/rtl/simple_alu.sv @@ -0,0 +1,44 @@ +// Simple 32-bit ALU supporting addition and subtraction (sel=0/1). +// Outputs are registered. Overflow/underflow detected via 33-bit extended arithmetic. +// Active-low synchronous reset. Used as a sandbox for formal verification. +module simple_alu ( + + //inputs + input logic clk, + input logic [31:0] a, + input logic [31:0] b, + input logic sel, //sel = 0 -> ADD, sel = 1 -> SUB + input logic rst, //active LOW sync reset + + //outputs + output logic [31:0] y, + output logic overflow +); + + logic [32:0] sum; + logic [32:0] diff; + + always_comb begin + sum = {1'b0, a} + {1'b0, b}; + diff = {1'b0, a} - {1'b0, b}; + end + + always_ff @(posedge clk) begin + if (~rst) begin + y <= '0; + overflow <= '0; + end + else begin + case (sel) + 0: begin + y <= sum[31:0]; + overflow <= sum[32]; + end + 1: begin + y <= diff[31:0]; + overflow <= diff[32]; + end + endcase + end + end +endmodule diff --git a/verif/formal/simple_alu/README.md b/verif/formal/simple_alu/README.md new file mode 100644 index 0000000..3355ced --- /dev/null +++ b/verif/formal/simple_alu/README.md @@ -0,0 +1,23 @@ +# simple_alu Formal Verification + +Run with: `sby -f simple_alu.sby` from this directory. + +Reference: https://yosyshq.readthedocs.io/projects/sby/en/latest/reference.html + +## Mode + +Bounded Model Check (BMC, depth=100): proves assertions hold for the first 100 clock cycles. +A counterexample waveform is generated on failure. + +Prove mode (k-induction): proves assertions hold for infinite time. Much stronger guarantee but harder to converge. Change `mode bmc` to `mode prove` in the `.sby` to use it. + +## Properties + +| Name | Status | Description | +|-------------------|-------------|------------------------------------------| +| `a_rst_check` | implemented | y == 0 one cycle after reset asserts | +| `a_rst_overflow` | planned | overflow == 0 one cycle after reset | +| `a_add` | planned | y == a+b one cycle after sel=0 | +| `a_sub` | planned | y == a-b one cycle after sel=1 | +| `a_overflow_add` | planned | overflow correct for addition | +| `a_overflow_sub` | planned | overflow correct for subtraction | \ No newline at end of file diff --git a/verif/formal/simple_alu/simple_alu.sby b/verif/formal/simple_alu/simple_alu.sby new file mode 100644 index 0000000..cd028d9 --- /dev/null +++ b/verif/formal/simple_alu/simple_alu.sby @@ -0,0 +1,22 @@ +[tasks] +bmc +cover + +[options] +bmc: mode bmc +cover: mode cover +depth 100 + +[engines] +smtbmc + +[script] +read -formal -sv simple_alu.sv +read -formal -sv simple_alu_fv.sv +read -formal -sv simple_alu_top_fv.sv +prep -top simple_alu_top_fv + +[files] +../../../rtl/simple_alu.sv +simple_alu_fv.sv +simple_alu_top_fv.sv diff --git a/verif/formal/simple_alu/simple_alu_bind.sv b/verif/formal/simple_alu/simple_alu_bind.sv new file mode 100644 index 0000000..b12e0eb --- /dev/null +++ b/verif/formal/simple_alu/simple_alu_bind.sv @@ -0,0 +1,15 @@ +// Bind file for simple_alu formal verification. +// Attaches simple_alu_fv to every instance of simple_alu in the design. +// RTL is completely unaware of this file. +// +// bind (); + +bind simple_alu simple_alu_fv u_simple_alu_fv ( + .clk (clk), + .rst (rst), + .a (a), + .b (b), + .sel (sel), + .y (y), + .overflow (overflow) +); \ No newline at end of file diff --git a/verif/formal/simple_alu/simple_alu_fv.sv b/verif/formal/simple_alu/simple_alu_fv.sv new file mode 100644 index 0000000..ea9700a --- /dev/null +++ b/verif/formal/simple_alu/simple_alu_fv.sv @@ -0,0 +1,51 @@ +// Formal verification module for simple_alu. +// All ports are inputs - this module only observes DUT signals, never drives them. +// Instantiated via simple_alu_top_fv.sv wrapper (bind unsupported in open-source Yosys). +module simple_alu_fv ( + input logic clk, + input logic [31:0] a, + input logic [31:0] b, + input logic sel, + input logic rst, + + input logic [31:0] y, + input logic overflow + ); + + // ------------------------------------------------------------------------- + // Initial assumptions - constrain starting state so solver doesn't + // explore garbage initial register values + // ------------------------------------------------------------------------- + initial assume(~rst); + initial assume(y == '0); + initial assume(overflow == 1'b0); + + //assertion check: if rst deasserted, y tied to 0 + //assertions are what we want to prove, formal verification is the engine that proves it + // property p_rst_y; + // @(posedge clk) + // ~rst |=> (y=='0); + // endproperty + // a_rst_y: assert property (p_rst_y) + // else $error("RESET CHECK FAILED: rst=%0b y=%0h, expected y=0", rst, y); + + // Reset check - y must be 0 one cycle after reset asserts (active low) + always @(posedge clk) begin + if ( $past(~rst)) begin + assert (y == '0); + assert (overflow == 0); + end + end + + // ------------------------------------------------------------------------- + // Cover statements - solver finds shortest path to reach each state + // These generate VCD traces you can inspect in GTKWave + // ------------------------------------------------------------------------- + + always @(posedge clk) begin + cover ($past(sel == 0) && overflow == 1'b1); // addition overflow + cover ($past(sel == 1) && overflow == 1'b1); // subtraction underflow + end + + +endmodule diff --git a/verif/formal/simple_alu/simple_alu_top_fv.sv b/verif/formal/simple_alu/simple_alu_top_fv.sv new file mode 100644 index 0000000..2292713 --- /dev/null +++ b/verif/formal/simple_alu/simple_alu_top_fv.sv @@ -0,0 +1,29 @@ +// Wrapper top module for formal verification of simple_alu. +// Instantiates the DUT and the checker side-by-side so the formal tool +// sees both. Used because open-source Yosys does not support bind. +// Note: only DUT ports are accessible here - internal signals (sum, diff) +// cannot be tapped without bind or Verific. +module simple_alu_top_fv ( + input logic clk, + input logic [31:0] a, + input logic [31:0] b, + input logic sel, + input logic rst +); + logic [31:0] y; + logic overflow; + + // DUT instance + simple_alu dut (.*); + + // Checker instance - observes DUT outputs + simple_alu_fv u_checker ( + .clk (clk), + .a (a), + .b (b), + .sel (sel), + .rst (rst), + .y (y), + .overflow (overflow) + ); +endmodule diff --git a/verif/uvm/env.sv b/verif/uvm/env.sv new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 429dd4fa609a5b8c71f8cd6ae6f8d74fd59f2280 Mon Sep 17 00:00:00 2001 From: Chat <63841542+chatrajaman3@users.noreply.github.com> Date: Tue, 19 May 2026 01:31:06 -0700 Subject: Pass linter - simple_alu.sv: rename ports with suffixes (clk_i, rst_ni, a_i, b_i, sel_i, y_o, overflow_o); add default case to sel case statement; add y_next and overflow_next combinational signals; simplify always_ff to only register y_next and overflow_next - simple_alu_fv.sv: rename ports to match RTL (clk_i, rst_ni, a_i, b_i, sel_i, y_i, overflow_i); remove trailing spaces - simple_alu_top_fv.sv: rename ports; replace .* with explicit connections to match updated port names - simple_alu_bind.sv: add missing posix newline at EOF --- rtl/simple_alu.sv | 64 +++++++++++++++++----------- verif/formal/simple_alu/simple_alu_bind.sv | 2 +- verif/formal/simple_alu/simple_alu_fv.sv | 45 ++++++++++--------- verif/formal/simple_alu/simple_alu_top_fv.sv | 34 +++++++++------ 4 files changed, 83 insertions(+), 62 deletions(-) diff --git a/rtl/simple_alu.sv b/rtl/simple_alu.sv index 8dc0586..a5ae9e7 100644 --- a/rtl/simple_alu.sv +++ b/rtl/simple_alu.sv @@ -4,41 +4,55 @@ module simple_alu ( //inputs - input logic clk, - input logic [31:0] a, - input logic [31:0] b, - input logic sel, //sel = 0 -> ADD, sel = 1 -> SUB - input logic rst, //active LOW sync reset + input logic clk_i, + input logic [31:0] a_i, + input logic [31:0] b_i, + input logic sel_i, //sel = 0 -> ADD, sel = 1 -> SUB + input logic rst_ni, //active LOW sync reset //outputs - output logic [31:0] y, - output logic overflow + output logic [31:0] y_o, + output logic overflow_o ); logic [32:0] sum; logic [32:0] diff; + logic [31:0] y_r; + logic overflow_r; + logic [31:0] y_next; + logic overflow_next; always_comb begin - sum = {1'b0, a} + {1'b0, b}; - diff = {1'b0, a} - {1'b0, b}; - end + sum = {1'b0, a_i} + {1'b0, b_i}; + diff = {1'b0, a_i} - {1'b0, b_i}; - always_ff @(posedge clk) begin - if (~rst) begin - y <= '0; - overflow <= '0; - end - else begin - case (sel) - 0: begin - y <= sum[31:0]; - overflow <= sum[32]; - end - 1: begin - y <= diff[31:0]; - overflow <= diff[32]; + y_next = '0; + overflow_next = '0; + + if (rst_ni) begin + case (sel_i) + 0: begin + y_next = sum[31:0]; + overflow_next = sum[32]; + end + 1: begin + y_next = diff[31:0]; + overflow_next = diff[32]; + end + default: begin + y_next = '0; + overflow_next = '0; + end + endcase end - endcase end + + always_ff @(posedge clk_i) begin + y_r <= y_next; + overflow_r <= overflow_next; end + + assign y_o = y_r; + assign overflow_o = overflow_r; + endmodule diff --git a/verif/formal/simple_alu/simple_alu_bind.sv b/verif/formal/simple_alu/simple_alu_bind.sv index b12e0eb..8ed7057 100644 --- a/verif/formal/simple_alu/simple_alu_bind.sv +++ b/verif/formal/simple_alu/simple_alu_bind.sv @@ -12,4 +12,4 @@ bind simple_alu simple_alu_fv u_simple_alu_fv ( .sel (sel), .y (y), .overflow (overflow) -); \ No newline at end of file +); diff --git a/verif/formal/simple_alu/simple_alu_fv.sv b/verif/formal/simple_alu/simple_alu_fv.sv index ea9700a..98c05a7 100644 --- a/verif/formal/simple_alu/simple_alu_fv.sv +++ b/verif/formal/simple_alu/simple_alu_fv.sv @@ -2,38 +2,38 @@ // All ports are inputs - this module only observes DUT signals, never drives them. // Instantiated via simple_alu_top_fv.sv wrapper (bind unsupported in open-source Yosys). module simple_alu_fv ( - input logic clk, - input logic [31:0] a, - input logic [31:0] b, - input logic sel, - input logic rst, - - input logic [31:0] y, - input logic overflow + input logic clk_i, + input logic [31:0] a_i, + input logic [31:0] b_i, + input logic sel_i, + input logic rst_ni, + + input logic [31:0] y_i, + input logic overflow_i ); // ------------------------------------------------------------------------- // Initial assumptions - constrain starting state so solver doesn't // explore garbage initial register values // ------------------------------------------------------------------------- - initial assume(~rst); - initial assume(y == '0); - initial assume(overflow == 1'b0); + initial assume (~rst_ni); + initial assume (y_i == '0); + initial assume (overflow_i == 1'b0); //assertion check: if rst deasserted, y tied to 0 //assertions are what we want to prove, formal verification is the engine that proves it - // property p_rst_y; - // @(posedge clk) - // ~rst |=> (y=='0); + // property p_rst_y; + // @(posedge clk_i) + // ~rst_ni |=> (y_i=='0); // endproperty // a_rst_y: assert property (p_rst_y) - // else $error("RESET CHECK FAILED: rst=%0b y=%0h, expected y=0", rst, y); + // else $error("RESET CHECK FAILED: rst_ni=%0b y_i=%0h, expected y=0", rst_ni, y_i); // Reset check - y must be 0 one cycle after reset asserts (active low) - always @(posedge clk) begin - if ( $past(~rst)) begin - assert (y == '0); - assert (overflow == 0); + always @(posedge clk_i) begin + if ($past(~rst_ni)) begin + assert (y_i == '0); + assert (overflow_i == 0); end end @@ -42,10 +42,9 @@ module simple_alu_fv ( // These generate VCD traces you can inspect in GTKWave // ------------------------------------------------------------------------- - always @(posedge clk) begin - cover ($past(sel == 0) && overflow == 1'b1); // addition overflow - cover ($past(sel == 1) && overflow == 1'b1); // subtraction underflow + always @(posedge clk_i) begin + cover ($past(sel_i == 0) && overflow_i == 1'b1); // addition overflow + cover ($past(sel_i == 1) && overflow_i == 1'b1); // subtraction underflow end - endmodule diff --git a/verif/formal/simple_alu/simple_alu_top_fv.sv b/verif/formal/simple_alu/simple_alu_top_fv.sv index 2292713..8f1241c 100644 --- a/verif/formal/simple_alu/simple_alu_top_fv.sv +++ b/verif/formal/simple_alu/simple_alu_top_fv.sv @@ -4,26 +4,34 @@ // Note: only DUT ports are accessible here - internal signals (sum, diff) // cannot be tapped without bind or Verific. module simple_alu_top_fv ( - input logic clk, - input logic [31:0] a, - input logic [31:0] b, - input logic sel, - input logic rst + input logic clk_i, + input logic [31:0] a_i, + input logic [31:0] b_i, + input logic sel_i, + input logic rst_ni ); logic [31:0] y; logic overflow; // DUT instance - simple_alu dut (.*); + simple_alu dut ( + .clk_i (clk_i), + .a_i (a_i), + .b_i (b_i), + .sel_i (sel_i), + .rst_ni (rst_ni), + .y_o (y), + .overflow_o (overflow) + ); // Checker instance - observes DUT outputs simple_alu_fv u_checker ( - .clk (clk), - .a (a), - .b (b), - .sel (sel), - .rst (rst), - .y (y), - .overflow (overflow) + .clk_i (clk_i), + .a_i (a_i), + .b_i (b_i), + .sel_i (sel_i), + .rst_ni (rst_ni), + .y_i (y), + .overflow_i (overflow) ); endmodule -- cgit v1.2.3 From 2090c730e8a3ba069da7459b3130bf351403d6ae Mon Sep 17 00:00:00 2001 From: Warrick Lo Date: Sat, 23 May 2026 22:10:42 -0700 Subject: Add WaveDrom diagrams for instructions to README Signed-off-by: Warrick Lo --- README.md | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e8807da..6b1628c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# Montreal +Montreal +======== A RISC-V RV32E processor designed for TinyTapeout. -## [RV32E](https://docs.riscv.org/reference/isa/unpriv/unpriv-index.html) +[RV32E](https://docs.riscv.org/reference/isa/unpriv/unpriv-index.html) +---------------------------------------------------------------------- Reduces number of integer registers to 16 general-purpose registers (x0-x15). Upper 16 registers consume around one quarter of the total area of the core excluding memories, thus their removal saves around 25% core area with a corresponding core power reduction. @@ -28,26 +30,32 @@ Each register is 32 bits wide. | x15 | sixth function argument | | | pc | program counter | Address of current instruction | -## INSTRUCTION SET +INSTRUCTION SET +--------------- + ### Formats -``` - 31 25 24 20 19 15 14 12 11 7 6 0 - +----------+--------+--------+-------+--------+----------+ -R | funct7 | rs2 | rs1 | funct3| rd | opcode | - +----------+--------+--------+-------+--------+----------+ - (src2) (src1) (dest) - +-------------------+--------+-------+--------+----------+ -I | imm[11:0] | rs1 | funct3| rd | opcode | - +-------------------+--------+-------+--------+----------+ - (src) (dest) - +----------+--------+--------+-------+--------+----------+ -I-sh | imm[11:5]|imm[4:0]| rs1 | funct3| rd | opcode | - +----------+--------+--------+-------+--------+----------+ - (src) (dest) -``` - -I-sh is the shift variant of I-type: `imm[11:5]` acts as a discriminator (like `funct7`), and `imm[4:0]` is the shift amount (shamt). +![U-type instructions (LUI)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/u-type-lui.json5) + +![U-type instructions (AUIPC)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/u-type-auipc.json5) + +![J-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/j-type.json5) + +![I-type instructions (JALR)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-jalr.json5) + +![B-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/b-type.json5) + +![I-type instructions (load)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-load.json5) + +![S-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/s-type.json5) + +![I-type instructions (arithmetic and logic)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-alu.json5) + +![I-type instructions (shift)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-shift.json5) + +![R-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/r-type.json5) + +![I-type instructions (system)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-system.json5) ### R-Type (Register-to-register) @@ -83,5 +91,3 @@ I-sh is the shift variant of I-type: `imm[11:5]` acts as a discriminator (like ` | SLLI | Shift rs1 left by shamt (`imm[4:0]`), logical, store in rd. | `0000000` \| `001` \| `0010011` | | SRLI | Shift rs1 right by shamt (`imm[4:0]`), logical, store in rd. | `0000000` \| `101` \| `0010011` | | SRAI | Shift rs1 right by shamt (`imm[4:0]`), arithmetic, store in rd. | `0100000` \| `101` \| `0010011` | - - -- cgit v1.2.3 From 59db9335448b568ccff9964aec0626a23387597f Mon Sep 17 00:00:00 2001 From: Warrick Lo Date: Wed, 27 May 2026 20:40:30 -0700 Subject: Update README and WaveDrom diagrams [skip ci] Signed-off-by: Warrick Lo --- README.adoc | 248 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 93 ----------------- docs/images/add.svg | 1 + docs/images/addi.svg | 1 + docs/images/and.svg | 1 + docs/images/andi.svg | 1 + docs/images/auipc.svg | 1 + docs/images/b-immediate.svg | 1 + docs/images/beq.svg | 1 + docs/images/bge.svg | 1 + docs/images/bgeu.svg | 1 + docs/images/blt.svg | 1 + docs/images/bltu.svg | 1 + docs/images/bne.svg | 1 + docs/images/czero.eqz.svg | 1 + docs/images/czero.nez.svg | 1 + docs/images/ebreak.svg | 1 + docs/images/ecall.svg | 1 + docs/images/fence.svg | 1 + docs/images/i-immediate.svg | 1 + docs/images/j-immediate.svg | 1 + docs/images/jal.svg | 1 + docs/images/jalr.svg | 1 + docs/images/lb.svg | 1 + docs/images/lbu.svg | 1 + docs/images/lh.svg | 1 + docs/images/lhu.svg | 1 + docs/images/lui.svg | 1 + docs/images/lw.svg | 1 + docs/images/or.svg | 1 + docs/images/ori.svg | 1 + docs/images/s-immediate.svg | 1 + docs/images/sb.svg | 1 + docs/images/sh.svg | 1 + docs/images/sll.svg | 1 + docs/images/slli.svg | 1 + docs/images/slt.svg | 1 + docs/images/slti.svg | 1 + docs/images/sltiu.svg | 1 + docs/images/sltu.svg | 1 + docs/images/sra.svg | 1 + docs/images/srai.svg | 1 + docs/images/srl.svg | 1 + docs/images/srli.svg | 1 + docs/images/sub.svg | 1 + docs/images/sw.svg | 1 + docs/images/u-immediate.svg | 1 + docs/images/xor.svg | 1 + docs/images/xori.svg | 1 + 49 files changed, 295 insertions(+), 93 deletions(-) create mode 100644 README.adoc delete mode 100644 README.md create mode 100644 docs/images/add.svg create mode 100644 docs/images/addi.svg create mode 100644 docs/images/and.svg create mode 100644 docs/images/andi.svg create mode 100644 docs/images/auipc.svg create mode 100644 docs/images/b-immediate.svg create mode 100644 docs/images/beq.svg create mode 100644 docs/images/bge.svg create mode 100644 docs/images/bgeu.svg create mode 100644 docs/images/blt.svg create mode 100644 docs/images/bltu.svg create mode 100644 docs/images/bne.svg create mode 100644 docs/images/czero.eqz.svg create mode 100644 docs/images/czero.nez.svg create mode 100644 docs/images/ebreak.svg create mode 100644 docs/images/ecall.svg create mode 100644 docs/images/fence.svg create mode 100644 docs/images/i-immediate.svg create mode 100644 docs/images/j-immediate.svg create mode 100644 docs/images/jal.svg create mode 100644 docs/images/jalr.svg create mode 100644 docs/images/lb.svg create mode 100644 docs/images/lbu.svg create mode 100644 docs/images/lh.svg create mode 100644 docs/images/lhu.svg create mode 100644 docs/images/lui.svg create mode 100644 docs/images/lw.svg create mode 100644 docs/images/or.svg create mode 100644 docs/images/ori.svg create mode 100644 docs/images/s-immediate.svg create mode 100644 docs/images/sb.svg create mode 100644 docs/images/sh.svg create mode 100644 docs/images/sll.svg create mode 100644 docs/images/slli.svg create mode 100644 docs/images/slt.svg create mode 100644 docs/images/slti.svg create mode 100644 docs/images/sltiu.svg create mode 100644 docs/images/sltu.svg create mode 100644 docs/images/sra.svg create mode 100644 docs/images/srai.svg create mode 100644 docs/images/srl.svg create mode 100644 docs/images/srli.svg create mode 100644 docs/images/sub.svg create mode 100644 docs/images/sw.svg create mode 100644 docs/images/u-immediate.svg create mode 100644 docs/images/xor.svg create mode 100644 docs/images/xori.svg diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..694dcad --- /dev/null +++ b/README.adoc @@ -0,0 +1,248 @@ +Montreal +======== +:revnumber: 0.1.0-draft + +A RISC-V RV32E processor designed for TinyTapeout. + +RV32E +----- + +https://docs.riscv.org/reference/isa/unpriv/unpriv-index.html[ISA Reference] + +Reduces number of integer registers to 16 general-purpose registers +(x0-x15). Upper 16 registers consume around one quarter of the total +area of the core excluding memories, thus their removal saves around 25% +core area with a corresponding core power reduction. + +Each register is 32 bits wide. + +[cols="1,2,4", options="header"] +|=== + +| Register +| Description +| Purpose + +| x0 +| dedicated zero +| Source operand for value 0. + +| x1 +| return address +| Written by JAL/JALR. Holds address to be returned to once a function returns. +Must be saved to stack before calling another function. + +| x2 +| stack pointer +| Always points to top of the stack in RAM. Decremented to allocate space, +incremented to free it. CALLEE must restore it BEFORE returning. + +| x3 +| global pointer +| + +| x4 +| thread pointer +| + +| x5 +| alternate link reg +| Second link register for nested JAL sequences. Caller must save +if needed across a call. + +| x6 +| general scratch reg +| + +| x7 +| general scratch reg +| + +| x8 +| frame pointer +| + +| x9 +| saved register +| + +| x10 +| first function argument +| Also used to return integer results from function. + +| x11 +| second function argument +| + +| x12 +| third function argument +| + +| x13 +| fourth function argument +| + +| x14 +| fifth function argument +| + +| x15 +| sixth function argument +| + +| pc +| program counter +| Address of current instruction + +|=== + +Instruction Set +--------------- + +.Relevant opcodes for the IP. `inst[1:0] = 11`. +[cols="2*^1m,8*^2m", hrows=2] +|=== + +| +| +8+^| inst[4:2] + +| +| +| 000 +| 001 +| 010 +| 011 +| 100 +| 101 +| 110 +| 111 + +1.4+.^| inst[6:5] +| 00 +| LOAD +| +| +| MISC-MEM +| OP-IMM +| AUIPC +| +| + +| 01 +| STORE +| +| +| +| OP +| LUI +| +| + +| 10 +| +| +| +| +| +| +| +| + +| 11 +| BRANCH +| JALR +| +| JAL +| SYSTEM +| +| +| +|=== + +=== Immediate Types + +The labels `[7]`, `[20]`, and `[31]` represent the bits `inst[7]`, `inst[20]`, and `inst[31]`, respectively. + +image::docs/images/i-immediate.svg[width=100%] +image::docs/images/s-immediate.svg[width=100%] +image::docs/images/b-immediate.svg[width=100%] +image::docs/images/u-immediate.svg[width=100%] +image::docs/images/j-immediate.svg[width=100%] + +=== LUI + +image::docs/images/lui.svg[width=100%] + +=== AUIPC + +image::docs/images/auipc.svg[width=100%] + +=== OP-IMM + +image::docs/images/addi.svg[width=100%] +image::docs/images/slti.svg[width=100%] +image::docs/images/sltiu.svg[width=100%] +image::docs/images/xori.svg[width=100%] +image::docs/images/ori.svg[width=100%] +image::docs/images/andi.svg[width=100%] +image::docs/images/slli.svg[width=100%] +image::docs/images/srli.svg[width=100%] +image::docs/images/srai.svg[width=100%] + +=== OP + +image::docs/images/add.svg[width=100%] +image::docs/images/sub.svg[width=100%] +image::docs/images/slt.svg[width=100%] +image::docs/images/sltu.svg[width=100%] +image::docs/images/xor.svg[width=100%] +image::docs/images/or.svg[width=100%] +image::docs/images/and.svg[width=100%] +image::docs/images/sll.svg[width=100%] +image::docs/images/srl.svg[width=100%] +image::docs/images/sra.svg[width=100%] +image::docs/images/czero.eqz.svg[width=100%] +image::docs/images/czero.nez.svg[width=100%] + +=== JAL + +image::docs/images/jal.svg[width=100%] + +=== JALR + +image::docs/images/jalr.svg[width=100%] + +=== BRANCH + +The labels `[11]` and `[12]` represent the bits `imm[11]` and `imm[12]` respectively. + +image::docs/images/beq.svg[width=100%] +image::docs/images/bne.svg[width=100%] +image::docs/images/blt.svg[width=100%] +image::docs/images/bge.svg[width=100%] +image::docs/images/bltu.svg[width=100%] +image::docs/images/bgeu.svg[width=100%] + +=== LOAD + +image::docs/images/lb.svg[width=100%] +image::docs/images/lh.svg[width=100%] +image::docs/images/lw.svg[width=100%] +image::docs/images/lbu.svg[width=100%] +image::docs/images/lhu.svg[width=100%] + +=== STORE + +image::docs/images/sb.svg[width=100%] +image::docs/images/sh.svg[width=100%] +image::docs/images/sw.svg[width=100%] + +=== MISC-MEM + +image::docs/images/fence.svg[width=100%] + +=== SYSTEM + +image::docs/images/ecall.svg[width=100%] +image::docs/images/ebreak.svg[width=100%] diff --git a/README.md b/README.md deleted file mode 100644 index 6b1628c..0000000 --- a/README.md +++ /dev/null @@ -1,93 +0,0 @@ -Montreal -======== - -A RISC-V RV32E processor designed for TinyTapeout. - -[RV32E](https://docs.riscv.org/reference/isa/unpriv/unpriv-index.html) ----------------------------------------------------------------------- - -Reduces number of integer registers to 16 general-purpose registers (x0-x15). Upper 16 registers consume around one quarter of the total area of the core excluding memories, thus their removal saves around 25% core area with a corresponding core power reduction. - -Each register is 32 bits wide. - -| Register | Description | Purpose | -| -------- | ----------- | ------- | -| x0 | dedicated zero | Source operand for value 0. | -| x1 | return address | Written by JAL/JALR. Holds address to be returned to once a function returns. Must be saved to stack before calling another function. | -| x2 | stack pointer | Always points to top of the stack in RAM. Decremented to allocate space, incremented to free it. CALLEE must restore it BEFORE returning. | -| x3 | global pointer | | -| x4 | thread pointer | | -| x5 | alternate link reg | Second link register for nested JAL sequences. Caller must save if needed across a call. | -| x6 | general scratch reg | | -| x7 | general scratch reg | | -| x8 | frame pointer | | -| x9 | saved register | | -| x10 | first function argument | Also used to return integer results from function. | -| x11 | second function argument | | -| x12 | third function argument | | -| x13 | fourth function argument | | -| x14 | fifth function argument | | -| x15 | sixth function argument | | -| pc | program counter | Address of current instruction | - -INSTRUCTION SET ---------------- - -### Formats - -![U-type instructions (LUI)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/u-type-lui.json5) - -![U-type instructions (AUIPC)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/u-type-auipc.json5) - -![J-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/j-type.json5) - -![I-type instructions (JALR)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-jalr.json5) - -![B-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/b-type.json5) - -![I-type instructions (load)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-load.json5) - -![S-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/s-type.json5) - -![I-type instructions (arithmetic and logic)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-alu.json5) - -![I-type instructions (shift)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-shift.json5) - -![R-type instructions](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/r-type.json5) - -![I-type instructions (system)](https://svg.wavedrom.com/github/ubc-asic/montreal-docs/master/images/i-type-system.json5) - -### R-Type (Register-to-register) - -| Instruction | Description | Encoding (`funct7` \| `funct3` \| `opcode`) | -| ----------- | ----------- | ------------------------------------------ | -| ADD | Add two registers and store the result in rd. | `0000000` \| `000` \| `0110011` | -| SUB | Subtract rs2 from rs1 and store the result in rd. | `0100000` \| `000` \| `0110011` | -| SLL | Shift rs1 left by the amount in rs2 (logical), store result in rd. | `0000000` \| `001` \| `0110011` | -| SLT | Set rd to 1 if rs1 < rs2 (signed), otherwise 0. | `0000000` \| `010` \| `0110011` | -| SLTU | Set rd to 1 if rs1 < rs2 (unsigned), otherwise 0. | `0000000` \| `011` \| `0110011` | -| XOR | Bitwise XOR of rs1 and rs2, result in rd. | `0000000` \| `100` \| `0110011` | -| SRL | Shift rs1 right by the amount in rs2 (logical), store result in rd. | `0000000` \| `101` \| `0110011` | -| SRA | Shift rs1 right by the amount in rs2 (arithmetic), sign-extend result into rd. | `0100000` \| `101` \| `0110011` | -| OR | Bitwise OR of rs1 and rs2, result in rd. | `0000000` \| `110` \| `0110011` | -| AND | Bitwise AND of rs1 and rs2, result in rd. | `0000000` \| `111` \| `0110011` | - -### I-Type (Immediate) - -#### OP-IMM — Integer immediate ops (opcode `0010011`) - -| Instruction | Description | Encoding (`imm[11:0]` \| `funct3` \| `opcode`) | -| ----------- | ----------- | ----------------------------------------------- | -| ADDI | Add sign-extended 12-bit immediate to rs1, store in rd. | imm \| `000` \| `0010011` | -| SLTI | Set rd to 1 if rs1 < sign-extended imm (signed), else 0. | imm \| `010` \| `0010011` | -| SLTIU | Set rd to 1 if rs1 < sign-extended imm (unsigned), else 0. | imm \| `011` \| `0010011` | -| XORI | Bitwise XOR of rs1 and sign-extended imm, result in rd. | imm \| `100` \| `0010011` | -| ORI | Bitwise OR of rs1 and sign-extended imm, result in rd. | imm \| `110` \| `0010011` | -| ANDI | Bitwise AND of rs1 and sign-extended imm, result in rd. | imm \| `111` \| `0010011` | - -##### Shifting Instructions that carry an encoding disciminator in `imm[11:5]` -| Instruction | Description | Encoding (`imm[11:5]`\| `funct3` \| `opcode`) | -| ----------- | ----------- | ----------------------------------------------- | -| SLLI | Shift rs1 left by shamt (`imm[4:0]`), logical, store in rd. | `0000000` \| `001` \| `0010011` | -| SRLI | Shift rs1 right by shamt (`imm[4:0]`), logical, store in rd. | `0000000` \| `101` \| `0010011` | -| SRAI | Shift rs1 right by shamt (`imm[4:0]`), arithmetic, store in rd. | `0100000` \| `101` \| `0010011` | diff --git a/docs/images/add.svg b/docs/images/add.svg new file mode 100644 index 0000000..7c97e86 --- /dev/null +++ b/docs/images/add.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd000rs1rs20000000OPfunct3funct7ADD \ No newline at end of file diff --git a/docs/images/addi.svg b/docs/images/addi.svg new file mode 100644 index 0000000..8986fe4 --- /dev/null +++ b/docs/images/addi.svg @@ -0,0 +1 @@ +067111214151920311100100rd000rs1imm[11:0]OP-IMMfunct3ADDI \ No newline at end of file diff --git a/docs/images/and.svg b/docs/images/and.svg new file mode 100644 index 0000000..688d473 --- /dev/null +++ b/docs/images/and.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd111rs1rs20000000OPfunct3funct7AND \ No newline at end of file diff --git a/docs/images/andi.svg b/docs/images/andi.svg new file mode 100644 index 0000000..1ecfef3 --- /dev/null +++ b/docs/images/andi.svg @@ -0,0 +1 @@ +067111214151920311100100rd111rs1imm[11:0]OP-IMMfunct3ANDI \ No newline at end of file diff --git a/docs/images/auipc.svg b/docs/images/auipc.svg new file mode 100644 index 0000000..7c76a7c --- /dev/null +++ b/docs/images/auipc.svg @@ -0,0 +1 @@ +0671112311110100rdimm[31:12]AUIPCAUIPC \ No newline at end of file diff --git a/docs/images/b-immediate.svg b/docs/images/b-immediate.svg new file mode 100644 index 0000000..b7e2231 --- /dev/null +++ b/docs/images/b-immediate.svg @@ -0,0 +1 @@ +0145101112310inst[11:8]inst[30:25][7]inst[31]146120B-immediate \ No newline at end of file diff --git a/docs/images/beq.svg b/docs/images/beq.svg new file mode 100644 index 0000000..9b3e3f6 --- /dev/null +++ b/docs/images/beq.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]000rs1rs2imm[10:5][12]BRANCHfunct3BEQ \ No newline at end of file diff --git a/docs/images/bge.svg b/docs/images/bge.svg new file mode 100644 index 0000000..3348022 --- /dev/null +++ b/docs/images/bge.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]101rs1rs2imm[10:5][12]BRANCHfunct3BGE \ No newline at end of file diff --git a/docs/images/bgeu.svg b/docs/images/bgeu.svg new file mode 100644 index 0000000..b00bd8c --- /dev/null +++ b/docs/images/bgeu.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]111rs1rs2imm[10:5][12]BRANCHfunct3BGEU \ No newline at end of file diff --git a/docs/images/blt.svg b/docs/images/blt.svg new file mode 100644 index 0000000..41a281f --- /dev/null +++ b/docs/images/blt.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]001rs1rs2imm[10:5][12]BRANCHfunct3BLT \ No newline at end of file diff --git a/docs/images/bltu.svg b/docs/images/bltu.svg new file mode 100644 index 0000000..4aecba1 --- /dev/null +++ b/docs/images/bltu.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]011rs1rs2imm[10:5][12]BRANCHfunct3BLTU \ No newline at end of file diff --git a/docs/images/bne.svg b/docs/images/bne.svg new file mode 100644 index 0000000..1015d71 --- /dev/null +++ b/docs/images/bne.svg @@ -0,0 +1 @@ +0678111214151920242530311100011[11]imm[4:1]100rs1rs2imm[10:5][12]BRANCHfunct3BNE \ No newline at end of file diff --git a/docs/images/czero.eqz.svg b/docs/images/czero.eqz.svg new file mode 100644 index 0000000..134737f --- /dev/null +++ b/docs/images/czero.eqz.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd101rs1rs21110000OPfunct3funct7CZERO.EQZ \ No newline at end of file diff --git a/docs/images/czero.nez.svg b/docs/images/czero.nez.svg new file mode 100644 index 0000000..34b36e6 --- /dev/null +++ b/docs/images/czero.nez.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd111rs1rs21110000OPfunct3funct7CZERO.NEZ \ No newline at end of file diff --git a/docs/images/ebreak.svg b/docs/images/ebreak.svg new file mode 100644 index 0000000..56ba357 --- /dev/null +++ b/docs/images/ebreak.svg @@ -0,0 +1 @@ +0671112141519203111001110000000000000100000000000SYSTEMrdfunct3rs1imm[11:0]EBREAK \ No newline at end of file diff --git a/docs/images/ecall.svg b/docs/images/ecall.svg new file mode 100644 index 0000000..2de24d6 --- /dev/null +++ b/docs/images/ecall.svg @@ -0,0 +1 @@ +0671112141519203111001110000000000000000000000000SYSTEMrdfunct3rs1imm[11:0]ECALL \ No newline at end of file diff --git a/docs/images/fence.svg b/docs/images/fence.svg new file mode 100644 index 0000000..1bd099b --- /dev/null +++ b/docs/images/fence.svg @@ -0,0 +1 @@ +06711121415192023242728311111000rd000rs1predsuccfmMISC-MEMfunct3FENCE \ No newline at end of file diff --git a/docs/images/i-immediate.svg b/docs/images/i-immediate.svg new file mode 100644 index 0000000..c0911d6 --- /dev/null +++ b/docs/images/i-immediate.svg @@ -0,0 +1 @@ +0101131inst[30:20]inst[31]1121I-immediate \ No newline at end of file diff --git a/docs/images/j-immediate.svg b/docs/images/j-immediate.svg new file mode 100644 index 0000000..7383ace --- /dev/null +++ b/docs/images/j-immediate.svg @@ -0,0 +1 @@ +011011121920310inst[30:21][20]inst[19:12]inst[31]1101812J-immediate \ No newline at end of file diff --git a/docs/images/jal.svg b/docs/images/jal.svg new file mode 100644 index 0000000..0d7b058 --- /dev/null +++ b/docs/images/jal.svg @@ -0,0 +1 @@ +067111219202130311111011rdimm[19:12][11]imm[10:1][20]JALJAL \ No newline at end of file diff --git a/docs/images/jalr.svg b/docs/images/jalr.svg new file mode 100644 index 0000000..ac7cc92 --- /dev/null +++ b/docs/images/jalr.svg @@ -0,0 +1 @@ +067111214151920311110011rd000rs1imm[11:0]JALRfunct3JALR \ No newline at end of file diff --git a/docs/images/lb.svg b/docs/images/lb.svg new file mode 100644 index 0000000..24471b2 --- /dev/null +++ b/docs/images/lb.svg @@ -0,0 +1 @@ +067111214151920311100000rd000rs1imm[11:0]LOADfunct3LB \ No newline at end of file diff --git a/docs/images/lbu.svg b/docs/images/lbu.svg new file mode 100644 index 0000000..ab45a88 --- /dev/null +++ b/docs/images/lbu.svg @@ -0,0 +1 @@ +067111214151920311100000rd001rs1imm[11:0]LOADfunct3LBU \ No newline at end of file diff --git a/docs/images/lh.svg b/docs/images/lh.svg new file mode 100644 index 0000000..ed52c97 --- /dev/null +++ b/docs/images/lh.svg @@ -0,0 +1 @@ +067111214151920311100000rd100rs1imm[11:0]LOADfunct3LH \ No newline at end of file diff --git a/docs/images/lhu.svg b/docs/images/lhu.svg new file mode 100644 index 0000000..fb8f19b --- /dev/null +++ b/docs/images/lhu.svg @@ -0,0 +1 @@ +067111214151920311100000rd101rs1imm[11:0]LOADfunct3LHU \ No newline at end of file diff --git a/docs/images/lui.svg b/docs/images/lui.svg new file mode 100644 index 0000000..8f65be1 --- /dev/null +++ b/docs/images/lui.svg @@ -0,0 +1 @@ +0671112311110110rdimm[31:12]LUILUI \ No newline at end of file diff --git a/docs/images/lw.svg b/docs/images/lw.svg new file mode 100644 index 0000000..44aa174 --- /dev/null +++ b/docs/images/lw.svg @@ -0,0 +1 @@ +067111214151920311100000rd010rs1imm[11:0]LOADfunct3LW \ No newline at end of file diff --git a/docs/images/or.svg b/docs/images/or.svg new file mode 100644 index 0000000..13a3b2d --- /dev/null +++ b/docs/images/or.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd011rs1rs20000000OPfunct3funct7OR \ No newline at end of file diff --git a/docs/images/ori.svg b/docs/images/ori.svg new file mode 100644 index 0000000..7ec0ce6 --- /dev/null +++ b/docs/images/ori.svg @@ -0,0 +1 @@ +067111214151920311100100rd011rs1imm[11:0]OP-IMMfunct3ORI \ No newline at end of file diff --git a/docs/images/s-immediate.svg b/docs/images/s-immediate.svg new file mode 100644 index 0000000..5026c2b --- /dev/null +++ b/docs/images/s-immediate.svg @@ -0,0 +1 @@ +0145101131[7]inst[11:8]inst[30:25]inst[31]14621S-immediate \ No newline at end of file diff --git a/docs/images/sb.svg b/docs/images/sb.svg new file mode 100644 index 0000000..84bea85 --- /dev/null +++ b/docs/images/sb.svg @@ -0,0 +1 @@ +0671112141519202425311100010imm[4:0]000rs1rs2imm[11:5]STOREfunct3SB \ No newline at end of file diff --git a/docs/images/sh.svg b/docs/images/sh.svg new file mode 100644 index 0000000..7c74e5a --- /dev/null +++ b/docs/images/sh.svg @@ -0,0 +1 @@ +0671112141519202425311100010imm[4:0]100rs1rs2imm[11:5]STOREfunct3SH \ No newline at end of file diff --git a/docs/images/sll.svg b/docs/images/sll.svg new file mode 100644 index 0000000..f9309f1 --- /dev/null +++ b/docs/images/sll.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd100rs1rs20000000OPfunct3funct7SLL \ No newline at end of file diff --git a/docs/images/slli.svg b/docs/images/slli.svg new file mode 100644 index 0000000..b27cbf5 --- /dev/null +++ b/docs/images/slli.svg @@ -0,0 +1 @@ +0671112141519202425311100100rd100rs1shamt0000000OP-IMMfunct3imm[11:5]SLLI \ No newline at end of file diff --git a/docs/images/slt.svg b/docs/images/slt.svg new file mode 100644 index 0000000..377cdff --- /dev/null +++ b/docs/images/slt.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd010rs1rs20000000OPfunct3funct7SLT \ No newline at end of file diff --git a/docs/images/slti.svg b/docs/images/slti.svg new file mode 100644 index 0000000..38c463a --- /dev/null +++ b/docs/images/slti.svg @@ -0,0 +1 @@ +067111214151920311100100rd010rs1imm[11:0]OP-IMMfunct3SLTI \ No newline at end of file diff --git a/docs/images/sltiu.svg b/docs/images/sltiu.svg new file mode 100644 index 0000000..901a0a1 --- /dev/null +++ b/docs/images/sltiu.svg @@ -0,0 +1 @@ +067111214151920311100100rd110rs1imm[11:0]OP-IMMfunct3SLTIU \ No newline at end of file diff --git a/docs/images/sltu.svg b/docs/images/sltu.svg new file mode 100644 index 0000000..1d89ab3 --- /dev/null +++ b/docs/images/sltu.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd110rs1rs20000000OPfunct3funct7SLTU \ No newline at end of file diff --git a/docs/images/sra.svg b/docs/images/sra.svg new file mode 100644 index 0000000..b75b5e8 --- /dev/null +++ b/docs/images/sra.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd101rs1rs20000010OPfunct3funct7SRA \ No newline at end of file diff --git a/docs/images/srai.svg b/docs/images/srai.svg new file mode 100644 index 0000000..5d636e1 --- /dev/null +++ b/docs/images/srai.svg @@ -0,0 +1 @@ +0671112141519202425311100100rd101rs1shamt0000010OP-IMMfunct3imm[11:5]SRAI \ No newline at end of file diff --git a/docs/images/srl.svg b/docs/images/srl.svg new file mode 100644 index 0000000..ae348c5 --- /dev/null +++ b/docs/images/srl.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd101rs1rs20000000OPfunct3funct7SRL \ No newline at end of file diff --git a/docs/images/srli.svg b/docs/images/srli.svg new file mode 100644 index 0000000..1028426 --- /dev/null +++ b/docs/images/srli.svg @@ -0,0 +1 @@ +0671112141519202425311100100rd101rs1shamt0000000OP-IMMfunct3imm[11:5]SRLI \ No newline at end of file diff --git a/docs/images/sub.svg b/docs/images/sub.svg new file mode 100644 index 0000000..56fe6ca --- /dev/null +++ b/docs/images/sub.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd000rs1rs20000010OPfunct3funct7SUB \ No newline at end of file diff --git a/docs/images/sw.svg b/docs/images/sw.svg new file mode 100644 index 0000000..8d84a28 --- /dev/null +++ b/docs/images/sw.svg @@ -0,0 +1 @@ +0671112141519202425311100010imm[4:0]010rs1rs2imm[11:5]STOREfunct3SW \ No newline at end of file diff --git a/docs/images/u-immediate.svg b/docs/images/u-immediate.svg new file mode 100644 index 0000000..608746b --- /dev/null +++ b/docs/images/u-immediate.svg @@ -0,0 +1 @@ +01112310inst[31:12]1220U-immediate \ No newline at end of file diff --git a/docs/images/xor.svg b/docs/images/xor.svg new file mode 100644 index 0000000..69a26ba --- /dev/null +++ b/docs/images/xor.svg @@ -0,0 +1 @@ +0671112141519202425311100110rd001rs1rs20000000OPfunct3funct7XOR \ No newline at end of file diff --git a/docs/images/xori.svg b/docs/images/xori.svg new file mode 100644 index 0000000..334e6c7 --- /dev/null +++ b/docs/images/xori.svg @@ -0,0 +1 @@ +067111214151920311100100rd001rs1imm[11:0]OP-IMMfunct3XORI \ No newline at end of file -- cgit v1.2.3 From 577ad51f728a56b1c2244cb21a563564e62999b6 Mon Sep 17 00:00:00 2001 From: Chat <63841542+chatrajaman3@users.noreply.github.com> Date: Sun, 14 Jun 2026 16:21:08 -0700 Subject: Add top-level and QSPI controller modules --- rtl/qspi_controller.sv | 38 +++++++++++++++++++++++++++++++ rtl/rv32e_core_wrapper.sv | 8 +++++++ rtl/tt_top.sv | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 rtl/qspi_controller.sv create mode 100644 rtl/rv32e_core_wrapper.sv create mode 100644 rtl/tt_top.sv diff --git a/rtl/qspi_controller.sv b/rtl/qspi_controller.sv new file mode 100644 index 0000000..15b3c96 --- /dev/null +++ b/rtl/qspi_controller.sv @@ -0,0 +1,38 @@ +// Interface between core and QSPI pmod +// https://onlinedocs.microchip.com/oxy/GUID-450989FA-38E4-4D68-AB61-15ADB29AD718-en-US-6/GUID-C2190631-B6F5-4CD7-B6DB-5267DC280E90_3.html + +module qspi_controller ( + // Clock + input wire clk, + + // Reset (active low) + input wire rst_n, + + // Bi-directional I/O + input wire [7:0] uio_in, // IOs: Input path + output wire [7:0] uio_out, // IOs: Output path + output wire [7:0] uio_oe, // IOs: Enable path (active high: 0=input, 1=output) +); + + // ==================================== + // Pin mapping + // ==================================== + + // QSPI Serial CLK + + // QSPI CS - Active Low + + // QSPI IO_0 + // QSPI IO_1 + // QSPI IO_2 + // QSPI IO_3 + + + logic qspi_clk; + logic qspi_cs_n; + logic [3:0] qspi_data; + + + + +endmodule diff --git a/rtl/rv32e_core_wrapper.sv b/rtl/rv32e_core_wrapper.sv new file mode 100644 index 0000000..8d2b5c9 --- /dev/null +++ b/rtl/rv32e_core_wrapper.sv @@ -0,0 +1,8 @@ +// Provides a clean, generic bus interface for the core +// Easier UVM access + +module rv32e_core_wrapper (); + + + +endmodule diff --git a/rtl/tt_top.sv b/rtl/tt_top.sv new file mode 100644 index 0000000..be5f40d --- /dev/null +++ b/rtl/tt_top.sv @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2026 UBC ASIC + * SPDX-License-Identifier: Apache-2.0 + */ + +// Core wrapper + QSPI PMOD controller + +`default_nettype none + +module tt_top ( + // Dedicated inputs + input wire [7:0] ui_in, + + // Dedicated outputs + output wire [7:0] uo_out, + + // Bi-directional I/O + input wire [7:0] uio_in, // IOs: Input path + output wire [7:0] uio_out, // IOs: Output path + output wire [7:0] uio_oe, // IOs: Enable path (active high: 0=input, 1=output) + + // Enable design + input wire ena, // always 1 when the design is powered, so you can ignore it + + // Clock + input wire clk, // clock + + // Reset + input wire rst_n // reset_n - low to reset +); + + // All output pins must be assigned. If not used, assign to 0. + assign uo_out = ui_in + uio_in; // Example: ou_out is the sum of ui_in and uio_in + assign uio_out = 0; + assign uio_oe = 0; + + // List all unused inputs to prevent warnings + wire _unused = &{ena, clk, rst_n, 1'b0}; + + + u_rv32e_core_wrapper rv32e_core_wrapper( + + ); + + + u_qspi_controller qspi_controller( + // Clock + .clk(), + + // Reset + .rst_n(), + + // Bi-directional I/O + .uio_in(), // IOs: Input path + .uio_out(), // IOs: Output path + .uio_oe(), // IOs: Enable path (active high: 0=input, 1=output) + ); +endmodule -- cgit v1.2.3 From eef204455c692cee60e3713bad6c7428627b3672 Mon Sep 17 00:00:00 2001 From: Warrick Lo Date: Sun, 14 Jun 2026 18:18:32 -0700 Subject: Rename top-level module to prevent clashes Also fixes linter errors, whitespace, and copyright. Top-level module name MUST be unique to avoid collisions with other projects in the shuttle run. The port list MUST also exactly follow the Tiny Tapeout template, so a comment has been added to emphasise this. Signed-off-by: Warrick Lo --- rtl/qspi_controller.sv | 77 +++++++++++++++++++--------------- rtl/rv32e_core_wrapper.sv | 18 +++++--- rtl/tt_top.sv | 105 ++++++++++++++++++++++++++-------------------- 3 files changed, 115 insertions(+), 85 deletions(-) diff --git a/rtl/qspi_controller.sv b/rtl/qspi_controller.sv index 15b3c96..e718b50 100644 --- a/rtl/qspi_controller.sv +++ b/rtl/qspi_controller.sv @@ -1,38 +1,47 @@ -// Interface between core and QSPI pmod -// https://onlinedocs.microchip.com/oxy/GUID-450989FA-38E4-4D68-AB61-15ADB29AD718-en-US-6/GUID-C2190631-B6F5-4CD7-B6DB-5267DC280E90_3.html - +/* SPDX-License-Identifier: CERN-OHL-P-2.0 */ + +/* + * Copyright 2026 UBC ASIC contributors (Montreal project). + * All rights reserved. + * + * Authors: Chathil Rajamanthree + * + * Interface between core and QSPI Pmod + * + * https://onlinedocs.microchip.com/oxy/GUID-450989FA-38E4-4D68-AB61-15ADB29AD718-en-US-6/GUID-C2190631-B6F5-4CD7-B6DB-5267DC280E90_3.html + */ + +/* + * Pin mapping + * =========== + * + * QSPI Serial CLK + * + * QSPI CS - Active Low + * + * QSPI IO_0 + * QSPI IO_1 + * QSPI IO_2 + * QSPI IO_3 + */ module qspi_controller ( - // Clock - input wire clk, - - // Reset (active low) - input wire rst_n, - - // Bi-directional I/O - input wire [7:0] uio_in, // IOs: Input path - output wire [7:0] uio_out, // IOs: Output path - output wire [7:0] uio_oe, // IOs: Enable path (active high: 0=input, 1=output) + /* verilog_lint: waive-start port-name-suffix */ + /* Clock. */ + input wire clk, + /* Active-low reset. */ + input wire rst_n, + + /* I/O: input path. */ + input wire [7:0] uio_in, + /* I/O: output path. */ + output wire [7:0] uio_out, + /* I/O: active-high output enable. */ + output wire [7:0] uio_oe + /* verilog_lint: waive-stop port-name-suffix */ ); - // ==================================== - // Pin mapping - // ==================================== - - // QSPI Serial CLK - - // QSPI CS - Active Low - - // QSPI IO_0 - // QSPI IO_1 - // QSPI IO_2 - // QSPI IO_3 - - - logic qspi_clk; - logic qspi_cs_n; - logic [3:0] qspi_data; - - - + logic qspi_clk; + logic qspi_cs_n; + logic [3:0] qspi_data; -endmodule +endmodule : qspi_controller diff --git a/rtl/rv32e_core_wrapper.sv b/rtl/rv32e_core_wrapper.sv index 8d2b5c9..773b7af 100644 --- a/rtl/rv32e_core_wrapper.sv +++ b/rtl/rv32e_core_wrapper.sv @@ -1,8 +1,16 @@ -// Provides a clean, generic bus interface for the core -// Easier UVM access - -module rv32e_core_wrapper (); +/* SPDX-License-Identifier: CERN-OHL-P-2.0 */ +/* + * Copyright 2026 UBC ASIC contributors (Montreal project). + * All rights reserved. + * + * Authors: Chathil Rajamanthree + * + * Montreal RV32E Core Wrapper + * + * Provides a clean, generic bus interface for the core for easier UVM access. + */ +module rv32e_core_wrapper (); -endmodule +endmodule : rv32e_core_wrapper diff --git a/rtl/tt_top.sv b/rtl/tt_top.sv index be5f40d..5f179f6 100644 --- a/rtl/tt_top.sv +++ b/rtl/tt_top.sv @@ -1,58 +1,71 @@ +/* SPDX-License-Identifier: Apache-2.0 OR CERN-OHL-P-2.0 */ + /* - * Copyright (c) 2026 UBC ASIC - * SPDX-License-Identifier: Apache-2.0 + * Copyright 2024 Tiny Tapeout Ltd. + * Copyright 2026 UBC ASIC contributors (Montreal project). + * All rights reserved. + * + * Authors: Tiny Tapeout contributors + * Chathil Rajamanthree + * + * Tiny Tapeout top-level module and QSPI PMOD controller */ -// Core wrapper + QSPI PMOD controller - `default_nettype none -module tt_top ( - // Dedicated inputs - input wire [7:0] ui_in, - - // Dedicated outputs - output wire [7:0] uo_out, - - // Bi-directional I/O - input wire [7:0] uio_in, // IOs: Input path - output wire [7:0] uio_out, // IOs: Output path - output wire [7:0] uio_oe, // IOs: Enable path (active high: 0=input, 1=output) - - // Enable design - input wire ena, // always 1 when the design is powered, so you can ignore it - - // Clock - input wire clk, // clock - - // Reset - input wire rst_n // reset_n - low to reset +/* + * Tiny Tapeout top-level wrapper. + * + * IMPORTANT: The module definition MUST follow the Tiny Tapeout specification + * exactly. Do not modify the port names. + */ +/* verilog_lint: waive module-filename */ +module tt_top_ubc_montreal ( + /* verilog_lint: waive-start port-name-suffix */ + /* Dedicated inputs. */ + input wire [7:0] ui_in, + + /* Dedicated outputs. */ + output wire [7:0] uo_out, + + /* I/O: input path. */ + input wire [7:0] uio_in, + /* I/O: output path. */ + output wire [7:0] uio_out, + /* I/O: active-high output enable. */ + output wire [7:0] uio_oe, + + /* Design enable signal. This will be 1 when the design is powered. */ + input wire ena, + /* Clock. */ + input wire clk, + /* Active-low reset. */ + input wire rst_n + /* verilog_lint: waive-stop port-name-suffix */ ); - // All output pins must be assigned. If not used, assign to 0. - assign uo_out = ui_in + uio_in; // Example: ou_out is the sum of ui_in and uio_in - assign uio_out = 0; - assign uio_oe = 0; - - // List all unused inputs to prevent warnings - wire _unused = &{ena, clk, rst_n, 1'b0}; - + /* Temporary output assignments. Unused pins must be assigned to 0. */ + assign uo_out = ui_in + uio_in; + assign uio_out = '0; + assign uio_oe = '0; - u_rv32e_core_wrapper rv32e_core_wrapper( + /* Connect all unused inputs to prevent warnings. */ + wire unused = &{ena, clk, rst_n, 1'b0}; - ); + rv32e_core_wrapper u_rv32e_core_wrapper (); + qspi_controller u_qspi_controller ( + /* Clock. */ + .clk(), + /* Active-low reset. */ + .rst_n(), - u_qspi_controller qspi_controller( - // Clock - .clk(), - - // Reset - .rst_n(), + /* I/O: input path. */ + .uio_in(), + /* I/O: output path. */ + .uio_out(), + /* I/O: active high output enable. */ + .uio_oe() + ); - // Bi-directional I/O - .uio_in(), // IOs: Input path - .uio_out(), // IOs: Output path - .uio_oe(), // IOs: Enable path (active high: 0=input, 1=output) - ); -endmodule +endmodule : tt_top_ubc_montreal -- cgit v1.2.3