Commit Graph

393 Commits (d87648422965cd94c21af9f972542e396000c790)
 

Author SHA1 Message Date
Anton Blanchard d876484229
Merge pull request #142 from antonblanchard/ghdl-synthesis-3
Initial support for ghdl synthesis
5 years ago
Anton Blanchard 4508182fe1
Merge pull request #144 from antonblanchard/update-README
Add some information about GHDL backend issues
5 years ago
Anton Blanchard d1166e9c26
Merge pull request #143 from antonblanchard/use-docker
Add an option to use Docker
5 years ago
Anton Blanchard 5f2efde644 Add some information about GHDL backend issues
A number of people have tripped up on GHDL backend issues. We
require either the LLVM or gcc backend, because the mcode backend
can't link against libraries which we use for simulated memory
and UART. Make that clearer, and point people at the Docker images
if they are having issues building ghdl.

Also point at the prebuilt micropython image.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard c18830a5e5 Add an option to use Docker
Some distros don't have a version of ghdl with the  LLVM or GCC backend,
so add a Docker image as an alternative.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard db937403ec Initial support for ghdl synthesis
A first pass at ghdl synthesis using yosys and nextpnr. It runs hello world
or micropython if the FPGA has enough block RAM (eg ECP5 85F). The hello
world testcase also loops UART rx to tx in software (ie not a hardware
loopback).

It uses Docker images, so no software needs to be installed. If you prefer
podman you can use that too. Edit Makefile.synth to configure your FPGA,
JTAG device etc.

To build:

make -f Makefile.synth

and to program:

make -f Makefile.synth prog

A few issues:

We need to add PLL support. Right now Microwatt runs at whatever the
external clock frequency is and the baud rate gets scaled by how far off
50MHz it is. This means on the ecp5-evn with a 12 MHz clock rate the baud
rate is a quite strange 27650 (115200 * 50 / 12). On my OrangeCrab with a
50MHz clock the UART is 115200.

