microwatt.git
3 years agoliteeth: Update yaml config
Anton Blanchard [Mon, 9 Aug 2021 03:49:25 +0000 (13:49 +1000)]
liteeth: Update yaml config

csr_data_width is no longer required. Add ntxslots and nrxslots
parameters but set them to the default value.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoAdd liteeth support to Nexys Video
Anton Blanchard [Wed, 4 Aug 2021 05:59:43 +0000 (15:59 +1000)]
Add liteeth support to Nexys Video

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoMerge pull request #307 from antonblanchard/litedram-update
Michael Neuling [Mon, 9 Aug 2021 05:42:05 +0000 (15:42 +1000)]
Merge pull request #307 from antonblanchard/litedram-update

Updating to latest upstream litedram and some cleanups to associated scripts

3 years agoMerge pull request #309 from antonblanchard/clk-cleanup
Michael Neuling [Mon, 9 Aug 2021 05:31:09 +0000 (15:31 +1000)]
Merge pull request #309 from antonblanchard/clk-cleanup

Small cleanups to clock definitions

3 years agoMerge pull request #308 from antonblanchard/small-fixes
Michael Neuling [Mon, 9 Aug 2021 04:25:06 +0000 (14:25 +1000)]
Merge pull request #308 from antonblanchard/small-fixes

Fix some whitespace issues

3 years agoRemove -add from xdc files
Anton Blanchard [Mon, 9 Aug 2021 03:26:32 +0000 (13:26 +1000)]
Remove -add from xdc files

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoRemove -waveform from xdc files
Anton Blanchard [Mon, 9 Aug 2021 03:02:01 +0000 (13:02 +1000)]
Remove -waveform from xdc files

A 50% duty cycle is the default, so no need to use -waveform.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoFix some whitespace issues
Anton Blanchard [Sun, 8 Aug 2021 20:44:43 +0000 (06:44 +1000)]
Fix some whitespace issues

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoMerge pull request #305 from mikey/noflatten
Anton Blanchard [Mon, 9 Aug 2021 01:28:49 +0000 (11:28 +1000)]
Merge pull request #305 from mikey/noflatten

ci: Remove noflatten to reduce size of ECP5 builds

3 years agolitedram: Regenerate from upstream litex
Anton Blanchard [Mon, 9 Aug 2021 00:54:35 +0000 (10:54 +1000)]
litedram: Regenerate from upstream litex

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agolitedram: sdrinit() is now sdram_init()
Anton Blanchard [Mon, 9 Aug 2021 00:53:51 +0000 (10:53 +1000)]
litedram: sdrinit() is now sdram_init()

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agolitedram: Fix compiler warning
Anton Blanchard [Mon, 9 Aug 2021 00:29:48 +0000 (10:29 +1000)]
litedram: Fix compiler warning

define MAIN_RAM_BASE and MAIN_RAM_SIZE as unsigned long

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agolitedram: Update yaml files
Anton Blanchard [Mon, 9 Aug 2021 00:26:35 +0000 (10:26 +1000)]
litedram: Update yaml files

Update the litedram yaml files based on latest upstream.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agolitedram: simplify generate.py
Anton Blanchard [Mon, 9 Aug 2021 00:24:38 +0000 (10:24 +1000)]
litedram: simplify generate.py

We can call litedram_gen instead of doing the work ourselves.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agolitedram: Remove variables.mak
Anton Blanchard [Sun, 8 Aug 2021 23:49:03 +0000 (09:49 +1000)]
litedram: Remove variables.mak

Instead of creating variables.mak, just pass the variables in on
the make command line.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoci: Remove noflatten to reduce size of ECP5 builds
Michael Neuling [Wed, 4 Aug 2021 06:33:52 +0000 (16:33 +1000)]
ci: Remove noflatten to reduce size of ECP5 builds

This option was added in the commit but is no longer needed for github
CI to work.

    commit ef0dcf3bc6380cd6c3454cac7ff881a7454a8281
    Author: Michael Neuling <mikey@neuling.org>
    Date:   Thu Jul 2 14:36:14 2020 +1000
    Add SYNTH_ECP5_FLAGS option for building

Removing noflatten has the added advantage that it gets our builds
from 75% down to 59% usage on ECP5 85K.

Signed-off-by: Michael Neuling <mikey@neuling.org>
3 years agoMerge pull request #299 from mikey/vunit-make
Anton Blanchard [Wed, 4 Aug 2021 03:59:22 +0000 (13:59 +1000)]
Merge pull request #299 from mikey/vunit-make

