You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight, open source 32-bit CPU core optimized for FPGA implementation.
3
+
LXP32 is a small and FPGA friendly 32-bit CPU IP core based on a simple, original instruction set. Its key features include:
4
+
5
+
* portability (described in behavioral VHDL, not tied to any particular vendor);
6
+
* 3-stage hazard-free pipeline;
7
+
* 256 registers implemented as a RAM block;
8
+
* only 30 distinct opcodes;
9
+
* separate instruction and data buses, optional instruction cache;
10
+
* WISHBONE compatibility;
11
+
* 8 interrupts with hardwired priorities;
12
+
* optional divider.
13
+
14
+
The LXP32 processor was successfully used in commercial projects, is [well documented](https://github.com/lxp32/lxp32-cpu/raw/develop/doc/lxp32-trm.pdf) and comes with a verification environment.
15
+
16
+
LXP32 lacks some features of more advanced processors, such as nested interrupt handling, debugging support, floating-point and memory management units. LXP32 ISA (Instruction Set Architecture) does not currently have a C compiler, only assembly based workflow is supported.
Copy file name to clipboardExpand all lines: doc/src/trm/lxp32-trm.tex
+51-8Lines changed: 51 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,7 @@ \section{Addressing}
164
164
165
165
All addressing in \lxp{} is indirect. In order to access a memory location, its address must be stored in a register; any available register can be used for this purpose.
166
166
167
-
Some instructions, namely \instr{lsb} (\instrname{Load Signed Byte}), \instr{lub} (\instrname{Load Unsigned Byte}) and \instr{sb} (\instrname{Store Byte}) provide byte-granular access, in which case all 32 bits in the address are significant. Otherwise the least two address bits are ignored as \lxp{} doesn't support unaligned access to 32-bit data words (during simulation, a warning is emitted if such a transaction is attempted).
167
+
\lxp{} uses a 32-bit address space. Each address refers to an individual byte. Some instructions, namely \instr{lsb} (\instrname{Load Signed Byte}), \instr{lub} (\instrname{Load Unsigned Byte}) and \instr{sb} (\instrname{Store Byte}) provide byte-granular access, in which case all 32 bits in the address are significant. Otherwise the least two address bits are ignored as \lxp{} doesn't support unaligned access to 32-bit data words (during simulation, a warning is emitted if such a transaction is attempted).
168
168
169
169
A special rule applies to pointers that refer to instructions: since instructions are always word-aligned, the least significant bit is interpreted as the \code{IRF} (\emph{Interrupt Return Flag}). See Section \ref{sec:interrupthandling} for details.
The simplest slaves such as on-chip RAM blocks which are never busy can be trivially connected to the LLI by connecting address, data and read enable ports and tying the \signal{lli\_busy\_i} signal to a logical \code{0} (you can even ignore \signal{lli\_re\_o} in this case, although doing so can theoretically increase power consumption).
443
443
444
-
Note that the \signal{lli\_adr\_o} signal has a width of 30 bits since it addresses words, not bytes (instructions are always word-aligned).
445
-
446
444
Since the \signal{lli\_re\_o} output signal is not registered, this interface is not suitable for interaction with off-chip peripherals. Also, care should be taken to avoid introducing too much additional combinatorial delay on its outputs.
447
445
446
+
The instruction bus, whether LLI or WISHBONE, doesn't support access to individual bytes and uses a 30-bit address port to address 32-bit words (instructions are always word-aligned). The lower two bits of the 32-bit address are ignored for the purpose of addressing. Consider the following example:
447
+
448
+
\begin{codeparbreakable}
449
+
\instr{lc} r0, 0x10000000
450
+
\instr{jmp} r0
451
+
\emph{// 0x04000000 will appear on lli_adr_o or ibus_adr_o}
452
+
\end{codeparbreakable}
453
+
448
454
\section{WISHBONE instruction bus}
449
455
450
456
The \lxp{}C CPU fetches instructions over the WISHBONE bus. Its parameters are defined in the WISHBONE datasheet (Appendix \ref{app:wishbonedatasheet}). For a detailed description of the bus protocol refer to the WISHBONE specification, revision B3.
@@ -464,7 +470,17 @@ \section{WISHBONE data bus}
464
470
465
471
\lxp{} uses the WISHBONE bus to interact with data memory and other peripherals. This bus is distinct from the instruction bus; its parameters are defined in the WISHBONE datasheet (Appendix \ref{app:wishbonedatasheet}).
466
472
467
-
This bus uses a 30-bit \signal{dbus\_adr\_o} port to address 32-bit words; the \signal{dbus\_sel\_o} port is used to select individual bytes to be written or read. Alternatively, with the \code{DBUS\_RMW} option (Section \ref{sec:generics}) the \signal{dbus\_sel\_o} port is not used; byte-granular write access is performed using the read-modify-write cycle instead.
473
+
The data bus uses a 30-bit \signal{dbus\_adr\_o} port to address 32-bit words; the \signal{dbus\_sel\_o} port is used to select individual bytes to be written or read. The upper 30 bits of the address appear on the \signal{dbus\_adr\_o} port, while the lower two bits are decoded to create a 4-bit \signal{dbus\_sel\_o} signal. Consider:
474
+
475
+
\begin{codeparbreakable}
476
+
\instr{lc} r0, 0x20000002
477
+
\instr{sb} r0, 0x55
478
+
\emph{// write 0x55 to the address in r0}
479
+
\emph{// 0x08000000 will appear on dbus_adr_o}
480
+
\emph{// 0x4 will appear on dbus_sel_o}
481
+
\end{codeparbreakable}
482
+
483
+
The byte-granular access feature is optional. If it is not needed, the \signal{dbus\_sel\_o} port can be left unconnected. It is also possible to set the \code{DBUS\_RMW} generic to \code{true} to enable byte-granular access emulation using the read-modify-write (RMW) cycle, which works even if the interconnect or slave doesn't provide the [SEL\_I()] port (Section \ref{sec:generics}).
468
484
469
485
For a detailed description of the bus protocol refer to the WISHBONE specification, revision B3.
470
486
@@ -634,7 +650,7 @@ \section{Running simulation using makefiles}
634
650
635
651
\begin{itemize}
636
652
\item\shellcmd{batch} -- simulate the design in batch mode. Results will be written to the standard output. This is the default target.
637
-
\item\shellcmd{gui} -- simulate the design in GUI mode. Note: since GHDL doesn't have a GUI, the simulation itself will be run in batch mode; upon a successful completion, GTKWave will be run automatically to display dumped waveforms.
653
+
\item\shellcmd{gui} -- simulate the design in GUI mode. Note: since GHDL doesn't have a GUI, the simulation itself will be run in batch mode; upon a completion, GTKWave will be run automatically to display the dumped waveforms.
638
654
\item\shellcmd{compile} -- compile only, don't run simulation.
639
655
\item\shellcmd{clean} -- delete all the produced artifacts.
640
656
\end{itemize}
@@ -693,7 +709,7 @@ \section{\shellcmd{lxp32asm} -- Assembler and linker}
693
709
Linkable objects are combined into a single executable module. References to symbols defined in external modules are resolved at this stage.
694
710
\end{enumerate}
695
711
696
-
In the simplest case there is only one input source file which doesn't contain external symbol references. If there are multiple input files, one of them must define the \code{entry} symbol at the beginning of the code.
712
+
In the simplest case there is only one input source file which doesn't contain external symbol references. If there are multiple input files, one of them must define the \code{entry} (or \code{Entry}) symbol at the beginning of the code.
697
713
698
714
\subsection{Command line syntax}
699
715
\label{subsec:assemblercmdline}
@@ -1646,17 +1662,33 @@ \subsection{Directives}
1646
1662
The first token of a directive statement always starts with the \code{\#} character.
Defines a macro that will be substituted with zero or more tokens. The \code{\emph{identifier}} must satisfy the requirements listed in Section \ref{sec:symbols}. Tokens can be anything, including keywords, identifiers, literals and separators (i.e. comma and colon characters).
1669
+
1670
+
\begin{codepar}
1671
+
\instr{\#error} [ \emph{msg} ]
1650
1672
\end{codepar}
1651
1673
1652
-
Defines a macro that will be substituted with one or more tokens. The \code{\emph{identifier}} must satisfy the requirements listed in Section \ref{sec:symbols}. Tokens can be anything, including keywords, identifiers, literals and separators (i.e. comma and colon characters).
1674
+
Raises a compiler error. If \emph{msg} is supplied, uses it as an error message.
1653
1675
1654
1676
\begin{codepar}
1655
1677
\instr{\#export} \emph{identifier}
1656
1678
\end{codepar}
1657
1679
1658
1680
Declares \code{\emph{identifier}} as an exported symbol. Exported symbols can be referenced by other modules.
Define C preprocessor-style conditional sections which are processed or not based on whether a certain macro has been defined. \instr{\#else} is optional. Can be nested.
1691
+
1660
1692
\begin{codepar}
1661
1693
\instr{\#import} \emph{identifier}
1662
1694
\end{codepar}
@@ -1796,6 +1828,17 @@ \section{Data bus}
1796
1828
1797
1829
\chapter{List of changes}
1798
1830
1831
+
\section*{Version 1.2 (2021-10-21)}
1832
+
1833
+
This release introduces a few non-breaking changes to the software and testbench. The CPU RTL description hasn't been changed from the previous release.
1834
+
1835
+
\begin{itemize}
1836
+
\item\shellcmd{lxp32asm} now supports C-style conditional processing directives: \instr{\#ifdef}, \instr{\#ifndef}, \instr{\#else} and \instr{\#endif}.
1837
+
\item\instr{\#define} directive can now declare a macro with zero subsitute tokens.
1838
+
\item A new \instr{\#error} directive.
1839
+
\item Minor changes to the testbench.
1840
+
\end{itemize}
1841
+
1799
1842
\section*{Version 1.1 (2019-01-11)}
1800
1843
1801
1844
This release introduces a minor but technically breaking hardware change: the START\_ADDR generic, which used to be 30-bit, has been for convenience extended to a full 32-bit word; the two least significant bits are ignored.
Copy file name to clipboardExpand all lines: misc/highlight/notepad++/LXP32Assembly.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@
26
26
<Keywordsname="Folders in comment, close"></Keywords>
27
27
<Keywordsname="Keywords1">add and call cjmpe cjmpne cjmpsg cjmpsge cjmpsl cjmpsle cjmpug cjmpuge cjmpul cjmpule divs divu hlt jmp iret lc lcs lsb lub lw mods modu mov mul neg nop not or ret sb sl srs sru sub sw xor</Keywords>
0 commit comments