microwatt.git
4 years agomultiply: Move selection of result bits into execute1
Paul Mackerras [Thu, 21 May 2020 03:42:46 +0000 (13:42 +1000)]
multiply: Move selection of result bits into execute1

This puts the logic that selects which bits of the multiplier result
get written into the destination GPR into execute1, moved out from
multiply.

The multiplier is now expected to do an unsigned multiplication of
64-bit operands, optionally negate the result, detect 32-bit
or 64-bit signed overflow of the result, and return a full 128-bit
result.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agocore: Double the dcache and icache sizes
Paul Mackerras [Wed, 3 Jun 2020 01:26:33 +0000 (11:26 +1000)]
core: Double the dcache and icache sizes

This makes the dcache and icache both be 8kB.  This still only uses
one BRAM per way per cache on the Artix-7, since the BRAMs were only
half-used previously.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agocore: Remove fetch2 pipeline stage
Paul Mackerras [Sun, 10 May 2020 08:18:03 +0000 (18:18 +1000)]
core: Remove fetch2 pipeline stage

The fetch2 stage existed primarily to provide a stash buffer for the
output of icache when a stall occurred.  However, we can get the same
effect -- of having the input to decode1 stay unchanged on a stall
cycle -- by using the read enable of the BRAMs in icache, and by
adding logic to keep the outputs unchanged on a clock cycle when
stall_in = 1.  This reduces branch and interrupt latency by one
cycle.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoAdd core logging
Paul Mackerras [Thu, 14 May 2020 03:25:48 +0000 (13:25 +1000)]
Add core logging

This logs 256 bits of data per cycle to a ring buffer in BRAM.  The
data collected can be read out through 2 new SPRs or through the
debug interface.

The new SPRs are LOG_ADDR (724) and LOG_DATA (725).  LOG_ADDR contains
the buffer write pointer in the upper 32 bits (in units of entries,
i.e. 32 bytes) and the read pointer in the lower 32 bits (in units of
doublewords, i.e. 8 bytes).  Reading LOG_DATA gives the doubleword
from the buffer at the read pointer and increments the read pointer.
Setting bit 31 of LOG_ADDR inhibits the trace log system from writing
to the log buffer, so the contents are stable and can be read.

There are two new debug addresses which function similarly to the
LOG_ADDR and LOG_DATA SPRs.  The log is frozen while either or both of
the LOG_ADDR SPR bit 31 or the debug LOG_ADDR register bit 31 are set.

The buffer defaults to 2048 entries, i.e. 64kB.  The size is set by
the LOG_LENGTH generic on the core_debug module.  Software can
determine the length of the buffer because the length is ORed into the
buffer write pointer in the upper 32 bits of LOG_ADDR.  Hence the
length of the buffer can be calculated as 1 << (31 - clz(LOG_ADDR)).

There is a program to format the log entries in a somewhat readable
fashion in scripts/fmt_log/fmt_log.c.  The log_entry struct in that
file describes the layout of the bits in the log entries.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoscripts/mw_debug: Make progress counts display on one line
Paul Mackerras [Sat, 13 Jun 2020 09:59:17 +0000 (19:59 +1000)]
scripts/mw_debug: Make progress counts display on one line

This outputs a carriage return rather than a newline after the
display of the progress count during the load and save operations.
This makes the output more compact and better looking.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agotests/xics: Fix assumption that interrupts happen immediately
Paul Mackerras [Thu, 11 Jun 2020 04:57:30 +0000 (14:57 +1000)]
tests/xics: Fix assumption that interrupts happen immediately

Currently the test writes to the XICS and then checks that the
expected interrupt has happened.  This turns into a stbcix
instruction followed immediately by a load from the variable that
indicates whether an interrupt has happened.  It is possible for
it to take a few cycles for the store to reach the XICS and the
interrupt request signal to come back to the core, particularly
with improvements to the load/store unit and dcache.

This therefore adds a delay between storing to the XICS and
checking for the occurrence of an interrupt, so as to give the
signals time to propagate.  The delay loop does an arbitrary 10
iterations, and each iteration does two loads and one store to
(cacheable) memory.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoregister_file: Report value being written before asserting it's not X
Paul Mackerras [Sat, 13 Jun 2020 07:22:56 +0000 (17:22 +1000)]
register_file: Report value being written before asserting it's not X