makefile: Add check_vunit

3 years agoMerge pull request #304 from umarcor/ci-backends
Michael Neuling [Tue, 3 Aug 2021 23:57:35 +0000 (09:57 +1000)]
Merge pull request #304 from umarcor/ci-backends

ci: test 'build' with LLVM and GCC backends

3 years agoci: test 'build' with LLVM and GCC backends
umarcor [Wed, 21 Jul 2021 22:02:41 +0000 (00:02 +0200)]
ci: test 'build' with LLVM and GCC backends

Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
3 years agoMerge pull request #301 from umarcor/vunit-cleanup
Michael Neuling [Mon, 2 Aug 2021 04:22:11 +0000 (14:22 +1000)]
Merge pull request #301 from umarcor/vunit-cleanup

VUnit cleanup

3 years agomakefile: Add check_vunit
Michael Neuling [Mon, 21 Jun 2021 01:35:56 +0000 (11:35 +1000)]
makefile: Add check_vunit

Allow newly added vuint run script to be run via make. Also integrate
with DOCKER/PODMAN=1.

Signed-off-by: Michael Neuling <mikey@neuling.org>
3 years agoVUnit: style
umarcor [Wed, 21 Jul 2021 17:54:27 +0000 (19:54 +0200)]
VUnit: style

Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
3 years agoVUnit: use Path.glob instead of glob.glob
umarcor [Wed, 21 Jul 2021 17:52:24 +0000 (19:52 +0200)]
VUnit: use Path.glob instead of glob.glob

Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
3 years agoci: add 'workflow_dispatch'
umarcor [Wed, 21 Jul 2021 16:09:37 +0000 (18:09 +0200)]
ci: add 'workflow_dispatch'

Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
3 years agoci: in job 'VUnit' use a container step instead of a container job
umarcor [Wed, 21 Jul 2021 16:04:15 +0000 (18:04 +0200)]
ci: in job 'VUnit' use a container step instead of a container job

