From 84568453f803b542326cae061b1ee9ef7894c430 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Povi=C5=A1er?= <povik@cutebit.org>
Date: Wed, 22 Nov 2023 12:33:47 +0100
Subject: [PATCH] rtlil: Add `lsb()` `msb()` SigSpec helpers

---
 kernel/rtlil.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 9c318eac9..17853fae1 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -921,6 +921,9 @@ public:
 	RTLIL::SigSpec extract(int offset, int length = 1) const;
 	RTLIL::SigSpec extract_end(int offset) const { return extract(offset, width_ - offset); }
 
+	RTLIL::SigBit lsb() const { log_assert(width_); return (*this)[0]; };
+	RTLIL::SigBit msb() const { log_assert(width_); return (*this)[width_ - 1]; };
+
 	void append(const RTLIL::SigSpec &signal);
 	inline void append(Wire *wire) { append(RTLIL::SigSpec(wire)); }
 	inline void append(const RTLIL::SigChunk &chunk) { append(RTLIL::SigSpec(chunk)); }