If a bug causes an indeterminate value to be written to a GPR, an
assert causes simulation to abort.  Move the assert after the report
of the GPR index and value so that we get to know what the bad value
is before the simulation terminates.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoMerge pull request #205 from ozbenh/timing
Paul Mackerras [Sat, 13 Jun 2020 02:36:16 +0000 (12:36 +1000)]
Merge pull request #205 from ozbenh/timing

Timing improvements

4 years agoMerge pull request #204 from ozbenh/spi
Paul Mackerras [Sat, 13 Jun 2020 02:27:40 +0000 (12:27 +1000)]
Merge pull request #204 from ozbenh/spi

Add an SPI master flash controller

4 years agosyscon: Remove combinational loop on ack and stall
Benjamin Herrenschmidt [Fri, 12 Jun 2020 11:48:01 +0000 (21:48 +1000)]
syscon: Remove combinational loop on ack and stall

Those hurt timings. Instead latch the wishbone response for one cycle

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agobram: Remove combinational loop on stall
Benjamin Herrenschmidt [Fri, 12 Jun 2020 11:47:06 +0000 (21:47 +1000)]
bram: Remove combinational loop on stall

It hurts timing and is pointless

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agouart: Remove combinational loops on ack and stall signal
Benjamin Herrenschmidt [Fri, 12 Jun 2020 11:46:37 +0000 (21:46 +1000)]
uart: Remove combinational loops on ack and stall signal

They hurt timing forcing signals to come from the master and back
again in one cycle. Stall isn't sampled by the master unless there
is an active cycle so masking it with cyc is pointless. Masking acks
is somewhat pointless too as we don't handle early dropping of cyc
in any of our slaves properly anyways.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agospi: Add booting from flash to litedram init
Benjamin Herrenschmidt [Wed, 10 Jun 2020 03:35:18 +0000 (13:35 +1000)]
spi: Add booting from flash to litedram init

It will look for an ELF binary at the flash offset specified
for the board (currently 0x300000 on Arty but that could be
changed).

Note: litedram is regenerated in order to rebuild the init code,
which was done using a newer version of litedram from LiteX.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agospi: Add simulation support
Benjamin Herrenschmidt [Wed, 10 Jun 2020 03:35:10 +0000 (13:35 +1000)]
spi: Add simulation support

This require the s25fl128s.vhd flash model and FMF libraries,
which will be built when passed to the Makefile via the
FLASH_MODEL_PATH argument. Otherwise a dummy module is used
which ties MISO to '1'.

The model isn't included as I'm not sure its licence (GPL) is
at this point, but it can be obtained from

https://github.com/ozbenh/microspi

