1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-02-17 04:57:11 +00:00
Commit Graph

560 Commits

Author SHA1 Message Date
Anton Blanchard
ab86b58d95 Exit cleanly from testbench on success
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
2020-05-20 16:07:13 +10:00
Anton Blanchard
a9e7194de5 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>
2020-05-20 15:37:49 +10:00
Anton Blanchard
6326efaca4 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>
2020-05-20 15:04:24 +10:00
Anton Blanchard
224e7734a8 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>
2020-05-20 15:03:04 +10:00
Anton Blanchard
b82d07c8d5 Merge pull request #179 from antonblanchard/yosys-verilator
Add yosys/verilator support
2020-05-19 15:53:54 +10:00
Anton Blanchard
8c028f26f1 Improve make clean
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
2020-05-19 15:32:04 +10:00
Anton Blanchard
3e8a6a8fc2 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>
2020-05-19 15:18:42 +10:00
Anton Blanchard
354e0fbfea Merge pull request #171 from shenki/mw-debug-features
mw debug features
2020-05-19 14:27:42 +10:00
Anton Blanchard
6692f0db4f Merge pull request #173 from Jbalkind/core-vcs-syntax
Changing use of others in core files to satisfy VCS
2020-05-19 14:04:19 +10:00
Joel Stanley
5860c2d1b6 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>
2020-05-19 13:27:35 +09:30
Joel Stanley
2bf5bf4bac mw_debug: Add usage text
Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-05-19 13:27:35 +09:30
Joel Stanley
fa90f0dbb1 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>
2020-05-19 13:27:35 +09:30
Anton Blanchard
6d36ef93d9 Merge pull request #177 from antonblanchard/litedram
LiteDRAM fixes from Ben
2020-05-19 13:32:33 +10:00
Anton Blanchard
4e78b8078e Merge branch 'master' into litedram 2020-05-19 12:28:02 +10:00
Anton Blanchard
e9251544f4 Merge pull request #176 from antonblanchard/console-improv
Console improvements from Ben
2020-05-19 11:53:34 +10:00
Anton Blanchard
03369a137c Merge pull request #175 from antonblanchard/yosys-fixes-2
Fix yosys build after MMU merge
2020-05-19 11:38:16 +10:00
Jonathan Balkind
cc532dd065 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>
2020-05-18 21:23:12 -04:00
Anton Blanchard
2aae3bf7a4 Fix yosys build after MMU merge
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
2020-05-19 11:22:29 +10:00
Anton Blanchard
9287e80711 Merge pull request #174 from antonblanchard/yosys-fixes
Some yosys fixes
2020-05-19 10:44:04 +10:00
Anton Blanchard
f96d179f66 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>
2020-05-19 10:23:58 +10:00
Anton Blanchard
7c4dab7eb0 Merge pull request #169 from paulusmack/mmu
Add radix MMU with dTLB and iTLB
2020-05-19 09:34:41 +10:00
Benjamin Herrenschmidt
6efb31c924 litedram: Regenerate
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
acbdd396a5 soc/core: Add reset latches
This adds one-cycle latches to the various resets out of the soc and
into the various core modules. It *seems* to help vivado P&R a bit
and has shown to avoid timing violations under some circumstances.

Interestingly those resets never seem to appear in the bad timing
path. It looks like those long resets simply impose placement
constraints that Vivado satisfies at the expense of timing elsewhere.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
7560e8f2ff arty/nexys: Rework reset with litedram
When using litedram, request a much longer PLL reset. This seems to
help get rid of all the grabled output after config.

Also use the clean system_rst out of litedram as our source of reset
for the rest of the SoC (it is synchronized with system_clk and takes
pll_locked into account already)
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
3b603402d2 soc_reset: Use counters, add synchronizers
In some cases we need to keep the reset held for much longer,
so use counters rather than shift registers.

Additionally, some signals such as ext_rst and pll_locked
or signals going from the ext_clk domain to the pll_clk
domain need to be treated as async, and testing them without
synchronizers is asking for trouble.

Finally, make the external reset also reset the PLL.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
30fd9aa298 litedram: Forward system reset signal
The wrapper wouldn't forward it. Make it do so

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
c0f537b845 litedram: Remove init delays
The clocks / resets are now stable

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Benjamin Herrenschmidt
c19b5b8cc7 litedram: Update to new LiteX/LiteDRAM version
Things have changed a bit in upstream LiteX. LiteDRAM now exposes a
wishbone for the CSRs for example.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-16 12:42:58 +10:00
Paul Mackerras
eca0fb5bf1 dcache: Fix bug in store hit after dcbz case
This fixes a bug where a store that hits in the dcache immediately
following a dcbz has its write to the cache RAM suppressed (but not
its write to memory).  If a load to the same location comes along
before the cache line gets replaced, the load will return incorrect
data.

Fixes: 4db1676ef8 ("dcache: Don't assert on dcbz cache hit")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-15 22:01:02 +10:00
Benjamin Herrenschmidt
13e84b0bbb pp_soc_uart: Fix rx synchronizers and ensure stable tx init state
The rx synchronizers were ... non existent. Someone forgot to add
a if rising_edge(clk) to the process.

