diff --git a/.gitattributes b/.gitattributes index 808d3cfff..52f446644 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,11 +2,14 @@ # Licensed under the Apache License, Version 2.0, see LICENSE for details. # SPDX-License-Identifier: Apache-2.0 data/xbar_main_generated.hjson linguist-generated=true +data/xbar_peri_generated.hjson linguist-generated=true doc/ip/pinmux/README.md linguist-generated=true rtl/bus/sonata_xbar_main.sv linguist-generated=true rtl/bus/tl_main_pkg.sv linguist-generated=true +rtl/bus/tl_peri_pkg.sv linguist-generated=true rtl/bus/tl_ifetch_pkg.sv linguist-generated=true rtl/bus/xbar_main.sv linguist-generated=true +rtl/bus/xbar_peri.sv linguist-generated=true rtl/bus/xbar_ifetch.sv linguist-generated=true rtl/system/pinmux.sv linguist-generated=true rtl/system/sonata_pkg.sv linguist-generated=true diff --git a/data/top_config.toml b/data/top_config.toml index 8ac5b1cc8..162a3ff82 100644 --- a/data/top_config.toml +++ b/data/top_config.toml @@ -11,6 +11,7 @@ ios = [ ] memory_start = 0x80000040 memory_size = 0x00000040 +which_xbar = "peri" [[blocks]] name = "pwm" @@ -18,7 +19,7 @@ instances = 1 ios = [{ name = "out", type = "output", length = 7 }] memory_start = 0x80001000 memory_size = 0x00001000 -xbar = { pipeline = "true", req_fifo_pass = "false", rsp_fifo_pass = "false" } +which_xbar = "peri" [[blocks]] name = "uart" @@ -29,7 +30,7 @@ ios = [ ] memory_start = 0x80100000 memory_size = 0x00001000 -xbar = { pipeline = "true", req_fifo_pass = "false", rsp_fifo_pass = "false" } +which_xbar = "peri" [[blocks]] name = "i2c" @@ -41,6 +42,7 @@ ios = [ memory_start = 0x80200000 memory_size = 0x00001000 xbar = { pipeline = "true", req_fifo_pass = "false", rsp_fifo_pass = "false" } +which_xbar = "main" [[blocks]] name = "spi" @@ -53,6 +55,7 @@ ios = [ ] memory_start = 0x80302000 memory_size = 0x00001000 +which_xbar = "main" # UARTS [[pins]] diff --git a/data/xbar_main.hjson b/data/xbar_main.hjson index 9510698a8..a0e723720 100644 --- a/data/xbar_main.hjson +++ b/data/xbar_main.hjson @@ -61,87 +61,18 @@ size_byte: "0x00004000", }], }, - { name: "gpio", // General purpose input and output + { name: "peri", type: "device", clock: "clk_sys_i", reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, xbar: false, addr_range: [{ base_addr: "0x80000000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "pinmux", // Pin multiplexer - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x80005000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "rgbled_ctrl", // RGB LED Controller - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x80009000", - size_byte: "0x00001000", + size_byte: "0x00200000", }], pipeline: true, - }, - { name: "hw_rev", // Hardware revoker control register - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x8000A000", - size_byte: "0x00001000", - }], - }, - { name: "xadc", // XADC - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", req_fifo_pass: false, rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x8000B000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "system_info", // System information - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x8000C000", - size_byte: "0x00001000", - }], - }, - { name: "timer", // Interrupt timer - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80040000", - size_byte: "0x00010000", - }], }, { name: "spi_lcd", type: "device", @@ -163,8 +94,12 @@ size_byte: "0x00001000", }], }, + // I^2C devices included here instead of in peri only because + // address range sizes must be a power of two. + // We can easily tolerate an extra cycle of access latency to them, + // so add pipelining to allow them to be placed further away physically. % for block in config.blocks: - % if not block.name == "gpio": + % if block.which_xbar == "main": % for i in range(block.instances): { name: "${f"{block.name}{i}"}", type: "device", @@ -196,15 +131,12 @@ type: "device", clock: "clk_sys_i", reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, xbar: false, addr_range: [{ // This block is overaligned to 0x0800_0000 bytes since OpenTitan RV_PLIC block expects it. base_addr: "0x88000000", size_byte: "0x04000000", }], - pipeline: true, }, ], connections: { @@ -212,17 +144,11 @@ "sram", "hyperram", "rev_tag", - "gpio", - "pinmux", - "system_info", - "rgbled_ctrl", - "hw_rev", - "xadc", - "timer", + "peri", "spi_lcd", "spi_ethmac", % for block in config.blocks: - % if not block.name == "gpio": + % if block.which_xbar == "main": % for i in range(block.instances): "${f"{block.name}{i}"}", % endfor diff --git a/data/xbar_main_generated.hjson b/data/xbar_main_generated.hjson index 6f3815ed5..61682af9b 100644 --- a/data/xbar_main_generated.hjson +++ b/data/xbar_main_generated.hjson @@ -61,87 +61,18 @@ size_byte: "0x00004000", }], }, - { name: "gpio", // General purpose input and output + { name: "peri", type: "device", clock: "clk_sys_i", reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, xbar: false, addr_range: [{ base_addr: "0x80000000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "pinmux", // Pin multiplexer - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x80005000", - size_byte: "0x00001000", + size_byte: "0x00200000", }], pipeline: true, - }, - { name: "rgbled_ctrl", // RGB LED Controller - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x80009000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "hw_rev", // Hardware revoker control register - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x8000A000", - size_byte: "0x00001000", - }], - }, - { name: "xadc", // XADC - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", req_fifo_pass: false, rsp_fifo_pass: false, - xbar: false, - addr_range: [{ - base_addr: "0x8000B000", - size_byte: "0x00001000", - }], - pipeline: true, - }, - { name: "system_info", // System information - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x8000C000", - size_byte: "0x00001000", - }], - }, - { name: "timer", // Interrupt timer - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80040000", - size_byte: "0x00010000", - }], }, { name: "spi_lcd", type: "device", @@ -163,58 +94,10 @@ size_byte: "0x00001000", }], }, - { name: "pwm0", - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80001000", - size_byte: "0x1000", - }], - pipeline: true, - req_fifo_pass: false, - rsp_fifo_pass: false, - }, - { name: "uart0", - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80100000", - size_byte: "0x1000", - }], - pipeline: true, - req_fifo_pass: false, - rsp_fifo_pass: false, - }, - { name: "uart1", - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80101000", - size_byte: "0x1000", - }], - pipeline: true, - req_fifo_pass: false, - rsp_fifo_pass: false, - }, - { name: "uart2", - type: "device", - clock: "clk_sys_i", - reset: "rst_sys_ni", - xbar: false, - addr_range: [{ - base_addr: "0x80102000", - size_byte: "0x1000", - }], - pipeline: true, - req_fifo_pass: false, - rsp_fifo_pass: false, - }, + // I^2C devices included here instead of in peri only because + // address range sizes must be a power of two. + // We can easily tolerate an extra cycle of access latency to them, + // so add pipelining to allow them to be placed further away physically. { name: "i2c0", type: "device", clock: "clk_sys_i", @@ -285,15 +168,12 @@ type: "device", clock: "clk_sys_i", reset: "rst_sys_ni", - req_fifo_pass: false, - rsp_fifo_pass: false, xbar: false, addr_range: [{ // This block is overaligned to 0x0800_0000 bytes since OpenTitan RV_PLIC block expects it. base_addr: "0x88000000", size_byte: "0x04000000", }], - pipeline: true, }, ], connections: { @@ -301,19 +181,9 @@ "sram", "hyperram", "rev_tag", - "gpio", - "pinmux", - "system_info", - "rgbled_ctrl", - "hw_rev", - "xadc", - "timer", + "peri", "spi_lcd", "spi_ethmac", - "pwm0", - "uart0", - "uart1", - "uart2", "i2c0", "i2c1", "spi0", diff --git a/data/xbar_peri.hjson b/data/xbar_peri.hjson new file mode 100644 index 000000000..793676f80 --- /dev/null +++ b/data/xbar_peri.hjson @@ -0,0 +1,132 @@ +// Copyright lowRISC contributors. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +{ name: "peri", + type: "xbar", + clock: "clk_sys_i", // Main clock, used in sockets + clock_connections: { + clk_sys_i: "main", + }, + reset: "rst_sys_ni", + reset_connections: { + rst_sys_ni: "sys", + }, + nodes: [ + { name: "main", + type: "host", + // addr_space: "hart", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: true, + pipeline: false, + }, + { name: "gpio", // General purpose input and output + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80000000", + size_byte: "0x00001000", + }], + }, + { name: "pinmux", // Pin multiplexer + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80005000", + size_byte: "0x00001000", + }], + }, + { name: "rgbled_ctrl", // RGB LED Controller + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80009000", + size_byte: "0x00001000", + }], + }, + { name: "hw_rev", // Hardware revoker control register + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000A000", + size_byte: "0x00001000", + }], + }, + { name: "xadc", // XADC + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000B000", + size_byte: "0x00001000", + }], + }, + { name: "system_info", // System information + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000C000", + size_byte: "0x00001000", + }], + }, + { name: "timer", // Interrupt timer + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80040000", + size_byte: "0x00010000", + }], + }, + % for block in config.blocks: + % if block.name != "gpio" and block.which_xbar == "peri": + % for i in range(block.instances): + { name: "${f"{block.name}{i}"}", + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "${hex(block.memory_start + i * block.memory_size)}", + size_byte: "${hex(block.memory_size)}", + }], + % for (setting, value) in block.xbar.items(): + ${setting}: ${value}, + % endfor + }, + % endfor + % endif + % endfor + ], + connections: { + main: [ + "gpio", + "pinmux", + "system_info", + "rgbled_ctrl", + "hw_rev", + "xadc", + "timer", + % for block in config.blocks: + % if block.name != "gpio" and block.which_xbar == "peri": + % for i in range(block.instances): + "${f"{block.name}{i}"}", + % endfor + % endif + % endfor + ], + }, +} diff --git a/data/xbar_peri_generated.hjson b/data/xbar_peri_generated.hjson new file mode 100644 index 000000000..0293bd99c --- /dev/null +++ b/data/xbar_peri_generated.hjson @@ -0,0 +1,150 @@ +// Copyright lowRISC contributors. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +{ name: "peri", + type: "xbar", + clock: "clk_sys_i", // Main clock, used in sockets + clock_connections: { + clk_sys_i: "main", + }, + reset: "rst_sys_ni", + reset_connections: { + rst_sys_ni: "sys", + }, + nodes: [ + { name: "main", + type: "host", + // addr_space: "hart", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: true, + pipeline: false, + }, + { name: "gpio", // General purpose input and output + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80000000", + size_byte: "0x00001000", + }], + }, + { name: "pinmux", // Pin multiplexer + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80005000", + size_byte: "0x00001000", + }], + }, + { name: "rgbled_ctrl", // RGB LED Controller + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80009000", + size_byte: "0x00001000", + }], + }, + { name: "hw_rev", // Hardware revoker control register + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000A000", + size_byte: "0x00001000", + }], + }, + { name: "xadc", // XADC + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000B000", + size_byte: "0x00001000", + }], + }, + { name: "system_info", // System information + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x8000C000", + size_byte: "0x00001000", + }], + }, + { name: "timer", // Interrupt timer + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80040000", + size_byte: "0x00010000", + }], + }, + { name: "pwm0", + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80001000", + size_byte: "0x1000", + }], + }, + { name: "uart0", + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80100000", + size_byte: "0x1000", + }], + }, + { name: "uart1", + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80101000", + size_byte: "0x1000", + }], + }, + { name: "uart2", + type: "device", + clock: "clk_sys_i", + reset: "rst_sys_ni", + xbar: false, + addr_range: [{ + base_addr: "0x80102000", + size_byte: "0x1000", + }], + }, + ], + connections: { + main: [ + "gpio", + "pinmux", + "system_info", + "rgbled_ctrl", + "hw_rev", + "xadc", + "timer", + "pwm0", + "uart0", + "uart1", + "uart2", + ], + }, +} diff --git a/rtl/bus/sonata_xbar_main.sv b/rtl/bus/sonata_xbar_main.sv index e12b2f345..ed83e5f8a 100644 --- a/rtl/bus/sonata_xbar_main.sv +++ b/rtl/bus/sonata_xbar_main.sv @@ -59,8 +59,12 @@ module sonata_xbar_main input tlul_pkg::tl_d2h_t tl_rv_plic_i ); + // Inter-xbar interfaces + tlul_pkg::tl_h2d_t tl_main_to_peri; + tlul_pkg::tl_d2h_t tl_peri_to_main; + xbar_main xbar ( - // Clock and reset. + // Clock and reset. .clk_sys_i (clk_sys_i), .rst_sys_ni (rst_sys_ni), .clk_usb_i (clk_usb_i), @@ -79,6 +83,40 @@ module sonata_xbar_main .tl_hyperram_i (tl_hyperram_i), .tl_rev_tag_o (tl_rev_tag_o), .tl_rev_tag_i (tl_rev_tag_i), + .tl_peri_o (tl_main_to_peri), + .tl_peri_i (tl_peri_to_main), + .tl_spi_lcd_i (tl_spi_lcd_i), + .tl_spi_lcd_o (tl_spi_lcd_o), + .tl_spi_ethmac_i (tl_spi_ethmac_i), + .tl_spi_ethmac_o (tl_spi_ethmac_o), + .tl_i2c0_o (tl_i2c_o[0]), + .tl_i2c0_i (tl_i2c_i[0]), + .tl_i2c1_o (tl_i2c_o[1]), + .tl_i2c1_i (tl_i2c_i[1]), + .tl_spi0_o (tl_spi_o[0]), + .tl_spi0_i (tl_spi_i[0]), + .tl_spi1_o (tl_spi_o[1]), + .tl_spi1_i (tl_spi_i[1]), + .tl_spi2_o (tl_spi_o[2]), + .tl_spi2_i (tl_spi_i[2]), + .tl_usbdev_o (tl_usbdev_o), + .tl_usbdev_i (tl_usbdev_i), + .tl_rv_plic_o (tl_rv_plic_o), + .tl_rv_plic_i (tl_rv_plic_i), + + .scanmode_i (prim_mubi_pkg::MuBi4False) + ); + + xbar_peri xbar2 ( + // Clock and reset. + .clk_sys_i (clk_sys_i), + .rst_sys_ni (rst_sys_ni), + + // Host interfaces. + .tl_main_i (tl_main_to_peri), + .tl_main_o (tl_peri_to_main), + + // Device interfaces. .tl_gpio_o (tl_gpio_o), .tl_gpio_i (tl_gpio_i), .tl_pinmux_o (tl_pinmux_o), @@ -93,10 +131,6 @@ module sonata_xbar_main .tl_xadc_i (tl_xadc_i), .tl_timer_o (tl_timer_o), .tl_timer_i (tl_timer_i), - .tl_spi_lcd_i (tl_spi_lcd_i), - .tl_spi_lcd_o (tl_spi_lcd_o), - .tl_spi_ethmac_i (tl_spi_ethmac_i), - .tl_spi_ethmac_o (tl_spi_ethmac_o), .tl_pwm0_o (tl_pwm_o[0]), .tl_pwm0_i (tl_pwm_i[0]), .tl_uart0_o (tl_uart_o[0]), @@ -105,20 +139,6 @@ module sonata_xbar_main .tl_uart1_i (tl_uart_i[1]), .tl_uart2_o (tl_uart_o[2]), .tl_uart2_i (tl_uart_i[2]), - .tl_i2c0_o (tl_i2c_o[0]), - .tl_i2c0_i (tl_i2c_i[0]), - .tl_i2c1_o (tl_i2c_o[1]), - .tl_i2c1_i (tl_i2c_i[1]), - .tl_spi0_o (tl_spi_o[0]), - .tl_spi0_i (tl_spi_i[0]), - .tl_spi1_o (tl_spi_o[1]), - .tl_spi1_i (tl_spi_i[1]), - .tl_spi2_o (tl_spi_o[2]), - .tl_spi2_i (tl_spi_i[2]), - .tl_usbdev_o (tl_usbdev_o), - .tl_usbdev_i (tl_usbdev_i), - .tl_rv_plic_o (tl_rv_plic_o), - .tl_rv_plic_i (tl_rv_plic_i), .scanmode_i (prim_mubi_pkg::MuBi4False) ); diff --git a/rtl/bus/tl_main_pkg.sv b/rtl/bus/tl_main_pkg.sv index 68f64db41..5e9daf3ce 100644 --- a/rtl/bus/tl_main_pkg.sv +++ b/rtl/bus/tl_main_pkg.sv @@ -6,81 +6,51 @@ package tl_main_pkg; - localparam logic [31:0] ADDR_SPACE_SRAM = 32'h 00100000; - localparam logic [31:0] ADDR_SPACE_HYPERRAM = 32'h 40000000; - localparam logic [31:0] ADDR_SPACE_REV_TAG = 32'h 30000000; - localparam logic [31:0] ADDR_SPACE_GPIO = 32'h 80000000; - localparam logic [31:0] ADDR_SPACE_PINMUX = 32'h 80005000; - localparam logic [31:0] ADDR_SPACE_RGBLED_CTRL = 32'h 80009000; - localparam logic [31:0] ADDR_SPACE_HW_REV = 32'h 8000a000; - localparam logic [31:0] ADDR_SPACE_XADC = 32'h 8000b000; - localparam logic [31:0] ADDR_SPACE_SYSTEM_INFO = 32'h 8000c000; - localparam logic [31:0] ADDR_SPACE_TIMER = 32'h 80040000; - localparam logic [31:0] ADDR_SPACE_SPI_LCD = 32'h 80300000; - localparam logic [31:0] ADDR_SPACE_SPI_ETHMAC = 32'h 80301000; - localparam logic [31:0] ADDR_SPACE_PWM0 = 32'h 80001000; - localparam logic [31:0] ADDR_SPACE_UART0 = 32'h 80100000; - localparam logic [31:0] ADDR_SPACE_UART1 = 32'h 80101000; - localparam logic [31:0] ADDR_SPACE_UART2 = 32'h 80102000; - localparam logic [31:0] ADDR_SPACE_I2C0 = 32'h 80200000; - localparam logic [31:0] ADDR_SPACE_I2C1 = 32'h 80201000; - localparam logic [31:0] ADDR_SPACE_SPI0 = 32'h 80302000; - localparam logic [31:0] ADDR_SPACE_SPI1 = 32'h 80303000; - localparam logic [31:0] ADDR_SPACE_SPI2 = 32'h 80304000; - localparam logic [31:0] ADDR_SPACE_USBDEV = 32'h 80400000; - localparam logic [31:0] ADDR_SPACE_RV_PLIC = 32'h 88000000; + localparam logic [31:0] ADDR_SPACE_SRAM = 32'h 00100000; + localparam logic [31:0] ADDR_SPACE_HYPERRAM = 32'h 40000000; + localparam logic [31:0] ADDR_SPACE_REV_TAG = 32'h 30000000; + localparam logic [31:0] ADDR_SPACE_PERI = 32'h 80000000; + localparam logic [31:0] ADDR_SPACE_SPI_LCD = 32'h 80300000; + localparam logic [31:0] ADDR_SPACE_SPI_ETHMAC = 32'h 80301000; + localparam logic [31:0] ADDR_SPACE_I2C0 = 32'h 80200000; + localparam logic [31:0] ADDR_SPACE_I2C1 = 32'h 80201000; + localparam logic [31:0] ADDR_SPACE_SPI0 = 32'h 80302000; + localparam logic [31:0] ADDR_SPACE_SPI1 = 32'h 80303000; + localparam logic [31:0] ADDR_SPACE_SPI2 = 32'h 80304000; + localparam logic [31:0] ADDR_SPACE_USBDEV = 32'h 80400000; + localparam logic [31:0] ADDR_SPACE_RV_PLIC = 32'h 88000000; - localparam logic [31:0] ADDR_MASK_SRAM = 32'h 0003ffff; - localparam logic [31:0] ADDR_MASK_HYPERRAM = 32'h 000fffff; - localparam logic [31:0] ADDR_MASK_REV_TAG = 32'h 00003fff; - localparam logic [31:0] ADDR_MASK_GPIO = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_PINMUX = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_RGBLED_CTRL = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_HW_REV = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_XADC = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_SYSTEM_INFO = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_TIMER = 32'h 0000ffff; - localparam logic [31:0] ADDR_MASK_SPI_LCD = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_SPI_ETHMAC = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_PWM0 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_UART0 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_UART1 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_UART2 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_I2C0 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_I2C1 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_SPI0 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_SPI1 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_SPI2 = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_USBDEV = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_RV_PLIC = 32'h 03ffffff; + localparam logic [31:0] ADDR_MASK_SRAM = 32'h 0003ffff; + localparam logic [31:0] ADDR_MASK_HYPERRAM = 32'h 000fffff; + localparam logic [31:0] ADDR_MASK_REV_TAG = 32'h 00003fff; + localparam logic [31:0] ADDR_MASK_PERI = 32'h 001fffff; + localparam logic [31:0] ADDR_MASK_SPI_LCD = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_SPI_ETHMAC = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_I2C0 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_I2C1 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_SPI0 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_SPI1 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_SPI2 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_USBDEV = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_RV_PLIC = 32'h 03ffffff; localparam int N_HOST = 2; - localparam int N_DEVICE = 23; + localparam int N_DEVICE = 13; typedef enum int { TlSram = 0, TlHyperram = 1, TlRevTag = 2, - TlGpio = 3, - TlPinmux = 4, - TlRgbledCtrl = 5, - TlHwRev = 6, - TlXadc = 7, - TlSystemInfo = 8, - TlTimer = 9, - TlSpiLcd = 10, - TlSpiEthmac = 11, - TlPwm0 = 12, - TlUart0 = 13, - TlUart1 = 14, - TlUart2 = 15, - TlI2C0 = 16, - TlI2C1 = 17, - TlSpi0 = 18, - TlSpi1 = 19, - TlSpi2 = 20, - TlUsbdev = 21, - TlRvPlic = 22 + TlPeri = 3, + TlSpiLcd = 4, + TlSpiEthmac = 5, + TlI2C0 = 6, + TlI2C1 = 7, + TlSpi0 = 8, + TlSpi1 = 9, + TlSpi2 = 10, + TlUsbdev = 11, + TlRvPlic = 12 } tl_device_e; typedef enum int { diff --git a/rtl/bus/tl_peri_pkg.sv b/rtl/bus/tl_peri_pkg.sv new file mode 100644 index 000000000..efa2ec443 --- /dev/null +++ b/rtl/bus/tl_peri_pkg.sv @@ -0,0 +1,54 @@ +// Copyright lowRISC contributors (OpenTitan project). +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 +// +// tl_peri package generated by `tlgen.py` tool + +package tl_peri_pkg; + + localparam logic [31:0] ADDR_SPACE_GPIO = 32'h 80000000; + localparam logic [31:0] ADDR_SPACE_PINMUX = 32'h 80005000; + localparam logic [31:0] ADDR_SPACE_RGBLED_CTRL = 32'h 80009000; + localparam logic [31:0] ADDR_SPACE_HW_REV = 32'h 8000a000; + localparam logic [31:0] ADDR_SPACE_XADC = 32'h 8000b000; + localparam logic [31:0] ADDR_SPACE_SYSTEM_INFO = 32'h 8000c000; + localparam logic [31:0] ADDR_SPACE_TIMER = 32'h 80040000; + localparam logic [31:0] ADDR_SPACE_PWM0 = 32'h 80001000; + localparam logic [31:0] ADDR_SPACE_UART0 = 32'h 80100000; + localparam logic [31:0] ADDR_SPACE_UART1 = 32'h 80101000; + localparam logic [31:0] ADDR_SPACE_UART2 = 32'h 80102000; + + localparam logic [31:0] ADDR_MASK_GPIO = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_PINMUX = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_RGBLED_CTRL = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_HW_REV = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_XADC = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_SYSTEM_INFO = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_TIMER = 32'h 0000ffff; + localparam logic [31:0] ADDR_MASK_PWM0 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_UART0 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_UART1 = 32'h 00000fff; + localparam logic [31:0] ADDR_MASK_UART2 = 32'h 00000fff; + + localparam int N_HOST = 1; + localparam int N_DEVICE = 11; + + typedef enum int { + TlGpio = 0, + TlPinmux = 1, + TlRgbledCtrl = 2, + TlHwRev = 3, + TlXadc = 4, + TlSystemInfo = 5, + TlTimer = 6, + TlPwm0 = 7, + TlUart0 = 8, + TlUart1 = 9, + TlUart2 = 10 + } tl_device_e; + + typedef enum int { + TlMain = 0 + } tl_host_e; + +endpackage diff --git a/rtl/bus/xbar_main.sv b/rtl/bus/xbar_main.sv index b9a4a5735..6e8f0e5ad 100644 --- a/rtl/bus/xbar_main.sv +++ b/rtl/bus/xbar_main.sv @@ -7,34 +7,24 @@ // // Interconnect // ibex_lsu -// -> s1n_25 -// -> sm1_26 +// -> s1n_15 +// -> sm1_16 // -> sram // -> hyperram // -> rev_tag -// -> gpio -// -> pinmux -// -> system_info -// -> rgbled_ctrl -// -> hw_rev -// -> xadc -// -> timer +// -> peri // -> spi_lcd // -> spi_ethmac -// -> pwm0 -// -> uart0 -// -> uart1 -// -> uart2 // -> i2c0 // -> i2c1 // -> spi0 // -> spi1 // -> spi2 -// -> asf_27 +// -> asf_17 // -> usbdev // -> rv_plic // dbg_host -// -> sm1_26 +// -> sm1_16 // -> sram module xbar_main ( @@ -56,32 +46,12 @@ module xbar_main ( input tlul_pkg::tl_d2h_t tl_hyperram_i, output tlul_pkg::tl_h2d_t tl_rev_tag_o, input tlul_pkg::tl_d2h_t tl_rev_tag_i, - output tlul_pkg::tl_h2d_t tl_gpio_o, - input tlul_pkg::tl_d2h_t tl_gpio_i, - output tlul_pkg::tl_h2d_t tl_pinmux_o, - input tlul_pkg::tl_d2h_t tl_pinmux_i, - output tlul_pkg::tl_h2d_t tl_rgbled_ctrl_o, - input tlul_pkg::tl_d2h_t tl_rgbled_ctrl_i, - output tlul_pkg::tl_h2d_t tl_hw_rev_o, - input tlul_pkg::tl_d2h_t tl_hw_rev_i, - output tlul_pkg::tl_h2d_t tl_xadc_o, - input tlul_pkg::tl_d2h_t tl_xadc_i, - output tlul_pkg::tl_h2d_t tl_system_info_o, - input tlul_pkg::tl_d2h_t tl_system_info_i, - output tlul_pkg::tl_h2d_t tl_timer_o, - input tlul_pkg::tl_d2h_t tl_timer_i, + output tlul_pkg::tl_h2d_t tl_peri_o, + input tlul_pkg::tl_d2h_t tl_peri_i, output tlul_pkg::tl_h2d_t tl_spi_lcd_o, input tlul_pkg::tl_d2h_t tl_spi_lcd_i, output tlul_pkg::tl_h2d_t tl_spi_ethmac_o, input tlul_pkg::tl_d2h_t tl_spi_ethmac_i, - output tlul_pkg::tl_h2d_t tl_pwm0_o, - input tlul_pkg::tl_d2h_t tl_pwm0_i, - output tlul_pkg::tl_h2d_t tl_uart0_o, - input tlul_pkg::tl_d2h_t tl_uart0_i, - output tlul_pkg::tl_h2d_t tl_uart1_o, - input tlul_pkg::tl_d2h_t tl_uart1_i, - output tlul_pkg::tl_h2d_t tl_uart2_o, - input tlul_pkg::tl_d2h_t tl_uart2_i, output tlul_pkg::tl_h2d_t tl_i2c0_o, input tlul_pkg::tl_d2h_t tl_i2c0_i, output tlul_pkg::tl_h2d_t tl_i2c1_o, @@ -108,205 +78,135 @@ module xbar_main ( logic unused_scanmode; assign unused_scanmode = ^scanmode_i; - tl_h2d_t tl_s1n_25_us_h2d ; - tl_d2h_t tl_s1n_25_us_d2h ; + tl_h2d_t tl_s1n_15_us_h2d ; + tl_d2h_t tl_s1n_15_us_d2h ; - tl_h2d_t tl_s1n_25_ds_h2d [23]; - tl_d2h_t tl_s1n_25_ds_d2h [23]; + tl_h2d_t tl_s1n_15_ds_h2d [13]; + tl_d2h_t tl_s1n_15_ds_d2h [13]; // Create steering signal - logic [4:0] dev_sel_s1n_25; + logic [3:0] dev_sel_s1n_15; - tl_h2d_t tl_sm1_26_us_h2d [2]; - tl_d2h_t tl_sm1_26_us_d2h [2]; + tl_h2d_t tl_sm1_16_us_h2d [2]; + tl_d2h_t tl_sm1_16_us_d2h [2]; - tl_h2d_t tl_sm1_26_ds_h2d ; - tl_d2h_t tl_sm1_26_ds_d2h ; + tl_h2d_t tl_sm1_16_ds_h2d ; + tl_d2h_t tl_sm1_16_ds_d2h ; - tl_h2d_t tl_asf_27_us_h2d ; - tl_d2h_t tl_asf_27_us_d2h ; - tl_h2d_t tl_asf_27_ds_h2d ; - tl_d2h_t tl_asf_27_ds_d2h ; + tl_h2d_t tl_asf_17_us_h2d ; + tl_d2h_t tl_asf_17_us_d2h ; + tl_h2d_t tl_asf_17_ds_h2d ; + tl_d2h_t tl_asf_17_ds_d2h ; - assign tl_sm1_26_us_h2d[0] = tl_s1n_25_ds_h2d[0]; - assign tl_s1n_25_ds_d2h[0] = tl_sm1_26_us_d2h[0]; + assign tl_sm1_16_us_h2d[0] = tl_s1n_15_ds_h2d[0]; + assign tl_s1n_15_ds_d2h[0] = tl_sm1_16_us_d2h[0]; - assign tl_hyperram_o = tl_s1n_25_ds_h2d[1]; - assign tl_s1n_25_ds_d2h[1] = tl_hyperram_i; + assign tl_hyperram_o = tl_s1n_15_ds_h2d[1]; + assign tl_s1n_15_ds_d2h[1] = tl_hyperram_i; - assign tl_rev_tag_o = tl_s1n_25_ds_h2d[2]; - assign tl_s1n_25_ds_d2h[2] = tl_rev_tag_i; + assign tl_rev_tag_o = tl_s1n_15_ds_h2d[2]; + assign tl_s1n_15_ds_d2h[2] = tl_rev_tag_i; - assign tl_gpio_o = tl_s1n_25_ds_h2d[3]; - assign tl_s1n_25_ds_d2h[3] = tl_gpio_i; + assign tl_peri_o = tl_s1n_15_ds_h2d[3]; + assign tl_s1n_15_ds_d2h[3] = tl_peri_i; - assign tl_pinmux_o = tl_s1n_25_ds_h2d[4]; - assign tl_s1n_25_ds_d2h[4] = tl_pinmux_i; + assign tl_spi_lcd_o = tl_s1n_15_ds_h2d[4]; + assign tl_s1n_15_ds_d2h[4] = tl_spi_lcd_i; - assign tl_system_info_o = tl_s1n_25_ds_h2d[5]; - assign tl_s1n_25_ds_d2h[5] = tl_system_info_i; + assign tl_spi_ethmac_o = tl_s1n_15_ds_h2d[5]; + assign tl_s1n_15_ds_d2h[5] = tl_spi_ethmac_i; - assign tl_rgbled_ctrl_o = tl_s1n_25_ds_h2d[6]; - assign tl_s1n_25_ds_d2h[6] = tl_rgbled_ctrl_i; + assign tl_i2c0_o = tl_s1n_15_ds_h2d[6]; + assign tl_s1n_15_ds_d2h[6] = tl_i2c0_i; - assign tl_hw_rev_o = tl_s1n_25_ds_h2d[7]; - assign tl_s1n_25_ds_d2h[7] = tl_hw_rev_i; + assign tl_i2c1_o = tl_s1n_15_ds_h2d[7]; + assign tl_s1n_15_ds_d2h[7] = tl_i2c1_i; - assign tl_xadc_o = tl_s1n_25_ds_h2d[8]; - assign tl_s1n_25_ds_d2h[8] = tl_xadc_i; + assign tl_spi0_o = tl_s1n_15_ds_h2d[8]; + assign tl_s1n_15_ds_d2h[8] = tl_spi0_i; - assign tl_timer_o = tl_s1n_25_ds_h2d[9]; - assign tl_s1n_25_ds_d2h[9] = tl_timer_i; + assign tl_spi1_o = tl_s1n_15_ds_h2d[9]; + assign tl_s1n_15_ds_d2h[9] = tl_spi1_i; - assign tl_spi_lcd_o = tl_s1n_25_ds_h2d[10]; - assign tl_s1n_25_ds_d2h[10] = tl_spi_lcd_i; + assign tl_spi2_o = tl_s1n_15_ds_h2d[10]; + assign tl_s1n_15_ds_d2h[10] = tl_spi2_i; - assign tl_spi_ethmac_o = tl_s1n_25_ds_h2d[11]; - assign tl_s1n_25_ds_d2h[11] = tl_spi_ethmac_i; + assign tl_asf_17_us_h2d = tl_s1n_15_ds_h2d[11]; + assign tl_s1n_15_ds_d2h[11] = tl_asf_17_us_d2h; - assign tl_pwm0_o = tl_s1n_25_ds_h2d[12]; - assign tl_s1n_25_ds_d2h[12] = tl_pwm0_i; + assign tl_rv_plic_o = tl_s1n_15_ds_h2d[12]; + assign tl_s1n_15_ds_d2h[12] = tl_rv_plic_i; - assign tl_uart0_o = tl_s1n_25_ds_h2d[13]; - assign tl_s1n_25_ds_d2h[13] = tl_uart0_i; + assign tl_sm1_16_us_h2d[1] = tl_dbg_host_i; + assign tl_dbg_host_o = tl_sm1_16_us_d2h[1]; - assign tl_uart1_o = tl_s1n_25_ds_h2d[14]; - assign tl_s1n_25_ds_d2h[14] = tl_uart1_i; + assign tl_s1n_15_us_h2d = tl_ibex_lsu_i; + assign tl_ibex_lsu_o = tl_s1n_15_us_d2h; - assign tl_uart2_o = tl_s1n_25_ds_h2d[15]; - assign tl_s1n_25_ds_d2h[15] = tl_uart2_i; + assign tl_sram_o = tl_sm1_16_ds_h2d; + assign tl_sm1_16_ds_d2h = tl_sram_i; - assign tl_i2c0_o = tl_s1n_25_ds_h2d[16]; - assign tl_s1n_25_ds_d2h[16] = tl_i2c0_i; - - assign tl_i2c1_o = tl_s1n_25_ds_h2d[17]; - assign tl_s1n_25_ds_d2h[17] = tl_i2c1_i; - - assign tl_spi0_o = tl_s1n_25_ds_h2d[18]; - assign tl_s1n_25_ds_d2h[18] = tl_spi0_i; - - assign tl_spi1_o = tl_s1n_25_ds_h2d[19]; - assign tl_s1n_25_ds_d2h[19] = tl_spi1_i; - - assign tl_spi2_o = tl_s1n_25_ds_h2d[20]; - assign tl_s1n_25_ds_d2h[20] = tl_spi2_i; - - assign tl_asf_27_us_h2d = tl_s1n_25_ds_h2d[21]; - assign tl_s1n_25_ds_d2h[21] = tl_asf_27_us_d2h; - - assign tl_rv_plic_o = tl_s1n_25_ds_h2d[22]; - assign tl_s1n_25_ds_d2h[22] = tl_rv_plic_i; - - assign tl_sm1_26_us_h2d[1] = tl_dbg_host_i; - assign tl_dbg_host_o = tl_sm1_26_us_d2h[1]; - - assign tl_s1n_25_us_h2d = tl_ibex_lsu_i; - assign tl_ibex_lsu_o = tl_s1n_25_us_d2h; - - assign tl_sram_o = tl_sm1_26_ds_h2d; - assign tl_sm1_26_ds_d2h = tl_sram_i; - - assign tl_usbdev_o = tl_asf_27_ds_h2d; - assign tl_asf_27_ds_d2h = tl_usbdev_i; + assign tl_usbdev_o = tl_asf_17_ds_h2d; + assign tl_asf_17_ds_d2h = tl_usbdev_i; always_comb begin // default steering to generate error response if address is not within the range - dev_sel_s1n_25 = 5'd23; - if ((tl_s1n_25_us_h2d.a_address & + dev_sel_s1n_15 = 4'd13; + if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SRAM)) == ADDR_SPACE_SRAM) begin - dev_sel_s1n_25 = 5'd0; + dev_sel_s1n_15 = 4'd0; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_HYPERRAM)) == ADDR_SPACE_HYPERRAM) begin - dev_sel_s1n_25 = 5'd1; + dev_sel_s1n_15 = 4'd1; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_REV_TAG)) == ADDR_SPACE_REV_TAG) begin - dev_sel_s1n_25 = 5'd2; + dev_sel_s1n_15 = 4'd2; - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_GPIO)) == ADDR_SPACE_GPIO) begin - dev_sel_s1n_25 = 5'd3; + end else if ((tl_s1n_15_us_h2d.a_address & + ~(ADDR_MASK_PERI)) == ADDR_SPACE_PERI) begin + dev_sel_s1n_15 = 4'd3; - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_PINMUX)) == ADDR_SPACE_PINMUX) begin - dev_sel_s1n_25 = 5'd4; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_SYSTEM_INFO)) == ADDR_SPACE_SYSTEM_INFO) begin - dev_sel_s1n_25 = 5'd5; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_RGBLED_CTRL)) == ADDR_SPACE_RGBLED_CTRL) begin - dev_sel_s1n_25 = 5'd6; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_HW_REV)) == ADDR_SPACE_HW_REV) begin - dev_sel_s1n_25 = 5'd7; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_XADC)) == ADDR_SPACE_XADC) begin - dev_sel_s1n_25 = 5'd8; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_TIMER)) == ADDR_SPACE_TIMER) begin - dev_sel_s1n_25 = 5'd9; - - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SPI_LCD)) == ADDR_SPACE_SPI_LCD) begin - dev_sel_s1n_25 = 5'd10; + dev_sel_s1n_15 = 4'd4; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SPI_ETHMAC)) == ADDR_SPACE_SPI_ETHMAC) begin - dev_sel_s1n_25 = 5'd11; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_PWM0)) == ADDR_SPACE_PWM0) begin - dev_sel_s1n_25 = 5'd12; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_UART0)) == ADDR_SPACE_UART0) begin - dev_sel_s1n_25 = 5'd13; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_UART1)) == ADDR_SPACE_UART1) begin - dev_sel_s1n_25 = 5'd14; - - end else if ((tl_s1n_25_us_h2d.a_address & - ~(ADDR_MASK_UART2)) == ADDR_SPACE_UART2) begin - dev_sel_s1n_25 = 5'd15; + dev_sel_s1n_15 = 4'd5; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_I2C0)) == ADDR_SPACE_I2C0) begin - dev_sel_s1n_25 = 5'd16; + dev_sel_s1n_15 = 4'd6; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_I2C1)) == ADDR_SPACE_I2C1) begin - dev_sel_s1n_25 = 5'd17; + dev_sel_s1n_15 = 4'd7; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SPI0)) == ADDR_SPACE_SPI0) begin - dev_sel_s1n_25 = 5'd18; + dev_sel_s1n_15 = 4'd8; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SPI1)) == ADDR_SPACE_SPI1) begin - dev_sel_s1n_25 = 5'd19; + dev_sel_s1n_15 = 4'd9; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_SPI2)) == ADDR_SPACE_SPI2) begin - dev_sel_s1n_25 = 5'd20; + dev_sel_s1n_15 = 4'd10; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_USBDEV)) == ADDR_SPACE_USBDEV) begin - dev_sel_s1n_25 = 5'd21; + dev_sel_s1n_15 = 4'd11; - end else if ((tl_s1n_25_us_h2d.a_address & + end else if ((tl_s1n_15_us_h2d.a_address & ~(ADDR_MASK_RV_PLIC)) == ADDR_SPACE_RV_PLIC) begin - dev_sel_s1n_25 = 5'd22; + dev_sel_s1n_15 = 4'd12; end end @@ -315,19 +215,19 @@ end tlul_socket_1n #( .HReqDepth (4'h0), .HRspDepth (4'h0), - .DReqPass (23'h3c0ea7), - .DRspPass (23'h3c0ea7), - .DReqDepth (92'h10000111111000101011000), - .DRspDepth (92'h10000111111000101011000), - .N (23) - ) u_s1n_25 ( + .DReqPass (13'h1f37), + .DRspPass (13'h1f37), + .DReqDepth (52'h11001000), + .DRspDepth (52'h11001000), + .N (13) + ) u_s1n_15 ( .clk_i (clk_sys_i), .rst_ni (rst_sys_ni), - .tl_h_i (tl_s1n_25_us_h2d), - .tl_h_o (tl_s1n_25_us_d2h), - .tl_d_o (tl_s1n_25_ds_h2d), - .tl_d_i (tl_s1n_25_ds_d2h), - .dev_select_i (dev_sel_s1n_25) + .tl_h_i (tl_s1n_15_us_h2d), + .tl_h_o (tl_s1n_15_us_d2h), + .tl_d_o (tl_s1n_15_ds_h2d), + .tl_d_i (tl_s1n_15_ds_d2h), + .dev_select_i (dev_sel_s1n_15) ); tlul_socket_m1 #( .HReqPass (2'h1), @@ -336,26 +236,26 @@ end .DReqDepth (4'h0), .DRspDepth (4'h0), .M (2) - ) u_sm1_26 ( + ) u_sm1_16 ( .clk_i (clk_sys_i), .rst_ni (rst_sys_ni), - .tl_h_i (tl_sm1_26_us_h2d), - .tl_h_o (tl_sm1_26_us_d2h), - .tl_d_o (tl_sm1_26_ds_h2d), - .tl_d_i (tl_sm1_26_ds_d2h) + .tl_h_i (tl_sm1_16_us_h2d), + .tl_h_o (tl_sm1_16_us_d2h), + .tl_d_o (tl_sm1_16_ds_h2d), + .tl_d_i (tl_sm1_16_ds_d2h) ); tlul_fifo_async #( .ReqDepth (1), .RspDepth (1) - ) u_asf_27 ( + ) u_asf_17 ( .clk_h_i (clk_sys_i), .rst_h_ni (rst_sys_ni), .clk_d_i (clk_usb_i), .rst_d_ni (rst_usb_ni), - .tl_h_i (tl_asf_27_us_h2d), - .tl_h_o (tl_asf_27_us_d2h), - .tl_d_o (tl_asf_27_ds_h2d), - .tl_d_i (tl_asf_27_ds_d2h) + .tl_h_i (tl_asf_17_us_h2d), + .tl_h_o (tl_asf_17_us_d2h), + .tl_d_o (tl_asf_17_ds_h2d), + .tl_d_i (tl_asf_17_ds_d2h) ); endmodule diff --git a/rtl/bus/xbar_peri.core b/rtl/bus/xbar_peri.core new file mode 100644 index 000000000..77b44ab6c --- /dev/null +++ b/rtl/bus/xbar_peri.core @@ -0,0 +1,24 @@ +CAPI=2: +# Copyright lowRISC contributors (OpenTitan project). +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 +# +# xbar_peri core file generated by `tlgen.py` tool +name: "lowrisc:ip:xbar_peri:0.1" +description: "Generated RTL xbar_peri" + +filesets: + files_rtl: + depend: + - lowrisc:ip:tlul + files: + - tl_peri_pkg.sv + - xbar_peri.sv + file_type: systemVerilogSource + + +targets: + default: &default_target + filesets: + - files_rtl + toplevel: xbar_peri diff --git a/rtl/bus/xbar_peri.sv b/rtl/bus/xbar_peri.sv new file mode 100644 index 000000000..1bac04274 --- /dev/null +++ b/rtl/bus/xbar_peri.sv @@ -0,0 +1,181 @@ +// Copyright lowRISC contributors (OpenTitan project). +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 +// +// xbar_peri module generated by `tlgen.py` tool +// all reset signals should be generated from one reset signal to not make any deadlock +// +// Interconnect +// main +// -> s1n_12 +// -> gpio +// -> pinmux +// -> system_info +// -> rgbled_ctrl +// -> hw_rev +// -> xadc +// -> timer +// -> pwm0 +// -> uart0 +// -> uart1 +// -> uart2 + +module xbar_peri ( + input clk_sys_i, + input rst_sys_ni, + + // Host interfaces + input tlul_pkg::tl_h2d_t tl_main_i, + output tlul_pkg::tl_d2h_t tl_main_o, + + // Device interfaces + output tlul_pkg::tl_h2d_t tl_gpio_o, + input tlul_pkg::tl_d2h_t tl_gpio_i, + output tlul_pkg::tl_h2d_t tl_pinmux_o, + input tlul_pkg::tl_d2h_t tl_pinmux_i, + output tlul_pkg::tl_h2d_t tl_rgbled_ctrl_o, + input tlul_pkg::tl_d2h_t tl_rgbled_ctrl_i, + output tlul_pkg::tl_h2d_t tl_hw_rev_o, + input tlul_pkg::tl_d2h_t tl_hw_rev_i, + output tlul_pkg::tl_h2d_t tl_xadc_o, + input tlul_pkg::tl_d2h_t tl_xadc_i, + output tlul_pkg::tl_h2d_t tl_system_info_o, + input tlul_pkg::tl_d2h_t tl_system_info_i, + output tlul_pkg::tl_h2d_t tl_timer_o, + input tlul_pkg::tl_d2h_t tl_timer_i, + output tlul_pkg::tl_h2d_t tl_pwm0_o, + input tlul_pkg::tl_d2h_t tl_pwm0_i, + output tlul_pkg::tl_h2d_t tl_uart0_o, + input tlul_pkg::tl_d2h_t tl_uart0_i, + output tlul_pkg::tl_h2d_t tl_uart1_o, + input tlul_pkg::tl_d2h_t tl_uart1_i, + output tlul_pkg::tl_h2d_t tl_uart2_o, + input tlul_pkg::tl_d2h_t tl_uart2_i, + + input prim_mubi_pkg::mubi4_t scanmode_i +); + + import tlul_pkg::*; + import tl_peri_pkg::*; + + // scanmode_i is currently not used, but provisioned for future use + // this assignment prevents lint warnings + logic unused_scanmode; + assign unused_scanmode = ^scanmode_i; + + tl_h2d_t tl_s1n_12_us_h2d ; + tl_d2h_t tl_s1n_12_us_d2h ; + + + tl_h2d_t tl_s1n_12_ds_h2d [11]; + tl_d2h_t tl_s1n_12_ds_d2h [11]; + + // Create steering signal + logic [3:0] dev_sel_s1n_12; + + + + assign tl_gpio_o = tl_s1n_12_ds_h2d[0]; + assign tl_s1n_12_ds_d2h[0] = tl_gpio_i; + + assign tl_pinmux_o = tl_s1n_12_ds_h2d[1]; + assign tl_s1n_12_ds_d2h[1] = tl_pinmux_i; + + assign tl_system_info_o = tl_s1n_12_ds_h2d[2]; + assign tl_s1n_12_ds_d2h[2] = tl_system_info_i; + + assign tl_rgbled_ctrl_o = tl_s1n_12_ds_h2d[3]; + assign tl_s1n_12_ds_d2h[3] = tl_rgbled_ctrl_i; + + assign tl_hw_rev_o = tl_s1n_12_ds_h2d[4]; + assign tl_s1n_12_ds_d2h[4] = tl_hw_rev_i; + + assign tl_xadc_o = tl_s1n_12_ds_h2d[5]; + assign tl_s1n_12_ds_d2h[5] = tl_xadc_i; + + assign tl_timer_o = tl_s1n_12_ds_h2d[6]; + assign tl_s1n_12_ds_d2h[6] = tl_timer_i; + + assign tl_pwm0_o = tl_s1n_12_ds_h2d[7]; + assign tl_s1n_12_ds_d2h[7] = tl_pwm0_i; + + assign tl_uart0_o = tl_s1n_12_ds_h2d[8]; + assign tl_s1n_12_ds_d2h[8] = tl_uart0_i; + + assign tl_uart1_o = tl_s1n_12_ds_h2d[9]; + assign tl_s1n_12_ds_d2h[9] = tl_uart1_i; + + assign tl_uart2_o = tl_s1n_12_ds_h2d[10]; + assign tl_s1n_12_ds_d2h[10] = tl_uart2_i; + + assign tl_s1n_12_us_h2d = tl_main_i; + assign tl_main_o = tl_s1n_12_us_d2h; + + always_comb begin + // default steering to generate error response if address is not within the range + dev_sel_s1n_12 = 4'd11; + if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_GPIO)) == ADDR_SPACE_GPIO) begin + dev_sel_s1n_12 = 4'd0; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_PINMUX)) == ADDR_SPACE_PINMUX) begin + dev_sel_s1n_12 = 4'd1; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_SYSTEM_INFO)) == ADDR_SPACE_SYSTEM_INFO) begin + dev_sel_s1n_12 = 4'd2; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_RGBLED_CTRL)) == ADDR_SPACE_RGBLED_CTRL) begin + dev_sel_s1n_12 = 4'd3; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_HW_REV)) == ADDR_SPACE_HW_REV) begin + dev_sel_s1n_12 = 4'd4; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_XADC)) == ADDR_SPACE_XADC) begin + dev_sel_s1n_12 = 4'd5; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_TIMER)) == ADDR_SPACE_TIMER) begin + dev_sel_s1n_12 = 4'd6; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_PWM0)) == ADDR_SPACE_PWM0) begin + dev_sel_s1n_12 = 4'd7; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_UART0)) == ADDR_SPACE_UART0) begin + dev_sel_s1n_12 = 4'd8; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_UART1)) == ADDR_SPACE_UART1) begin + dev_sel_s1n_12 = 4'd9; + + end else if ((tl_s1n_12_us_h2d.a_address & + ~(ADDR_MASK_UART2)) == ADDR_SPACE_UART2) begin + dev_sel_s1n_12 = 4'd10; +end + end + + + // Instantiation phase + tlul_socket_1n #( + .HReqDepth (4'h0), + .HRspDepth (4'h0), + .DReqDepth (44'h0), + .DRspDepth (44'h0), + .N (11) + ) u_s1n_12 ( + .clk_i (clk_sys_i), + .rst_ni (rst_sys_ni), + .tl_h_i (tl_s1n_12_us_h2d), + .tl_h_o (tl_s1n_12_us_d2h), + .tl_d_o (tl_s1n_12_ds_h2d), + .tl_d_i (tl_s1n_12_ds_d2h), + .dev_select_i (dev_sel_s1n_12) + ); + +endmodule diff --git a/rtl/templates/sonata_xbar_main.sv.tpl b/rtl/templates/sonata_xbar_main.sv.tpl index 84a5f080d..a12e28e43 100644 --- a/rtl/templates/sonata_xbar_main.sv.tpl +++ b/rtl/templates/sonata_xbar_main.sv.tpl @@ -57,8 +57,12 @@ module sonata_xbar_main input tlul_pkg::tl_d2h_t tl_rv_plic_i ); + // Inter-xbar interfaces + tlul_pkg::tl_h2d_t tl_main_to_peri; + tlul_pkg::tl_d2h_t tl_peri_to_main; + xbar_main xbar ( - // Clock and reset. + // Clock and reset. .clk_sys_i (clk_sys_i), .rst_sys_ni (rst_sys_ni), .clk_usb_i (clk_usb_i), @@ -77,6 +81,38 @@ module sonata_xbar_main .tl_hyperram_i (tl_hyperram_i), .tl_rev_tag_o (tl_rev_tag_o), .tl_rev_tag_i (tl_rev_tag_i), + .tl_peri_o (tl_main_to_peri), + .tl_peri_i (tl_peri_to_main), + .tl_spi_lcd_i (tl_spi_lcd_i), + .tl_spi_lcd_o (tl_spi_lcd_o), + .tl_spi_ethmac_i (tl_spi_ethmac_i), + .tl_spi_ethmac_o (tl_spi_ethmac_o), + % for block in config.blocks: + % if block.name in ["i2c", "spi"]: + % for i in range(block.instances): + .tl_${block.name}${i}_o (tl_${block.name}_o[${i}]), + .tl_${block.name}${i}_i (tl_${block.name}_i[${i}]), + % endfor + % endif + % endfor + .tl_usbdev_o (tl_usbdev_o), + .tl_usbdev_i (tl_usbdev_i), + .tl_rv_plic_o (tl_rv_plic_o), + .tl_rv_plic_i (tl_rv_plic_i), + + .scanmode_i (prim_mubi_pkg::MuBi4False) + ); + + xbar_peri xbar2 ( + // Clock and reset. + .clk_sys_i (clk_sys_i), + .rst_sys_ni (rst_sys_ni), + + // Host interfaces. + .tl_main_i (tl_main_to_peri), + .tl_main_o (tl_peri_to_main), + + // Device interfaces. .tl_gpio_o (tl_gpio_o), .tl_gpio_i (tl_gpio_i), .tl_pinmux_o (tl_pinmux_o), @@ -91,22 +127,14 @@ module sonata_xbar_main .tl_xadc_i (tl_xadc_i), .tl_timer_o (tl_timer_o), .tl_timer_i (tl_timer_i), - .tl_spi_lcd_i (tl_spi_lcd_i), - .tl_spi_lcd_o (tl_spi_lcd_o), - .tl_spi_ethmac_i (tl_spi_ethmac_i), - .tl_spi_ethmac_o (tl_spi_ethmac_o), % for block in config.blocks: - % if not block.name == "gpio": + % if block.name not in ["gpio", "i2c", "spi"]: % for i in range(block.instances): .tl_${block.name}${i}_o (tl_${block.name}_o[${i}]), .tl_${block.name}${i}_i (tl_${block.name}_i[${i}]), % endfor % endif % endfor - .tl_usbdev_o (tl_usbdev_o), - .tl_usbdev_i (tl_usbdev_i), - .tl_rv_plic_o (tl_rv_plic_o), - .tl_rv_plic_i (tl_rv_plic_i), .scanmode_i (prim_mubi_pkg::MuBi4False) ); diff --git a/sonata_system.core b/sonata_system.core index 7fffb3f9b..58692ecdb 100644 --- a/sonata_system.core +++ b/sonata_system.core @@ -14,6 +14,7 @@ filesets: - lowrisc:ip:uart - lowrisc:ip:usbdev - lowrisc:ip:xbar_main + - lowrisc:ip:xbar_peri - lowrisc:ip:xbar_ifetch - lowrisc:ip:spi - lowrisc:ip:gpio diff --git a/util/generate_xbar.sh b/util/generate_xbar.sh index f03e30d42..f231c229f 100755 --- a/util/generate_xbar.sh +++ b/util/generate_xbar.sh @@ -5,6 +5,7 @@ set -e mkdir -p rtl/bus vendor/lowrisc_ip/util/tlgen.py -t data/xbar_main_generated.hjson -o rtl/bus +vendor/lowrisc_ip/util/tlgen.py -t data/xbar_peri_generated.hjson -o rtl/bus vendor/lowrisc_ip/util/tlgen.py -t data/xbar_ifetch.hjson -o rtl/bus rm -r rtl/bus/data rm -r rtl/bus/dv diff --git a/util/top_gen/generator.py b/util/top_gen/generator.py index 967a755c1..77c8ac92c 100644 --- a/util/top_gen/generator.py +++ b/util/top_gen/generator.py @@ -345,6 +345,7 @@ def generate_top(config: TopConfig) -> None: } for template_file, output_file in ( ("data/xbar_main.hjson", "data/xbar_main_generated.hjson"), + ("data/xbar_peri.hjson", "data/xbar_peri_generated.hjson"), ( "rtl/templates/sonata_xbar_main.sv.tpl", "rtl/bus/sonata_xbar_main.sv", diff --git a/util/top_gen/parser.py b/util/top_gen/parser.py index 16694099f..e7dc63a06 100644 --- a/util/top_gen/parser.py +++ b/util/top_gen/parser.py @@ -55,6 +55,7 @@ class Block(BaseModel, frozen=True): memory_start: int memory_size: int xbar: dict[str, str] = {} + which_xbar: str @field_validator("instances") @staticmethod