Signed-off-by: umarcor <unai.martinezcorral@ehu.eus>
3 years agoReduce the size of icache to help yosys ECP5 builds (#303)
Michael Neuling [Sat, 31 Jul 2021 01:18:39 +0000 (11:18 +1000)]
Reduce the size of icache to help yosys ECP5 builds (#303)

The icache RAM is currently LUT ram not block ram. This massively
bloats the icache size. We think this is due to yosys not inferencing
the RAM correctly but that's yet to be confirmed.

Work around this for now by reducing the default size of the icache
RAM for the ECP5 builds.

On the ECP5 85K builts, this gets us from 95% down to 76% and helps
our CI to pass.

Signed-off-by: Michael Neuling <mikey@neuling.org>
3 years agoMerge pull request #296 from LarsAsplund/logging-checking
Michael Neuling [Mon, 21 Jun 2021 07:58:34 +0000 (17:58 +1000)]
Merge pull request #296 from LarsAsplund/logging-checking

Replaced VHDL assert and report with VUnit checking and logging

3 years agoMerge pull request #298 from paulusmack/master
Michael Neuling [Mon, 21 Jun 2021 01:51:13 +0000 (11:51 +1000)]
Merge pull request #298 from paulusmack/master

MMU: Implement a vestigial partition table

3 years agoMerge pull request #295 from LarsAsplund/master
Michael Neuling [Mon, 21 Jun 2021 01:25:40 +0000 (11:25 +1000)]
Merge pull request #295 from LarsAsplund/master

Run VHDL tests with VUnit

3 years agoMMU: Implement a vestigial partition table
Paul Mackerras [Thu, 17 Jun 2021 10:01:32 +0000 (20:01 +1000)]
MMU: Implement a vestigial partition table

This implements a 1-entry partition table, so that instead of getting
the process table base address from the PRTBL SPR, the MMU now reads
the doubleword pointed to by the PTCR register plus 8 to get the
process table base address.  The partition table entry is cached.

Having the PTCR and the vestigial partition table reduces the amount
of software change required in Linux for Microwatt support.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoReplaced VHDL assert and report with VUnit checking and logging
Lars Asplund [Wed, 9 Jun 2021 21:50:02 +0000 (23:50 +0200)]
Replaced VHDL assert and report with VUnit checking and logging

The VUnit log package is a SW style logging framework in VHDL and the check package is an assertion library doing its error reporting with VUnit logging.
These testbenches don't use, and do not need, very advanced logging/checking features but the following was possible to improve

- Checking equality in VHDL can be quite tedious with a lot of type conversions and long message strings to explain the data received and what was expected.
  VUnit's check_equal procedure allow comparison between same or similar types and automatically create the error message for you.
- The code has report statements used for testbench progress reporting and debugging. These were replaced with the info and debug procedures.
  info logs are visible by default while debug is not. This means that debug logs don't have to be commented, which they are now, when not used.
  Instead there is a show procedure making debug messages visible. The show procedure has been commented to hide the debug messages but a more elegant
  solution is to control visibility from a generic and then set that generic from the command line. I've left this as a TODO but the run script allow you to
  extend the standard CLI of VUnit to add new options and you can also set generics from the run script.
- VUnit log messages are color coded if color codes are supported by the terminal. It makes it quicker to spot messages of different types when there are many log messages.
  Error messages will always be made visible on the terminal but you must use the -v (verbose) to see other logs.
- Some tests have a lot of "metvalue detected" warning messages from the numeric_std package and these clutter the logs when using the -v option. VUnit has a simulator independent
  option allowing you to suppress those messages. That option has been enabled.

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
3 years agoRun VUnit tests in CI
Lars Asplund [Wed, 9 Jun 2021 14:19:24 +0000 (16:19 +0200)]
Run VUnit tests in CI

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
3 years agoOrganized VUnit testbenches into test cases.
Lars Asplund [Tue, 8 Jun 2021 20:32:57 +0000 (22:32 +0200)]
Organized VUnit testbenches into test cases.

Several of the testbenches have stimuli code divided into sections preceded with a header comment explaining
what is being tested. These sections have been made into VUnit test cases. The default behavior of VUnit is
to run each test case in a separate simulation which comes with a number of benefits:

* A failing test case doesn't prevent other test cases to be executed
* Test cases are independent. A test case cannot fail as a side-effect to a problem with another test case
* Test execution can be more parallelized and the overall test execution time reduced

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
3 years agoMake core testbenches recognized by VUnit
Lars Asplund [Mon, 7 Jun 2021 20:34:00 +0000 (22:34 +0200)]
Make core testbenches recognized by VUnit

This commit also removes the dependencies these testbenches have on VHPIDIRECT.
The use of VHPIDIRECT limits the number of available simulators for the project. Rather than using
foreign functions the testbenches can be implemented entirely in VHDL where equivalent functionality exists.
For these testbenches the VHPIDIRECT-based randomization functions were replaced with VHDL-based functions.

The testbenches recognized by VUnit can be executed in parallel threads for better simulation performance using
the -p option to the run.py script

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
3 years agoAdded VUnit run script.
Lars Asplund [Mon, 7 Jun 2021 20:05:57 +0000 (22:05 +0200)]
Added VUnit run script.

The VUnit run script will find all VHDL files based on given search patterns, figure out their dependencies, and support incremental compile based on the dependencies.
The same script is used for all VUnit supported simulators. Supporting several simulators simplifies the adoption of this project.

At this point only compilation is performed. Coming commits will enable simulation of VHDL testbenches.

Signed-off-by: Lars Asplund <lars.anders.asplund@gmail.com>
3 years agoMerge pull request #277 from paulus/gpio
Michael Neuling [Mon, 17 May 2021 06:19:47 +0000 (16:19 +1000)]
Merge pull request #277 from paulus/gpio

A few cleanups. GPIO IRQ number is now 4 as 3 is now taken by the SD card.

3 years agoMerge pull request #287 from paulusmack/master
Michael Neuling [Thu, 13 May 2021 23:11:41 +0000 (09:11 +1000)]
Merge pull request #287 from paulusmack/master

Add SD card interface

3 years agoMerge pull request #278 from shenki/openocd-v0.11
Paul Mackerras [Tue, 11 May 2021 10:25:29 +0000 (20:25 +1000)]
Merge pull request #278 from shenki/openocd-v0.11

Add files for openocd v0.11

3 years agoopenocd: Fix verify command for v0.10
Joel Stanley [Tue, 11 May 2021 04:47:26 +0000 (14:17 +0930)]
openocd: Fix verify command for v0.10

v0.11 uses verify_image, which is not supported by v0.11. Use the old
verify_bank for v0.10.

Signed-off-by: Joel Stanley <joel@jms.id.au>
3 years agoarty_a7: Add litesdcard interface
Paul Mackerras [Thu, 15 Apr 2021 07:22:31 +0000 (17:22 +1000)]
arty_a7: Add litesdcard interface

This adds litesdcard.v generated from the litex/litesdcard project,
along with logic in top-arty.vhdl to connect it into the system.
There is now a DMA wishbone coming in to soc.vhdl which is narrower
than the other wishbone masters (it has 32-bit data rather than
64-bit) so there is a widening/narrowing adapter between it and the
main wishbone master arbiter.

Also, litesdcard generates a non-pipelined wishbone for its DMA
connection, which needs to be converted to a pipelined wishbone.  We
have a latch on both the incoming and outgoing sides of the wishbone
in order to help make timing (at the cost of two extra cycles of
latency).

litesdcard generates an interrupt signal which is wired up to input 3
of the ICS (IRQ 19).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoicache: Snoop writes to memory by other agents
Paul Mackerras [Tue, 11 May 2021 04:04:08 +0000 (14:04 +1000)]
icache: Snoop writes to memory by other agents

This makes the icache snoop writes to memory in the same way that the
dcache does, thus making DMA cache-coherent for the icache as well as
the dcache.

This also simplifies the logic for the WAIT_ACK state by removing the
stbs_done variable, since is_last_row(r.store_row, r.end_row_ix) can
only be true when stbs_done is true.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodcache: Simplify logic in RELOAD_WAIT_ACK state
Paul Mackerras [Tue, 11 May 2021 01:29:46 +0000 (11:29 +1000)]
dcache: Simplify logic in RELOAD_WAIT_ACK state

Since the expression is_last_row(r1.store_row, r1.end_row_ix) can only
be true when stbs_done is true, there is no need to include stbs_done
in the expression for the reload being completed, and hence no need to
compute stbs_done in the RELOAD_WAIT_ACK state.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodcache: Snoop writes to memory by other agents
Paul Mackerras [Tue, 11 May 2021 00:54:57 +0000 (10:54 +1000)]
dcache: Snoop writes to memory by other agents

This adds a path where the wishbone that goes out to memory and I/O
also gets fed back to the dcache, which looks for writes that it
didn't initiate, and invalidates any cache line that gets written to.

This involves a second read port on the cache tag RAM for looking up
the snooped writes, and effectively a second write port on the cache
valid bit array to clear bits corresponding to snoop hits.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoMerge pull request #283 from antonblanchard/whitespace
Paul Mackerras [Wed, 5 May 2021 00:20:46 +0000 (10:20 +1000)]
Merge pull request #283 from antonblanchard/whitespace

Fix a few whitespace issues.  Only changes whitespace and comments.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoUpdate documentation. (#280)
Antony Vennard [Wed, 5 May 2021 00:15:26 +0000 (02:15 +0200)]
Update documentation. (#280)

Update documentation to reference fusesoc init for Xilinx boards, for
those like me who have never used fusesoc before. Add a reference to the
board files for Digilent boards and comment on perhaps installing them
for other boards as appropriate.

Signed-off-by: Antony Vennard <antony@vennard.ch>
3 years agoMerge pull request #286 from antonblanchard/Makefile-cleanup-3
Anton Blanchard [Thu, 25 Mar 2021 03:43:45 +0000 (14:43 +1100)]
Merge pull request #286 from antonblanchard/Makefile-cleanup-3

A few more Makefile cleanups

3 years agoRemove unused GHDL_TARGET_GENERICS
Anton Blanchard [Thu, 25 Mar 2021 03:05:00 +0000 (14:05 +1100)]
Remove unused GHDL_TARGET_GENERICS

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoMove verilator --trace flag into VERILATOR_FLAGS
Anton Blanchard [Wed, 24 Mar 2021 10:40:26 +0000 (21:40 +1100)]
Move verilator --trace flag into VERILATOR_FLAGS

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoMerge pull request #285 from antonblanchard/Makefile-cleanup-2
Anton Blanchard [Wed, 24 Mar 2021 10:31:54 +0000 (21:31 +1100)]
Merge pull request #285 from antonblanchard/Makefile-cleanup-2

A few Makefile cleanups

3 years agoMerge pull request #281 from antonblanchard/cache-tlb-parameters
Anton Blanchard [Wed, 24 Mar 2021 09:44:45 +0000 (20:44 +1100)]
Merge pull request #281 from antonblanchard/cache-tlb-parameters

Pass icache/dcache/tlb parameters down from soc

3 years agoRemove -frelaxed
Anton Blanchard [Wed, 24 Mar 2021 06:08:29 +0000 (17:08 +1100)]
Remove -frelaxed

We don't appear to need this any more, so remove it.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoUse VERILATOR_FLAGS/VERILATOR_CFLAGS on all verilator targets
Anton Blanchard [Wed, 24 Mar 2021 06:07:56 +0000 (17:07 +1100)]
Use VERILATOR_FLAGS/VERILATOR_CFLAGS on all verilator targets

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoRemove core_files from soc_files and fpga_files
Anton Blanchard [Wed, 24 Mar 2021 04:08:18 +0000 (15:08 +1100)]
Remove core_files from soc_files and fpga_files

We were already including the core_files at the same time as the
soc_files in many targets.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoMerge pull request #284 from antonblanchard/boot-clocks
Anton Blanchard [Tue, 23 Mar 2021 09:02:27 +0000 (20:02 +1100)]
Merge pull request #284 from antonblanchard/boot-clocks

Allow SPI BOOT_CLOCKS to be overridden by top level

3 years agoReformat spi_flash_ctrl
Anton Blanchard [Mon, 22 Mar 2021 00:01:10 +0000 (11:01 +1100)]
Reformat spi_flash_ctrl

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat control
Anton Blanchard [Sun, 21 Mar 2021 23:55:53 +0000 (10:55 +1100)]
Reformat control

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat testbenches
Anton Blanchard [Sun, 21 Mar 2021 23:55:32 +0000 (10:55 +1100)]
Reformat testbenches

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat writeback
Anton Blanchard [Sun, 21 Mar 2021 23:19:27 +0000 (10:19 +1100)]
Reformat writeback

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat plru
Anton Blanchard [Sun, 21 Mar 2021 23:17:49 +0000 (10:17 +1100)]
Reformat plru

Also fix a typo

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat rotator
Anton Blanchard [Sun, 21 Mar 2021 23:09:39 +0000 (10:09 +1100)]
Reformat rotator

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat divider
Anton Blanchard [Sun, 21 Mar 2021 23:08:29 +0000 (10:08 +1100)]
Reformat divider

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat countzero
Anton Blanchard [Sun, 21 Mar 2021 23:07:47 +0000 (10:07 +1100)]
Reformat countzero

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat cr_file
Anton Blanchard [Sun, 21 Mar 2021 23:07:33 +0000 (10:07 +1100)]
Reformat cr_file

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat register_file
Anton Blanchard [Sun, 21 Mar 2021 23:06:03 +0000 (10:06 +1100)]
Reformat register_file

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoReformat cache_ram
Anton Blanchard [Sun, 21 Mar 2021 22:56:12 +0000 (09:56 +1100)]
Reformat cache_ram

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoAllow SPI BOOT_CLOCKS to be overridden by top level
Anton Blanchard [Mon, 15 Mar 2021 09:03:45 +0000 (20:03 +1100)]
Allow SPI BOOT_CLOCKS to be overridden by top level

Our SPI controller sends 8 dummy clocks at boot which Ben
added for some Xilinx boards. This should be harmless but
it is confusing the flash testbench in the Caravel project.

Add a parameter so it can be overridden at the top level.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoPass icache/dcache/tlb parameters down from soc
Anton Blanchard [Mon, 15 Mar 2021 07:18:21 +0000 (18:18 +1100)]
Pass icache/dcache/tlb parameters down from soc

We want much smaller caches and tlbs when building for sky130, so
allow the toplevel file to override the defaults.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agoarty: Update GPIOs for Boxarty BMC
Paul Mackerras [Tue, 9 Mar 2021 02:16:28 +0000 (13:16 +1100)]
arty: Update GPIOs for Boxarty BMC

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoAdd files for openocd v0.11
Joel Stanley [Wed, 17 Feb 2021 06:39:47 +0000 (17:09 +1030)]
Add files for openocd v0.11

The protocol used by the spi bridge firmware changed as of openocd
v0.11. As this is the version packaged by Debian Bullseye, add the
firmware for convince.

Signed-off-by: Joel Stanley <joel@jms.id.au>
3 years agoAdd a GPIO controller and use it to drive the shield I/O pins on the Arty
Paul Mackerras [Tue, 23 Feb 2021 10:44:04 +0000 (21:44 +1100)]
Add a GPIO controller and use it to drive the shield I/O pins on the Arty

This adds a GPIO controller which provides 32 bits of I/O.  The
registers are modelled on the set used by the gpio-ftgpio010.c driver
in the Linux kernel.  Currently there is no interrupt capability
implemented, though an interrupt line from the GPIO subsystem to the
XICS has been connected.

For the Arty A7 board, GPIO lines 0 to 13 are connected to the pins
labelled IO0 to IO13 on the "shield" connector, GPIO lines 14 to 29
connect to IO26 to IO41, GPIO line 30 connects to the pin labelled A
(aka IO42), and GPIO line 31 is connected to LED 7.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoMerge pull request #274 from mikey/read-sprs
Michael Neuling [Mon, 8 Feb 2021 23:06:03 +0000 (10:06 +1100)]
Merge pull request #274 from mikey/read-sprs

Fix reading DSISR/DAR before writing and add a test to read from all SPRs

3 years agoAdd a test to read from all SPRs
Anton Blanchard [Mon, 4 Jan 2021 03:16:06 +0000 (14:16 +1100)]
Add a test to read from all SPRs

Make sure the SPRs are initialized and we can't read X state.

(Mikey: rebased and added console/bin file for testing)

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
Signed-off-by: Michael Neuling <mikey@neuling.org>
3 years agoFix DAR/DSISR reading before they are written
Michael Neuling [Mon, 8 Feb 2021 09:17:48 +0000 (20:17 +1100)]
Fix DAR/DSISR reading before they are written

If the DAR and DSISR are read before they are written, we assert with:

  register_file.vhdl:55:25:@60195ns:(report note): Writing GPR 09 00000000XXXXXXXX
  register_file.vhdl:61:17:@60195ns:(assertion failure): Assertion violation

This initialises DAR/DSISR to avoid this.

Signed-off-by: Michael Neuling <mikey@neuling.org>
3 years agoMerge pull request #269 from paulusmack/pipeline
Michael Neuling [Mon, 8 Feb 2021 06:27:16 +0000 (17:27 +1100)]
Merge pull request #269 from paulusmack/pipeline

Rework load/store pipeline to achieve one load/store per cycle throughput

3 years agoMerge pull request #268 from paulusmack/btc
Michael Neuling [Mon, 8 Feb 2021 05:38:57 +0000 (16:38 +1100)]
Merge pull request #268 from paulusmack/btc

Implement branch target cache

3 years agoMerge pull request #273 from antonblanchard/wishbone-checking
Michael Neuling [Mon, 8 Feb 2021 03:34:53 +0000 (14:34 +1100)]
Merge pull request #273 from antonblanchard/wishbone-checking

Add some wishbone checking

3 years agoMerge pull request #267 from paulusmack/master
Michael Neuling [Mon, 8 Feb 2021 03:26:53 +0000 (14:26 +1100)]
Merge pull request #267 from paulusmack/master

Improve architecture compliance and other miscellaneous changes

3 years agoAdd some wishbone checking
Anton Blanchard [Mon, 8 Feb 2021 01:15:53 +0000 (12:15 +1100)]
Add some wishbone checking

Check that stb, cyc and ack are never undefined. While not really needed
here, this also tests if --pragma synthesis_off/--pragma synthesis_on
works on all the tools we use.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
3 years agocore: Allow multiple loadstore instructions to be in flight
Paul Mackerras [Mon, 28 Dec 2020 04:15:30 +0000 (15:15 +1100)]
core: Allow multiple loadstore instructions to be in flight

The idea here is that we can have multiple instructions in progress at
the same time as long as they all go to the same unit, because that
unit will keep them in order.  If we get an instruction for a
different unit, we wait for all the previous instructions to finish
before executing it.  Since the loadstore unit is the only one that is
currently pipelined, this boils down to saying that loadstore
instructions can go ahead while l_in.in_progress = 1 but other
instructions have to wait until it is 0.

This gives a 2% increase on coremark performance on the Arty A7-100
(from ~190 to ~194).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoloadstore: Convert to 3-stage pipeline
Paul Mackerras [Sat, 7 Nov 2020 09:50:58 +0000 (20:50 +1100)]
loadstore: Convert to 3-stage pipeline

This makes loadstore use a 3-stage pipeline.  For now, only one
instruction goes through the pipe at a time.  Completion and writeback
are still combinatorial off the valid signal back from the dcache, so
performance should be the same as before.  In future it should be able
to sustain one load or store per cycle provided they hit in the
dcache.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodcache: Fix bugs in pipelined operation
Paul Mackerras [Sun, 17 Jan 2021 21:55:56 +0000 (08:55 +1100)]
dcache: Fix bugs in pipelined operation

This fixes two bugs which show up when multiple operations are in
flight in the dcache, and adds a 'hold' input which will be needed
when loadstore1 is pipelined.

The first bug is that dcache needs to sample the data for a store on
the cycle after the store request comes in even if the store request
is held up because of a previous request (e.g. if the previous request
is a load miss or a dcbz).

The second bug is that a load request coming in for a cache line being
refilled needs to be handled immediately in the case where it is for
the row whose data arrives on the same cycle.  If it is not, then it
will be handled as a separate cache miss and the cache line will be
refilled again into a different way, leading to two ways both being
valid for the same tag.  This can lead to data corruption, in the
scenario where subsequent writes go to one of the ways and then that
way gets displaced but the other way doesn't.  This bug could in
principle show up even without having multiple operations in flight in
the dcache.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Send FPU interrupts to writeback rather than execute1
Paul Mackerras [Wed, 23 Dec 2020 02:57:40 +0000 (13:57 +1100)]
core: Send FPU interrupts to writeback rather than execute1

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Send loadstore1 interrupts to writeback rather than execute1
Paul Mackerras [Wed, 23 Dec 2020 01:27:22 +0000 (12:27 +1100)]
core: Send loadstore1 interrupts to writeback rather than execute1

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Move redirect and interrupt delivery logic to writeback
Paul Mackerras [Wed, 23 Dec 2020 00:13:21 +0000 (11:13 +1100)]
core: Move redirect and interrupt delivery logic to writeback

This moves the logic for redirecting fetching and writing SRR0 and
SRR1 to writeback.  The aim is that ultimately units other than
execute1 can send their interrupts to writeback along with their
instruction completions, so that there can be multiple instructions
in flight without needing execute1 to keep track of the address
of each outstanding instruction.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoexecute1: Move CR result to data path process
Paul Mackerras [Fri, 27 Nov 2020 06:41:39 +0000 (17:41 +1100)]
execute1: Move CR result to data path process

Also work out in decode2 whether the instruction sets the XER common
bits.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoexecute1: Move data-path logic out to a separate process
Paul Mackerras [Thu, 26 Nov 2020 11:10:30 +0000 (22:10 +1100)]
execute1: Move data-path logic out to a separate process

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Track CR hazards and bypasses using tags
Paul Mackerras [Thu, 12 Nov 2020 11:07:33 +0000 (22:07 +1100)]
core: Track CR hazards and bypasses using tags

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Restore bypass path from execute1
Paul Mackerras [Tue, 10 Nov 2020 22:42:17 +0000 (09:42 +1100)]
core: Restore bypass path from execute1

This changes the bypass path.  Previously it went from after
execute1's output to after decode2's output.  Now it goes from before
execute1's output register to before decode2's output register.  The
reason is that the new path will be simpler to manage when there are
possibly multiple instructions in flight.  This means that the
bypassing can be managed inside decode2 and control.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Track GPR hazards using tags that propagate through the pipelines
Paul Mackerras [Tue, 10 Nov 2020 09:04:00 +0000 (20:04 +1100)]
core: Track GPR hazards using tags that propagate through the pipelines

This changes the way GPR hazards are detected and tracked.  Instead of
having a model of the pipeline in gpr_hazard.vhdl, which has to mirror
the behaviour of the real pipeline exactly, we now assign a 2-bit tag
to each instruction and record which GSPR the instruction writes.
Subsequent instructions that need to use the GSPR get the tag number
and stall until the value with that tag is being written back to the
register file.

For now, the forwarding paths are disabled.  That gives about a 8%
reduction in coremark performance.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Crack branches that update both CTR and LR
Paul Mackerras [Wed, 11 Nov 2020 11:10:38 +0000 (22:10 +1100)]
core: Crack branches that update both CTR and LR

This uses the instruction doubling machinery to convert conditional
branch instructions that update both CTR and LR (e.g., bdnzl, bdnzlrl)
into two instructions, of which the first updates CTR and determines
whether the branch is taken, and the second updates LR and does the
redirect if necessary.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Crack update-form loads into two internal ops
Paul Mackerras [Wed, 11 Nov 2020 07:11:04 +0000 (18:11 +1100)]
core: Crack update-form loads into two internal ops

This uses the instruction-doubling machinery to send load with update
instructions down to loadstore1 as two separate ops, rather than
one op with two destinations.  This will help to simplify the value
tracking mechanisms.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agofetch1: Implement a simple branch target cache
Paul Mackerras [Fri, 18 Dec 2020 22:25:04 +0000 (09:25 +1100)]
fetch1: Implement a simple branch target cache

This implements a cache in fetch1, where each entry stores the address
of a simple branch instruction (b or bc) and the target of the branch.
When fetching sequentially, if the address being fetched matches the
cache entry, then fetching will be redirected to the branch target.
The cache has 1024 entries and is direct-mapped, i.e. indexed by bits
11..2 of the NIA.

The bus from execute1 now carries information about taken and
not-taken simple branches, which fetch1 uses to update the cache.
The cache entry is updated for both taken and not-taken branches, with
the valid bit being set if the branch was taken and cleared if the
branch was not taken.

If fetching is redirected to the branch target then that goes down the
pipe as a predicted-taken branch, and decode1 does not do any static
branch prediction.  If fetching is not redirected, then the next
instruction goes down the pipe as normal and decode1 does its static
branch prediction.

In order to make timing, the lookup of the cache is pipelined, so on
each cycle the cache entry for the current NIA + 8 is read.  This
means that after a redirect (from decode1 or execute1), only the third
and subsequent sequentially-fetched instructions will be able to be
predicted.

This improves the coremark value on the Arty A7-100 from about 180 to
about 190 (more than 5%).

The BTC is optional.  Builds for the Artix 7 35-T part have it off by
default because the extra ~1420 LUTs it takes mean that the design
doesn't fit on the Arty A7-35 board.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoexecute1: Improve timing on comparisons
Paul Mackerras [Mon, 28 Sep 2020 04:04:08 +0000 (14:04 +1000)]
execute1: Improve timing on comparisons

Using the main adder for comparisons has the disadvantage of creating
a long path from the CA/OV bit forwarding to v.busy via the carry
input of the adder, the comparison result, and determining whether a
trap instruction would trap.  Instead we now have dedicated
comparators for the high and low words of a_in vs. b_in, and combine
their results to get the signed and unsigned comparison results.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Reorganize execute1
Paul Mackerras [Sat, 26 Sep 2020 09:58:46 +0000 (19:58 +1000)]
core: Reorganize execute1

This breaks up the enormous if .. elsif .. case .. elsif statement in
execute1 in order to try to make it simpler and more understandable.
We now have decode2 deciding whether the instruction has a value to be
written back to a register (GPR, GSPR, FPR, etc.) rather than
individual cases in execute1 setting result_en.  The computation of
the data to be written back is now independent of detection of various
exception conditions.  We now have an if block determining if any
exception condition exists which prevents the next instruction from
being executed, then the case statement which performs actions such as
setting carry/overflow bits, determining if a trap exception exists,
doing branches, etc., then an if statement for all the r.busy = 1
cases (continuing execution of an instruction which was started in a
previous cycle, or writing SRR1 for an interrupt).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodecode1: Implement tlbsync as a no-op
Paul Mackerras [Sat, 10 Oct 2020 03:34:01 +0000 (14:34 +1100)]
decode1: Implement tlbsync as a no-op

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Make result multiplexing explicit
Paul Mackerras [Sat, 26 Sep 2020 07:19:57 +0000 (17:19 +1000)]
core: Make result multiplexing explicit

This adds an explicit multiplexer feeding v.e.write_data in execute1,
with the select lines determined in the previous cycle based on the
insn_type.  Similarly, for multiply and divide instructions, there is
now an explicit multiplexer.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodecode1: Implement obsolete dst, dstst, dss instructions as no-ops
Paul Mackerras [Tue, 22 Sep 2020 00:03:30 +0000 (10:03 +1000)]
decode1: Implement obsolete dst, dstst, dss instructions as no-ops

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoexecute1: Move branch adder after register
Paul Mackerras [Wed, 16 Dec 2020 09:41:08 +0000 (20:41 +1100)]
execute1: Move branch adder after register

This does the addition of the instruction NIA and the branch offset
after the register at the output of execute1 rather than before.
The propagation through the adder was showing up as a critical path
on the A7-100.  Performance is unaffected and now it makes timing.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodecode: Add a facility field to the instruction decode tables
Paul Mackerras [Sat, 12 Dec 2020 01:38:06 +0000 (12:38 +1100)]
decode: Add a facility field to the instruction decode tables

This makes it simpler to work out when to deliver a FPU unavailable
interrupt.  This also means we can get rid of the OP_FPLOAD and
OP_FPSTORE insn_type values.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodecode1: Take an extra cycle for predicted branch redirects
Paul Mackerras [Wed, 16 Dec 2020 08:32:07 +0000 (19:32 +1100)]
decode1: Take an extra cycle for predicted branch redirects

This does the addition of NIA plus the branch offset from the
instruction after a clock edge, in order to ease timing, as the path
from the icache RAM through the adder in decode1 to the NIA register
in fetch1 was showing up as a critical path.

This adds one extra cycle of latency when redirecting fetch because of
a predicted-taken branch.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>