It uses a large amount of resources, way more than it should. There are
still some ghdl/yosys issues to be sorted out.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 21a40c2ba6
Merge pull request #140 from antonblanchard/rework-makefile
Fix Makefile dependency issue with files in vhdl/*
5 years ago
Anton Blanchard a4dbbfda4a Fix Makefile dependency issue with files in vhdl/*
GHDL doesn't seem to have a way to specify the location of the object
file it writes, so right now they are all ending up in the root
directory. The Makefile rules did not reflect that, so make would
continually the files in fpga/*

Fix the rules to match what GHDL is doing.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard d1643443d6
Merge pull request #141 from antonblanchard/update-dependencies.py
Improve dependencies.py and add a --synth option
5 years ago
Anton Blanchard d92f3da606 Improve dependencies.py and add a --synth option
dependencies.py was pretty terrible at actually determining
dependencies. This improves it and also adds a --synth option.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard ffca138b78
Merge pull request #136 from antonblanchard/uart-rx-metastability
Add a few FFs on the RX input to avoid metastability issues
5 years ago
Anton Blanchard 61d5e61f09 Add a few FFs on the RX input to avoid metastability issues
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 8569ae0ab1
Merge pull request #139 from antonblanchard/reduce-mem
Reduce mem
5 years ago
Anton Blanchard f5424f8e71 Reduce simulated and default FPGA RAM to 384kB
Micropython has been able to fit into 384kB for ages, so lets reduce our
simulated RAM. This is useful for testing if micropython will run on an
ECP5 85k, which has enough BRAM for 384kB but not enough for 512kB.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 488c30fe91 Add log2ceil and use it in bram code
We might want a non power of 2 amount of RAM in order to fit into an
FPGA, so create log2ceil and use it when calculating the number of
memory bits.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard b3dd31a978
Merge pull request #138 from antonblanchard/micropython-update
Update micropython
5 years ago
Anton Blanchard d0b5050ca4 Update micropython
The current version of micropython in tests/micropython.bin is ancient.
Bug #135 points out that more recent versions are much smaller and they
also handle restart when ctrl+D is pressed.

Save all three versions of the file (elf, bin and hex) in micropython/

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 4d3da0c7e6
Merge pull request #137 from antonblanchard/hello-world
hello_world updates
5 years ago
Anton Blanchard 75f3614776 hello_world updates
Shrink hello_world a bit (from 12kB to 8kB).
Include the built images
Add 0x10 and 0x100 entry points

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 969245e379
Merge pull request #133 from antonblanchard/ghdl-synth
Ghdl synth
5 years ago
Anton Blanchard 729a35967a
Merge pull request #132 from antonblanchard/bin2hex-move
Move bin2hex.py to scripts/
5 years ago
Anton Blanchard 9362f2dd10 Move bin2hex.py to scripts/
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard f1d0382587 Fix a ghdlsynth issue in fast_spr_num
I've submitted a bug report for this, but we can work around it easily
for now.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard dcee60a729 Fix a ghdlsynth issue in icache
ghdlsynth doesn't like the debug statement, so wrap it in a generate.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 3ad3e2abfd Removed unused core_terminated signal
Right now it's unused. We can add it back when we add an LED to signify
the core has terminated.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 14c5cf3b83 Fix some ghdlsynth issues with fpga_bram
Use to_integer() instead of conv_integer().

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard b0212b0bf9 Fix ghdlsynth issue in register file
We need to drive sim_dump_done to keep ghdlsynth happy.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard f37ef56d79 Remove unused signal
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 25968951e4 Fix a ghdysynth inferred latch error in writeback
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard ad3db18dce Fix a ghdysynth inferred latch error in execute
It should never happen in practise, but ghdlsynth is complaining about
an inferred latch here. Fix it

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 0a6fd0adb5
Merge pull request #131 from antonblanchard/new-tests
Dump CTR, LR and CR on sim termination, and update our tests
5 years ago
Anton Blanchard cc8a9e7893 Upper 32 bits of XER should read as 0s
From the architecture:

  bits 0:31 and 35:43 are treated as reserved and return 0s when read
  using mfxer

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 467630573c Dump CTR, LR and CR on sim termination, and update our tests
Right now our test cases fold the SPRs into the GPRs. That makes
debugging fails more difficult than it needs to be, so print
out the CTR, LR and CR.

We still need to print the XER, but that is in two spots in microwatt
and will take some more work.

This also adds many instructions to the tests that we have added
lately including overflow instructions, CR logicals and mt/mfxer.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 115d63eaf3
Merge pull request #127 from tomtor/CR-PR
Implement CRNOR and friends
5 years ago
Anton Blanchard 320fc88d56
Merge pull request #130 from antonblanchard/build-fix
control: Fix build issue with Fedora 31 version of GHDL
5 years ago
Anton Blanchard 72aac38581
Merge pull request #129 from antonblanchard/update-micropython
Point to upstream micropython
5 years ago
Anton Blanchard 1aec1a4b0e Point to upstream micropython
Our changes are now merged upstream, so point there instead.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Tom Vijlbrief c05441bf47 Implement CRNOR and friends
Signed-off-by: Tom Vijlbrief <tvijlbrief@gmail.com>
5 years ago
Anton Blanchard 9a67e3b4fe
Merge pull request #126 from sharkcz/docs
document packaged fusesoc for Fedora users
5 years ago
Dan Horák f552021d19 document packaged fusesoc for Fedora users
Signed-off-by: Dan Horák <dan@danny.cz>
5 years ago
Anton Blanchard 1c05f330c6 control: Fix build issue with Fedora 31 version of GHDL
I'm hitting an issue with the Fedora 31 version of GHDL that
appears to be fixed upstream:

control.vhdl:105:39:error: actual expression must be globally static

Add a signal to get rid of error.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Anton Blanchard 1a826f077b
Merge pull request #122 from paulusmack/benh-sprs
Benh sprs
5 years ago
Anton Blanchard f5ca58b3c4
Merge pull request #123 from antonblanchard/spi-conf
Add SPI configuration to Xilinx constraint files
5 years ago
Anton Blanchard 20674e0d65 Add SPI configuration to Xilinx constraint files
Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years ago
Paul Mackerras 23ade0b1c3 decode2: Minor cleanup
Remove unused variable is_reg in decode_input_reg_a.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years ago
Benjamin Herrenschmidt e4f475e17f sprs: Store common SPRs in register file
This stores the most common SPRs in the register file.

This includes CTR and LR and a not yet final list of others.

The register file is set to 64 entries for now. Specific types
are defined that can represent a GPR index (gpr_index_t) or
a GPR/SPR index (gspr_index_t) along with conversion functions
between the two.

On order to deal with some forms of branch updating both LR and
CTR, we introduced a delayed update of LR after a branch link.

Note: We currently stall the pipeline on such a delayed branch,
but we could avoid stalling fetch in that specific case as we
know we have a branch delay. We could also limit that to the
specific case where we need to update both CTR and LR.

This allows us to make bcreg, mtspr and mfspr pipelined. decode1
will automatically force the single issue flag on mfspr/mtspr to
a "slow" SPR.

[paulus@ozlabs.org - fix direction of decode2.stall_in]

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years ago
Benjamin Herrenschmidt afdd593502 spr: Add translation from SPR to special GPR number
We will want to store some SPRs in the register file using
a set of "extra" registers. This provides a function for
doing the translation along with some SPR definitions.

This isn't used yet

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years ago
Paul Mackerras 5a0458dec1 divider: Fix overflow calculation
We were signalling overflow when neg_result=1 but the result was zero.
Fix this.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years ago
Paul Mackerras d04887fdcd decode1: Add OE=1 forms of add/sub, mul and div instructions
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years ago
Paul Mackerras ec9b27660f execute: Copy XER[SO] to CR for cmp[i] and cmpl[i] instructions
We were copying in XER[SO] for the dot-form instructions but not the
explicit compare instructions.  Fix this.

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