For tx, ensure that we have a default value so that TX stays high
from TPGA configuration to the reset being sampled on the first clock
cycle.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:49:09 +10:00
Benjamin Herrenschmidt
bd42580a42 pp_fifo: Fix full fifo losing all data on simultaneous push & pop
The pp_fifo decides whether top = bottom means empty or full based
on whether the previous operation was a push or a pop.

If the fifo performs both in one cycle, it sets the previous op to
pop. That means that a full fifo being added a character and removed
one at the same time becomes empty.

Instead, just leave the previous op alone. If the fifo was empty, it
remains so, if it was full ditto.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:49:09 +10:00
Benjamin Herrenschmidt
803ee9ef35 Makefile: Improve clean a bit
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:49:09 +10:00
Benjamin Herrenschmidt
edbbf9a125 console: Remove putstr()
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:48:58 +10:00
Benjamin Herrenschmidt
7bc118c7db console: Move console files
console.c goes to a new lib/ where we'll store other general utilities
and console.h goes to include/

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:48:58 +10:00
Benjamin Herrenschmidt
a87b86e54f console: Replace putstr with puts
It makes things a bit more standard and a bit nicer to read
without all those strlen(). Also console.c takes care of adding
the carriage returns before the linefeeds.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-15 20:48:47 +10:00
Benjamin Herrenschmidt
88b28a7b17 console: Improve putchar(), add puts()
Make putchar() match a standard prototype and add puts()

Also make puts() add carriage returns before linefeeds so the
users don't have to do it all over the place.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-14 23:12:22 +10:00
Paul Mackerras
941499133e soc: Work around compile error with ghdl 0.37-dev
The ghdl packaged in Fedora 31 doesn't like a port map of the form
"rst => rst or core_reset", so this works around the problem by
doing the OR in a separate statement.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-14 15:43:33 +10:00
Paul Mackerras
c164a2f4ea Merge branch 'mmu'
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-14 15:41:51 +10:00
Anton Blanchard
fcec66acf4 Merge pull request #170 from antonblanchard/litedram
LiteDRAM integration
2020-05-14 15:08:33 +10:00
Benjamin Herrenschmidt
e3013f5754 litedram: Use 32-bit CSR bus
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-09 11:57:23 +10:00
Benjamin Herrenschmidt
7f1f6b8525 litedram: Add support for Microwatt-initialized controller
This adds support for initializing the memory controller from microwatt
rather than using a built-in RiscV processor. This might require some
fixes to LiteX and LiteDRAM (they haven't been merged as of this commit
yet).

This is enabled in the shipped generated files and can be changed via
modifying the generator script to pass False to "mw_init"

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-09 10:57:18 +10:00
Benjamin Herrenschmidt
c5f5f50738 hello_world: Use new headers and frequency from syscon
This uses the new header files for register definitions and
extracts the core frequency from syscon rather than hard coding it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Benjamin Herrenschmidt
12e8b0952d litedram: Improve sdram init boot messages
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Benjamin Herrenschmidt
33de131384 Add microwatt_soc.h and io.h include file
This contains C definitions for various Microwatt internal MMIOs
and a set of accessors.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Benjamin Herrenschmidt
025cf5efe8 syscon: Add syscon registers
These provides some info about the SoC (though it's still somewhat
incomplete and needs more work, see comments).

There's also a control register for selecting DRAM vs. BRAM at 0
(and for soft-resetting the SoC but that isn't wired up yet).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Benjamin Herrenschmidt
2cef3005cd fpga: Hookup nexys-video to litedram
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Benjamin Herrenschmidt
3ac815823c fpga: Hookup Arty to litedram
The old toplevel.vhdl becomes top-generic.vhdl, which is to be used
by platforms that do not have a litedram option.

Arty has its own top-arty.vhdl which supports litedram and is now
hooked up

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2020-05-08 21:06:16 +10:00
Paul Mackerras
2843c99a71 MMU: Implement reading of the process table
This adds the PID register and repurposes SPR 720 as the PRTBL
register, which points to the base of the process table.  There
doesn't seem to be any point to implementing the partition table given
that we don't have hypervisor mode.

The MMU caches entry 0 of the process table internally (in pgtbl3)
plus the entry indexed by the value in the PID register (pgtbl0).
Both caches are invalidated by a tlbie[l] with RIC=2 or by a move to
PRTBL.  The pgtbl0 cache is invalidated by a move to PID.  The dTLB
and iTLB are cleared by a move to either PRTBL or PID.

Which of the two page table root pointers is used (pgtbl0 or pgtbl3)
depends on the MSB of the address being translated.  Since the segment
checking ensures that address(63) = address(62), this is sufficient to
map quadrants 0 and 3.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-08 12:12:02 +10:00
Paul Mackerras
f3c6119cf6 tests/mmu: Add a test of PTE refetching on permission error
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-08 12:12:02 +10:00
Paul Mackerras
8ff8b2f256 tests/mmu: Add a test for dcbz with translation on
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-05-08 12:12:02 +10:00