From: Sebastien Bourdeauducq Date: Thu, 17 Sep 2015 03:05:57 +0000 (+0800) Subject: doc: Constant X-Git-Tag: 24jan2021_ls180~2099^2~3^2~89 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b9c6720d8f7aac264e3fa9b2282ea97a3e6ed9e;p=litex.git doc: Constant --- diff --git a/doc/fhdl.rst b/doc/fhdl.rst index 85e78842..e3fa7e68 100644 --- a/doc/fhdl.rst +++ b/doc/fhdl.rst @@ -13,13 +13,17 @@ FHDL is made of several elements, which are briefly explained below. They all ca Expressions *********** -Integers and booleans -===================== +Constants +========= + +The ``Constant`` object represents a constant, HDL-literal integer. It behaves like specifying integers and booleans but also supports slicing and can have a bit width or signedness different from what is implied by the value it represents. -Python integers and booleans can appear in FHDL expressions to represent constant values in a circuit. ``True`` and ``False`` are interpreted as 1 and 0, respectively. +``True`` and ``False`` are interpreted as 1 and 0, respectively. Negative integers are explicitly supported. As with MyHDL [countin]_, arithmetic operations return the natural results. +To lighten the syntax, assignments and operators automatically wrap Python integers and booleans into ``Constant``. Additionally, ``Constant`` is aliased to ``C``. The following are valid Migen statements: ``a.eq(0)``, ``a.eq(a + 1)``, ``a.eq(C(42)[0:1])``. + .. [countin] http://www.jandecaluwe.com/hdldesign/counting.html Signal