FLASH_MODEL_PATH=<path to microspi>/model

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoflash-arty: update error message (#203)
Dan Horák [Fri, 12 Jun 2020 22:46:28 +0000 (00:46 +0200)]
flash-arty: update error message (#203)

Signed-off-by: Dan Horák <dan@danny.cz>
4 years agodmi: Add ASYNC_REG attribute on synchronizers (#200)
Benjamin Herrenschmidt [Fri, 12 Jun 2020 22:44:43 +0000 (08:44 +1000)]
dmi: Add ASYNC_REG attribute on synchronizers (#200)

This tells Vivado to keep them close among other things

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoicache: Latch PLRU victim output (#199)
Benjamin Herrenschmidt [Fri, 12 Jun 2020 22:43:47 +0000 (08:43 +1000)]
icache: Latch PLRU victim output (#199)

This stores the output of the PLRU big mux and clears the
tags and valid bits on the next cycle.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #198 from ozbenh/litedram
Paul Mackerras [Fri, 12 Jun 2020 22:01:55 +0000 (08:01 +1000)]
Merge pull request #198 from ozbenh/litedram

Litedram: Timing improvements

4 years agospi: Add SPI Flash controller
Benjamin Herrenschmidt [Fri, 5 Jun 2020 01:32:08 +0000 (11:32 +1000)]
spi: Add SPI Flash controller

This adds an SPI flash controller which supports direct
memory-mapped access to the flash along with a manual
mode to send commands.

The direct mode can be set via generic to default to single
wire or quad mode. The controller supports normal, dual and quad
accesses with configurable commands, clock divider, dummy clocks
etc...

The SPI clock can be an even divider of sys_clk starting at 2
(so max 50Mhz with our typical Arty designs).

A flash offset is carried via generics to syscon to tell SW about
which portion of the flash is reserved for the FPGA bitfile. There
is currently no plumbing to make the CPU reset past that address (TBD).

Note: Operating at 50Mhz has proven unreliable without adding some
delay to the sampling of the input data. I'm working in improving
this, in the meantime, I'm leaving the default set at 25 Mhz.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: L2 use latched refill_index
Benjamin Herrenschmidt [Thu, 11 Jun 2020 10:18:24 +0000 (20:18 +1000)]
litedram: L2 use latched refill_index

Not a huge difference since wb_req is itself a latch but
may as well

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Pipeline store acks in L2
Benjamin Herrenschmidt [Wed, 10 Jun 2020 13:45:42 +0000 (23:45 +1000)]
litedram: Pipeline store acks in L2

There is a long timing path to generate the ack signal from
the L2 cache as it's fully combinational for stores, including
signals coming from litedram.

Instead, pipeline the store acks. This will introduce a cycle
latency but should improve timing. Also the core will eventually
be smart enough not to wait for store acks to complete them anyway.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoarty/nexys-video: Update XDC
Benjamin Herrenschmidt [Wed, 10 Jun 2020 09:06:02 +0000 (19:06 +1000)]
arty/nexys-video: Update XDC

The DRAM related pins have some small changes in LiteX, so resync
and add the false path information as well.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Add stash buffer to the L2 cache wishbone interface
Benjamin Herrenschmidt [Wed, 10 Jun 2020 06:47:18 +0000 (16:47 +1000)]
litedram: Add stash buffer to the L2 cache wishbone interface

This breaks the long stall signal coming back to the processor
and helps improve overall timing.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Defer clearing of tags & valids to improve timing
Benjamin Herrenschmidt [Wed, 10 Jun 2020 08:00:12 +0000 (18:00 +1000)]
litedram: Defer clearing of tags & valids to improve timing

Currently, there's a huge mux gathering the output of all the PLRUs
to select the victim way on cache miss. This is fed combinationally
into the clearing of the valid and tags.

In order to help timing, let's store it instead and perform the
clearing on the next cycle. The L2 doesn't respond to requests
when not in IDLE state so this should have no negative effects.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Improve dram_tb error output
Benjamin Herrenschmidt [Wed, 10 Jun 2020 07:58:27 +0000 (17:58 +1000)]
litedram: Improve dram_tb error output

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #201 from mikey/github-actions
Anton Blanchard [Fri, 12 Jun 2020 00:25:09 +0000 (10:25 +1000)]
Merge pull request #201 from mikey/github-actions

Move from travis to github workflows

4 years agoMove from travis to github workflow
Michael Neuling [Tue, 9 Jun 2020 23:57:15 +0000 (09:57 +1000)]
Move from travis to github workflow

Github workflow gives us longer run times and faster startup.

Major kudos for this goes to @eine for the initial version and for
pushing us in this direction.

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoMerge pull request #194 from ozbenh/misc
Paul Mackerras [Wed, 10 Jun 2020 09:37:01 +0000 (19:37 +1000)]
Merge pull request #194 from ozbenh/misc

Fix syscon registers usage and add "save" function to mw_debug

4 years agogitignore: Add more exlusions
Benjamin Herrenschmidt [Wed, 10 Jun 2020 03:14:00 +0000 (13:14 +1000)]
gitignore: Add more exlusions

litedram build directory used by the generator and the
verilator obj_dir can be taken out

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Fix DRAM init mem using too many address bits
Benjamin Herrenschmidt [Tue, 9 Jun 2020 22:36:44 +0000 (08:36 +1000)]
litedram: Fix DRAM init mem using too many address bits

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Remove remnants of riscv-inits
Benjamin Herrenschmidt [Fri, 5 Jun 2020 12:28:30 +0000 (22:28 +1000)]
litedram: Remove remnants of riscv-inits

We still had some wires bringing an extra serial port out of
litedram for the built-in riscv processor. This is all gone now
so take them out.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agomw_debug: Add "save" function to save memory to a file
Benjamin Herrenschmidt [Thu, 4 Jun 2020 10:25:57 +0000 (20:25 +1000)]
mw_debug: Add "save" function to save memory to a file

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agosw: Properly mask syscon register fields
Benjamin Herrenschmidt [Thu, 4 Jun 2020 01:56:47 +0000 (11:56 +1000)]
sw: Properly mask syscon register fields

Some fields might get extended with extra bits, use the appropriate
masks when reading the values.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #196 from ozbenh/makefile-lib-fix
Michael Neuling [Tue, 9 Jun 2020 23:54:35 +0000 (09:54 +1000)]
Merge pull request #196 from ozbenh/makefile-lib-fix

Makefile: Improve unisim library generation

4 years agoMerge pull request #195 from shenki/nexys-video
Michael Neuling [Tue, 9 Jun 2020 23:22:50 +0000 (09:22 +1000)]
Merge pull request #195 from shenki/nexys-video

Nexys video

4 years agoMakefile: Improve unisim library generation
Benjamin Herrenschmidt [Tue, 9 Jun 2020 22:31:49 +0000 (08:31 +1000)]
Makefile: Improve unisim library generation

The rewrite of the Makefile to use "ghdl -c" somewhat broke building
the unisim library as ghdl doesn't yet support putting files in
separate libraries from a single command line invocation.

The workaround at the time was to put the entire project in "unisim"
which is ... weird and will break if we try to add another library
such as fmf.

This fixes it by generating the library separately using "ghdl -i"

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoflash-arty: Re-add support for running from any path
Joel Stanley [Tue, 9 Jun 2020 01:52:57 +0000 (11:22 +0930)]
flash-arty: Re-add support for running from any path

The changes in d3c274d01ec1 ("flash-arty: Add support for specifying the file type")
added a local jtagspi.cfg, which meant openocd must be run from the root
of the microwatt directory.

This puts the content into the xilinx-xc7.cfg so the script can be used
from any path again.

Signed-off-by: Joel Stanley <joel@jms.id.au>
4 years agoflash-arty: Support Nexys Video's a200
Joel Stanley [Tue, 9 Jun 2020 00:42:42 +0000 (10:12 +0930)]
flash-arty: Support Nexys Video's a200

Not an Arty but Anton tests on this board.

Signed-off-by: Joel Stanley <joel@jms.id.au>
4 years agoMerge pull request #193 from paulusmack/master
Michael Neuling [Fri, 5 Jun 2020 10:17:01 +0000 (20:17 +1000)]
Merge pull request #193 from paulusmack/master

Minor improvements and reformatting

4 years agoMerge pull request #182 from mikey/travis
Paul Mackerras [Fri, 5 Jun 2020 08:02:33 +0000 (18:02 +1000)]
Merge pull request #182 from mikey/travis

Travis and testing improvements

4 years agoicache: Fix icbi potentially clobbering the icache (#192)
Benjamin Herrenschmidt [Fri, 5 Jun 2020 06:23:23 +0000 (16:23 +1000)]
icache: Fix icbi potentially clobbering the icache (#192)

icbi currently just resets the icache. This has some nasty side
effects such as also clearing the TLB, but also the wishbone interface.

That means that any ongoing cycle will be dropped.

However, most of our slaves don't handle that well and will continue
sending acks for already issued requests.

Under some circumstances we can thus restart an icache load and get
spurious ack/data from the wishbone left over from the "cancelled"
sequence.

This has broken booting Linux for me.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agodecode2: Reformat to 4-space indentation
Paul Mackerras [Fri, 5 Jun 2020 01:16:56 +0000 (11:16 +1000)]
decode2: Reformat to 4-space indentation

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode1: Reformat to 4-space indentation
Paul Mackerras [Fri, 5 Jun 2020 01:16:07 +0000 (11:16 +1000)]
decode1: Reformat to 4-space indentation

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode1: Make ld/std and lwa not be single-issue
Paul Mackerras [Mon, 1 Jun 2020 06:42:05 +0000 (16:42 +1000)]
decode1: Make ld/std and lwa not be single-issue

These were missed earlier when the single-issue flag was turned off on
the other loads and stores by commit 1a244d34707a ("Remove single-issue
constraint for most loads and stores").

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoImprove Travis to run as a matrix job
Michael Neuling [Sat, 23 May 2020 07:00:24 +0000 (17:00 +1000)]
Improve Travis to run as a matrix job

Can now run all 999 random tests and unit tests in Travis.

Kudos for this goes to @eine. Based on his input from here:
  https://github.com/antonblanchard/microwatt/pull/182#issuecomment-637926957

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoAdd unit tests to check and check_light
Michael Neuling [Sun, 24 May 2020 02:09:11 +0000 (12:09 +1000)]
Add unit tests to check and check_light

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoAdd unit tests make target
Michael Neuling [Sun, 24 May 2020 02:08:47 +0000 (12:08 +1000)]
Add unit tests make target

We don't run these but we should.

The SOC tests have bit rotted. We need to fix them but leave them out
for now.

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoAdd tests_console make target
Michael Neuling [Sat, 23 May 2020 06:59:51 +0000 (16:59 +1000)]
Add tests_console make target

Will use when splitting out Travis tests later

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoMerge pull request #191 from ozbenh/litedram
Paul Mackerras [Fri, 5 Jun 2020 03:16:56 +0000 (13:16 +1000)]
Merge pull request #191 from ozbenh/litedram

Litedram updates with L2 cache and sim support

4 years agolitedram: Make the L2 twice as tall
Benjamin Herrenschmidt [Fri, 5 Jun 2020 01:45:00 +0000 (11:45 +1000)]
litedram: Make the L2 twice as tall

This increases the number of L2 lines from 32 to 64. The BRAM usage is the
same as they were only half used. There's an increase in LUTs and registers
due to the extra tags and valid bits, but none of it should be in a
space constrained or critical timing path.

We could make it wider instead (256 bytes lines) which would reduce usage
instead, but this increases the latency by 8 cycles. Something to consider
once the L2 is capable of early response on miss and starting reloads
from any point in a line.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agocore: Do addpcis using the main adder (#189)
Paul Mackerras [Fri, 5 Jun 2020 01:29:31 +0000 (11:29 +1000)]
core: Do addpcis using the main adder (#189)

By adding logic to decode2 to be able to send the instruction address
down the A input, and making CONST_DX_HI (renamed to CONST_DXHI4) add
4 to the immediate value (easy since the bottom 16 bits were zero),
we can do addpcis using the main adder.  This reduces the width of the
result mux and frees up one value in insn_type_t, since we can now use
OP_ADD for addpcis.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agolitedram: Remove old "VexRiscV" based initializations
Benjamin Herrenschmidt [Fri, 5 Jun 2020 01:15:35 +0000 (11:15 +1000)]
litedram: Remove old "VexRiscV" based initializations

Support for this has bitrotted and would require refactoring of L2 to
be brought back. It's also not really needed anymore now that we ship
pre-generated litedram and that LiteX supports what we do.

So take it out, which simplifies some of the scripts as well. This also
fixes up CSR alignment the sim model.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #183 from shawnanastasio/addpcis
Paul Mackerras [Fri, 5 Jun 2020 00:54:00 +0000 (10:54 +1000)]
Merge pull request #183 from shawnanastasio/addpcis

Add support for the addpcis instruction

4 years agolitedram: Update to latest LiteX/LiteDRAM version
Benjamin Herrenschmidt [Mon, 1 Jun 2020 13:58:47 +0000 (23:58 +1000)]
litedram: Update to latest LiteX/LiteDRAM version

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Test bench
Benjamin Herrenschmidt [Mon, 1 Jun 2020 22:32:17 +0000 (08:32 +1000)]
litedram: Test bench

The test bench test simple access forms for now, it's a starting point
but it already helped find/fix a bug.

Includes a litedram update to be able to operate the sim model without
inits.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Add an L2 cache with store queue
Benjamin Herrenschmidt [Wed, 27 May 2020 01:06:51 +0000 (11:06 +1000)]
litedram: Add an L2 cache with store queue

This adds a cache between the wishbone and litedram with the following
features (at this point, it's still evolving)

  - 128 bytes line width in order to have a reasonable amount of
litedram pipelining on the 128-bit wide data port.

  - Configurable geometry otherwise

  - Stores are acked immediately on wishbone whether hit or miss
(minus a 2 cycles delay if there's a previous load response in the
way) and sent to LiteDRAM via 8 entries (configurable) store queue

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Add support for booting without BRAM
Benjamin Herrenschmidt [Mon, 25 May 2020 10:20:59 +0000 (20:20 +1000)]
litedram: Add support for booting without BRAM

This adds an option to disable the main BRAM and instead copy a
payload stashed along with the init code in the secondary BRAM
into DRAM and boot from there

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agolitedram: Add simulation support
Benjamin Herrenschmidt [Fri, 22 May 2020 08:43:50 +0000 (18:43 +1000)]
litedram: Add simulation support

This adds a simulated litedram model along with the necessary
Makefile gunk to verilate it and wrap it for use by ghdl.

The core_dram_tb test bench is a variant of core_tb with
LiteDRAM simulated. It's not built by default, an explicit

make core_dram_tb

is necessary as to not require verilator to be installed for
the normal build process (also it's slow'ish).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #185 from ozbenh/misc
Paul Mackerras [Thu, 4 Jun 2020 23:29:24 +0000 (09:29 +1000)]
Merge pull request #185 from ozbenh/misc

Small fixes to mw_debug, bin2hex and improve BRAM generation in dcache

4 years agoMerge pull request #188 from ozbenh/openocd-tweaks
Michael Neuling [Thu, 4 Jun 2020 22:38:18 +0000 (08:38 +1000)]
Merge pull request #188 from ozbenh/openocd-tweaks

Openocd tweaks

4 years agoflash-arty: Add support for specifying the file type
Benjamin Herrenschmidt [Thu, 4 Jun 2020 13:29:29 +0000 (23:29 +1000)]
flash-arty: Add support for specifying the file type

By default openocd tries to "guess" the file type and interpret
it accordingly. For example it will detect an ELF file based on
the presence of an ELF header and will try to load the relevant
segments into the flash.

This may not be what we want. For example, I want to load the raw
ELF file into the flash.

Additionally the ELF parser in most distro's OpenOCD version
only supports ELF32 and will error out.

This adds a "-t" argument to flash-arty to allow us to specify the
file format. For example "-t bin" will treat the file as raw binary.

Unfortunately I had to copy and modify jtagspi.cfg from OpenOCD
to achieve this.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoflash-arty: Support hex values for address
Benjamin Herrenschmidt [Thu, 4 Jun 2020 13:13:45 +0000 (23:13 +1000)]
flash-arty: Support hex values for address

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #168 from shenki/flash-arty
Paul Mackerras [Wed, 3 Jun 2020 04:20:02 +0000 (14:20 +1000)]
Merge pull request #168 from shenki/flash-arty

Scripts to write data to the Arty's SPI flash

4 years agodcache: Rework RAM wrapper to synthetize better on Xilinx
Benjamin Herrenschmidt [Mon, 25 May 2020 06:48:47 +0000 (16:48 +1000)]
dcache: Rework RAM wrapper to synthetize better on Xilinx

The global wr_en signal is causing Vivado to generate two TDP (True Dual Port)
block RAMs instead of one SDP (Simple Dual Port) for each cache way. Remove
it and instead apply a AND to the individual byte write enables.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agobin2hex: Make sure to generate little endian files
Benjamin Herrenschmidt [Mon, 1 Jun 2020 08:24:15 +0000 (18:24 +1000)]
bin2hex: Make sure to generate little endian files

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agomw_debug: Fix memory overflow with "sim" backend
Benjamin Herrenschmidt [Thu, 28 May 2020 14:04:46 +0000 (00:04 +1000)]
mw_debug: Fix memory overflow with "sim" backend

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #178 from antonblanchard/intercon
Anton Blanchard [Tue, 2 Jun 2020 01:54:00 +0000 (11:54 +1000)]
Merge pull request #178 from antonblanchard/intercon

Interconnect timing improvements from Ben

4 years agoMerge pull request #184 from antonblanchard/verific
Anton Blanchard [Tue, 2 Jun 2020 00:36:06 +0000 (10:36 +1000)]
Merge pull request #184 from antonblanchard/verific

Delete old verific script

4 years agoDelete bit rotted verific script
Michael Neuling [Tue, 26 May 2020 06:55:20 +0000 (16:55 +1000)]
Delete bit rotted verific script

We can use ghdl-synth and fusesoc now, so verific is a dead path which
has bit rotted.

Signed-off-by: Michael Neuling <mikey@neuling.org>
4 years agoAdd a new misc test suite with addpcis tests
Shawn Anastasio [Tue, 26 May 2020 01:08:59 +0000 (20:08 -0500)]
Add a new misc test suite with addpcis tests

The two tests obtain NIA with bl+mflr+addi and then compare it
against addpcis with the minimum and maximum immediate operand values.

They were also tested on a real POWER9 system (in userspace) for good
measure.

Signed-off-by: Shawn Anastasio <shawn@anastas.io>
4 years agoImplement the addpcis instruction
Shawn Anastasio [Tue, 26 May 2020 01:03:02 +0000 (20:03 -0500)]
Implement the addpcis instruction

This commit adds support for the addpcis instruction from ISA 3.0.

A new input_reg_b_t type, CONST_DX_HI, was added to support the
shifted immediate value used in DX-Form instructions.

Signed-off-by: Shawn Anastasio <shawn@anastas.io>
4 years agolitedram: Split the init memory from the main wrapper
Benjamin Herrenschmidt [Wed, 20 May 2020 11:00:27 +0000 (21:00 +1000)]
litedram: Split the init memory from the main wrapper

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoirq: Simplify xics->core irq input
Benjamin Herrenschmidt [Sun, 17 May 2020 05:04:23 +0000 (15:04 +1000)]
irq: Simplify xics->core irq input

Use a simple wire. common.vhdl types are better kept for things
local to the core. We can add more wires later if we need to for
HV irqs etc...

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agosoc: Rework interconnect
Benjamin Herrenschmidt [Mon, 11 May 2020 11:22:07 +0000 (21:22 +1000)]
soc: Rework interconnect

This changes the SoC interconnect such that the main 64-bit wishbone out
of the processor is first split between only 3 slaves (BRAM, DRAM and a
general "IO" bus) instead of all the slaves in the SoC.

The IO bus leg is then latched and down-converted to 32 bits data width,
before going through a second address decoder for the various IO devices.

This significantly reduces routing and timing pressure on the main bus,
allowing to get rid of frequent timing violations when synthetizing on
small'ish FPGAs such as the Artix-7 35T found on the original Arty board.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agosw: Add full memory map to .h and use it for litedram .lds
Benjamin Herrenschmidt [Fri, 15 May 2020 07:43:51 +0000 (17:43 +1000)]
sw: Add full memory map to .h and use it for litedram .lds

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #181 from antonblanchard/Makefile-rework-2
Anton Blanchard [Sat, 23 May 2020 06:50:12 +0000 (16:50 +1000)]
Merge pull request #181 from antonblanchard/Makefile-rework-2

Pass clock frequency to UART sim wrapper

4 years agoPass clock frequency to UART sim wrapper
Anton Blanchard [Sat, 23 May 2020 03:46:43 +0000 (13:46 +1000)]
Pass clock frequency to UART sim wrapper

The UART sim wrapper is currently hard wired to 50 MHz.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #180 from antonblanchard/Makefile-rework
Anton Blanchard [Thu, 21 May 2020 02:29:55 +0000 (12:29 +1000)]
Merge pull request #180 from antonblanchard/Makefile-rework

Makefile rework

4 years agoA little less shouting in the Makefile
Anton Blanchard [Wed, 20 May 2020 06:27:06 +0000 (16:27 +1000)]
A little less shouting in the Makefile

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoFix the simulated DMI
Anton Blanchard [Wed, 20 May 2020 06:18:58 +0000 (16:18 +1000)]
Fix the simulated DMI

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoExit cleanly from testbench on success
Anton Blanchard [Wed, 20 May 2020 06:07:13 +0000 (16:07 +1000)]
Exit cleanly from testbench on success

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge Makefile and Makefile.synth
Anton Blanchard [Wed, 20 May 2020 05:37:49 +0000 (15:37 +1000)]
Merge Makefile and Makefile.synth

We still need to a way to our FPGA target on the command line, but this
at least gets us down to a common Makefile.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoAdd Makefile command line variables to enable docker and podman
Anton Blanchard [Wed, 20 May 2020 05:01:42 +0000 (15:01 +1000)]
Add Makefile command line variables to enable docker and podman

Instead of having to edit the Makefile, we can now do:

make DOCKER=1
make PODMAN=1

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoRework Makefile
Anton Blanchard [Wed, 20 May 2020 04:29:50 +0000 (14:29 +1000)]
Rework Makefile

Instead of building each file one by one (and having to track all
the dependencies manually), use the ghdl -c command that does
analysis and elaboration in one go.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #179 from antonblanchard/yosys-verilator
Anton Blanchard [Tue, 19 May 2020 05:53:54 +0000 (15:53 +1000)]
Merge pull request #179 from antonblanchard/yosys-verilator

Add yosys/verilator support

4 years agoImprove make clean
Anton Blanchard [Tue, 19 May 2020 05:32:04 +0000 (15:32 +1000)]
Improve make clean

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoAdd yosys/verilator support
Anton Blanchard [Tue, 19 May 2020 05:18:42 +0000 (15:18 +1000)]
Add yosys/verilator support

Add a microwatt-verilator target that simulates the
ghdl -> yosys -> verilog -> verilator path. A good test of
ghdl/yosys synthesis.

Because the everything is run through synthesis, the instruction
image is baked into the build via the RAM_INIT_FILE generic.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #171 from shenki/mw-debug-features
Anton Blanchard [Tue, 19 May 2020 04:27:42 +0000 (14:27 +1000)]
Merge pull request #171 from shenki/mw-debug-features

mw debug features

4 years agoMerge pull request #173 from Jbalkind/core-vcs-syntax
Anton Blanchard [Tue, 19 May 2020 04:04:19 +0000 (14:04 +1000)]
Merge pull request #173 from Jbalkind/core-vcs-syntax

Changing use of others in core files to satisfy VCS

4 years agomw_debug: Add README
Joel Stanley [Mon, 11 May 2020 04:22:41 +0000 (13:52 +0930)]
mw_debug: Add README

This describes how to build the tool on Fedora, and on Debian which lacks a packaged
liburjtag as of mid 2020.

Signed-off-by: Joel Stanley <joel@jms.id.au>
4 years agomw_debug: Add usage text
Joel Stanley [Sun, 10 May 2020 04:00:26 +0000 (13:30 +0930)]
mw_debug: Add usage text

Signed-off-by: Joel Stanley <joel@jms.id.au>
4 years agomw_debug: Add CFLAGS and fix warnings
Joel Stanley [Mon, 11 May 2020 03:52:00 +0000 (13:22 +0930)]
mw_debug: Add CFLAGS and fix warnings

CFLAGS was defined but not used anywhere. This adds them to the compile
line, and fixes the warnings (and errors!) that result.

Signed-off-by: Joel Stanley <joel@jms.id.au>
4 years agoMerge pull request #177 from antonblanchard/litedram
Anton Blanchard [Tue, 19 May 2020 03:32:33 +0000 (13:32 +1000)]
Merge pull request #177 from antonblanchard/litedram

LiteDRAM fixes from Ben

4 years agoMerge branch 'master' into litedram
Anton Blanchard [Tue, 19 May 2020 02:28:02 +0000 (12:28 +1000)]
Merge branch 'master' into litedram

4 years agoMerge pull request #176 from antonblanchard/console-improv
Anton Blanchard [Tue, 19 May 2020 01:53:34 +0000 (11:53 +1000)]
Merge pull request #176 from antonblanchard/console-improv

Console improvements from Ben

4 years agoMerge pull request #175 from antonblanchard/yosys-fixes-2
Anton Blanchard [Tue, 19 May 2020 01:38:16 +0000 (11:38 +1000)]
Merge pull request #175 from antonblanchard/yosys-fixes-2

Fix yosys build after MMU merge

4 years agoChanges for compilation with VCS:
Jonathan Balkind [Thu, 14 May 2020 21:17:15 +0000 (17:17 -0400)]
Changes for compilation with VCS:
- Changing use of others in core files to satisfy VCS
- Adding workaround for VCS subtype constraint inconsistencies in common.vhdl

Signed-off-by: Jonathan Balkind <jbalkind@princeton.edu>
4 years agoFix yosys build after MMU merge
Anton Blanchard [Tue, 19 May 2020 01:22:29 +0000 (11:22 +1000)]
Fix yosys build after MMU merge

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #174 from antonblanchard/yosys-fixes
Anton Blanchard [Tue, 19 May 2020 00:44:04 +0000 (10:44 +1000)]
Merge pull request #174 from antonblanchard/yosys-fixes

Some yosys fixes

4 years agoSome yosys fixes
Anton Blanchard [Mon, 18 May 2020 00:15:03 +0000 (10:15 +1000)]
Some yosys fixes

This gets the yosys build further along, but I'm now chasing what looks
like a yosys bug.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>