Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hw/top_chip/rtl/top_chip_system.sv
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ module top_chip_system #(
.intr_gpio_o (gpio_interrupts)
);

// Instantiate our UART block.
uart u_uart (
// Instantiate UART 16550 block.
uart16550 u_uart (
.clk_i (clkmgr_clocks.clk_io_infra),
.rst_ni (rstmgr_resets.rst_io_n[rstmgr_pkg::DomainMainSel]),

Expand Down
2 changes: 1 addition & 1 deletion hw/top_chip/top_chip_system.core
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ filesets:
files_rtl:
depend:
- lowrisc:ip:i2c
- lowrisc:ip:uart
- lowrisc:ip:uart16550
- lowrisc:ip:rv_timer
- lowrisc:ip:spi_device
- lowrisc:ip:spi_host
Expand Down
5 changes: 5 additions & 0 deletions hw/vendor/REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ path = ["axi_riscv_atomics/**"]
SPDX-License-Identifier = "SHL-0.51"
SPDX-FileCopyrightText = ["2018 ETH Zurich and University of Bologna."]

[[annotations]]
path = ["uart_16550/**"]
SPDX-License-Identifier = "Apache-2.0"
SPDX-FileCopyrightText = ["lowRISC and contributors (COSMIC project)."]

[[annotations]]
path = ["patches/**"]
SPDX-License-Identifier = "Apache-2.0"
Expand Down
14 changes: 14 additions & 0 deletions hw/vendor/uart_16550.lock.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

// This file is generated by the util/vendor script. Please do not modify it
// manually.

{
upstream:
{
url: https://github.com/lowRISC/uart-16550
rev: da7b3330525dcab9545c247430ac5e0c71a97a38
}
}
17 changes: 17 additions & 0 deletions hw/vendor/uart_16550.vendor.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
name: "uart_16550",
target_dir: "uart_16550",

upstream: {
url: "https://github.com/lowRISC/uart-16550"
rev: "mocha-fixes"
}

mapping: [
// UART 16550 wrapper.
{from: "hw/ip/uart16550", to: "hw/ip/uart16550"},
],
}
36 changes: 36 additions & 0 deletions hw/vendor/uart_16550/hw/ip/uart16550/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# UART 16550 Hardware IP Block

The UART 16550 IP block is a wrapper around the [OpenTitan UART IP][opentitan-uart], which allows it to be used with the standard 16550 register map.

> [!IMPORTANT]
> The design for this IP is incomplete and the RTL will change significantly. This IP is also not well verified.

## Register functionality

As the OpenTitan UART IP and the [16550 specification][16550-spec] have different feature sets, this wrapper only provides features supported by both implementations. The differences in register functionality are further described in the [register documentation](doc/registers.md).

## Functional differences

Additional functional differences from the [16550 specification][16550-spec] are listed below:

- Receive FIFO size is 64 bytes
- Transmit FIFO size is 32 bytes
- Received characters with framing error or parity error are not pushed into the RCVR FIFO.

## Interrupts

This wrapper provides the same set of interrupt outputs as the OpenTitan UART IP. The following interrupt outputs will however always be inactive as they are never enabled by the wrapper:

- tx_watermark
- tx_done
- rx_timeout

## Features not yet implemented

- TL-UL host request integrity check, integrity errors will be ignored
- TL-UL host `PutPartialData` opcode, which will behave as `PutFullData`
- TL-UL host request size other than 2, which will be treated as 2
- RACL, all registers will always be accessible

[opentitan-uart]: https://github.com/lowRISC/opentitan/tree/master/hw/ip/uart
[16550-spec]: https://web.archive.org/web/20180826215135/http://www.ti.com/lit/ds/symlink/pc16550d.pdf
156 changes: 156 additions & 0 deletions hw/vendor/uart_16550/hw/ip/uart16550/data/uart16550.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Copyright lowRISC and contributors (COSMIC project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
name: "uart16550"
human_name: "UART 16550"
one_line_desc: "Wrapper around the OpenTitan UART core, which provides the standard 16550 register map."
one_paragraph_desc: '''
Universal Asynchronous Receiver/Transmitter (UART) provides industry standard serial communication with external devices via two wires at a programmable baud rate.
The UART 16550 wrapper translates 16550 register accesses to the OpenTitan UART memory map, allowing the OpenTitan UART core to be used with built-in drivers from rich Operating Systems such as Linux.
'''
// Unique comportable IP identifier defined under KNOWN_CIP_IDS in the regtool.
cip_id: "49"
design_spec: "../doc"
version: "0.0.1"
life_stage: "L1"
design_stage: "D0"
verification_stage: "V0"

clocking: [
{ clock: "clk_i", reset: "rst_ni", primary: true }
]

bus_interfaces: [
{ protocol: "tlul", direction: "device", racl_support: false }
]

available_input_list: [
{ name: "rx", desc: "Serial receive bit" }
]
available_output_list: [
{ name: "tx", desc: "Serial transmit bit" }
]

interrupt_list: [
{ name: "tx_watermark",
type: "status",
default: "1",
desc: "raised if the transmit FIFO is past the high-water mark."}
{ name: "rx_watermark",
type: "status",
desc: "raised if the receive FIFO is past the high-water mark."}
{ name: "tx_done",
desc: "raised if the transmit FIFO has emptied and no transmit is ongoing."}
{ name: "rx_overflow",
desc: "raised if the receive FIFO has overflowed."}
{ name: "rx_frame_err",
desc: "raised if a framing error has been detected on receive."}
{ name: "rx_break_err",
desc: "raised if break condition has been detected on receive."}
{ name: "rx_timeout",
desc: '''
raised if RX FIFO has characters remaining in the FIFO without being
retrieved for the programmed time period.
'''
}
{ name: "rx_parity_err",
desc: "raised if the receiver has detected a parity error."}
{ name: "tx_empty",
type: "status",
default: "1",
desc: "raised if the transmit FIFO is empty."}
]

alert_list: [
{ name: "fatal_fault",
desc: '''
This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.
'''
}
]

features: [
{ name: "UART.PARITY",
desc: '''
The UART can be configured to so that it sends (or expects) a parity bit after each 8 data bits.
In receive mode, the UART sends the rx_parity_err interrupt if it receives a parity bit of the wrong polarity.
The parity mode is configurable (ensuring words are even or odd).
'''
}
{ name: "UART.SYSTEM_LOOPBACK",
desc: '''
The UART can be configured so that outgoing bits are registered as having been received on the RX side.
'''
}
{ name: "UART.FIFO_INTERRUPTS",
desc: '''
The UART can be configured to send an "watermark" interrupt when RX or TX FIFO is nearly full/empty, respectively.
It sends an rx_overflow interrupt if it sees an extra character when the RX FIFO is full.
'''
}
]

inter_signal_list: [
{ struct: "logic"
type: "uni"
name: "lsio_trigger"
desc: '''
Self-clearing status trigger for the DMA.
Set when RX or TX FIFOs are past their configured watermarks matching watermark interrupt behaviour.
'''
act: "req"
}
{ struct: "racl_policy_vec",
type: "uni",
name: "racl_policies",
act: "rcv",
package: "top_racl_pkg",
desc: '''
Incoming RACL policy vector from a racl_ctrl instance.
The policy selection vector (parameter) selects the policy for each register.
'''
}
{ struct: "racl_error_log",
type: "uni",
name: "racl_error",
act: "req",
width: "1"
package: "top_racl_pkg",
desc: '''
RACL error log information of this module.
'''
}
]

countermeasures: [
// No countermeasure implemented yet
]

param_list: [
// Note that the watermark CSRs further below need to be adjusted when
// making changes to these FIFO depths. The RTL and DV are written in
// a parametric way and will adjust automatically.
{ name: "RxFifoDepth",
desc: "Number of bytes in the RX FIFO.",
type: "int",
default: "64",
local: "true",
}
{ name: "TxFifoDepth",
desc: "Number of bytes in the TX FIFO.",
type: "int",
default: "32",
local: "true",
}
]

regwidth: "32",
registers: [
// Registers are specified in the following HJSON files as the interrupt and alert lists cause
// related CSRs, which do not exist on 16550, to be inserted at the start of the address map.
// - uart16550_main.hjson - Main address map with DLAB=0 and excluding write-only registers
// - uart16550_wo.hjson - Write-only registers with DLAB=0
// - uart16550_dl.hjson - Divisor latch registers with DLAB=1
]
}
50 changes: 50 additions & 0 deletions hw/vendor/uart_16550/hw/ip/uart16550/data/uart16550_dl.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright lowRISC and contributors (COSMIC project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
name: "uart16550_dl"
human_name: "UART 16550 divisor latch address map"
// Unique comportable IP identifier defined under KNOWN_CIP_IDS in the regtool.
cip_id: "49"
design_spec: "../doc"
version: "0.0.1"
life_stage: "L1"
design_stage: "D0"
verification_stage: "V0"

clocking: [
{ clock: "clk_i", reset: "rst_ni", primary: true }
]

bus_interfaces: [
{ protocol: "tlul", direction: "device", racl_support: false }
]

regwidth: "32",
registers: [
{ name: "DLL",
desc: '''Divisor latch register (least significant byte).
One write to the divisor latch is needed to enable Tx and Rx.
''',
swaccess: "rw",
hwaccess: "hro",
fields: [
{ bits: "7:0",
resval: "0x00"
}
]
}
{ name: "DLM",
desc: '''Divisor latch register (most significant byte).
One write to the divisor latch is needed to enable Tx and Rx.
''',
swaccess: "rw",
hwaccess: "hro",
fields: [
{ bits: "7:0",
resval: "0x00"
}
]
}
]
}
Loading
Loading