microwatt.git
9 months agoForgot to remove dissasembly file. verilator_trace
Andrey Miroshnikov [Thu, 3 Aug 2023 19:55:35 +0000 (19:55 +0000)]
Forgot to remove dissasembly file.

9 months agoAdding hello world svp64 example, not working yet.
Andrey Miroshnikov [Thu, 3 Aug 2023 19:45:40 +0000 (19:45 +0000)]
Adding hello world svp64 example, not working yet.

12 months agosdram_init/Makefile: Specified gcc8
Andrey Miroshnikov [Wed, 10 May 2023 11:56:45 +0000 (11:56 +0000)]
sdram_init/Makefile: Specified gcc8

12 months agomicrowatt-verilator.cpp: Added verilator runtime help
Andrey Miroshnikov [Mon, 8 May 2023 19:51:45 +0000 (19:51 +0000)]
microwatt-verilator.cpp: Added verilator runtime help

12 months agomicrowatt-verilator.cpp: Fixed indent
Andrey Miroshnikov [Mon, 8 May 2023 19:29:01 +0000 (19:29 +0000)]
microwatt-verilator.cpp: Fixed indent

12 months agomicrowatt-verilator.cpp: Forgot to add help str for trace dump flag
Andrey Miroshnikov [Mon, 8 May 2023 19:17:47 +0000 (19:17 +0000)]
microwatt-verilator.cpp: Forgot to add help str for trace dump flag

12 months agomicrowatt-verilator.cpp: Added -h and -d flags.
Andrey Miroshnikov [Mon, 8 May 2023 18:57:07 +0000 (18:57 +0000)]
microwatt-verilator.cpp: Added -h and -d flags.

Help string is crude, but at least shows all options.
Dump flag for enabling trace dumping. TRIGGER_ENABLE define was preventing dumping.
Trace dumps generate large VCD files, so may be worth using fst instead.

12 months agohello_world/Makefile: Add base address define. Add compiler define as gcc-8.
Andrey Miroshnikov [Tue, 2 May 2023 16:53:21 +0000 (16:53 +0000)]
hello_world/Makefile: Add base address define. Add compiler define as gcc-8.
hello_world/powerpc.lds.S: Assembler for setting address offset in linker script
hello_world.elf|bin|hex: Removed as these compiled by the user.
Makefile: Set RESET_ADDRESS to 0. Add verilator thread count define (default 1)

2 years agoadd block_ram tags as experiment to icache
Luke Kenneth Casson Leighton [Sun, 24 Apr 2022 14:57:47 +0000 (15:57 +0100)]
add block_ram tags as experiment to icache

2 years agoadd RESET_ADDRESS parameter into Makefile,
Luke Kenneth Casson Leighton [Sun, 24 Apr 2022 14:57:11 +0000 (15:57 +0100)]
add RESET_ADDRESS parameter into Makefile,
bring it into top-generic.vhdl, but shifted by 16 because VHDL refuses
to allow 32-bit integers (only 31-bit, sigh)

2 years agolink unused signals to undefined
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 15:49:37 +0000 (15:49 +0000)]
link unused signals to undefined
to stop them appearing in LPF constraints

2 years agoadd fpga/top-ulx3s.vhdl which sets dummy values for verilator signals
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 14:27:52 +0000 (14:27 +0000)]
add fpga/top-ulx3s.vhdl which sets dummy values for verilator signals
this stops a whole batch of unnecessary debug signals going into
the nextpnr-ecp5 LPF constraints

2 years agoadd external_core_top.v to build for ulx3s
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 13:50:34 +0000 (13:50 +0000)]
add external_core_top.v to build for ulx3s

2 years agofix missing uart_top (ordering of read_verilog is now important)
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 13:45:22 +0000 (13:45 +0000)]
fix missing uart_top (ordering of read_verilog is now important)

2 years agoadd PLL reset stability time option (defaults to 18 bits)
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 13:40:40 +0000 (13:40 +0000)]
add PLL reset stability time option (defaults to 18 bits)
to fpga/top-generic.vhdl

2 years agoULX3S is an LFE5U-85F ECP5 not a LFE5UMG-85F
Luke Kenneth Casson Leighton [Sun, 27 Feb 2022 13:37:52 +0000 (13:37 +0000)]
ULX3S is an LFE5U-85F ECP5 not a LFE5UMG-85F

2 years agowhoops wrong constraints file
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 13:22:12 +0000 (13:22 +0000)]
whoops wrong constraints file

2 years agore-enable hello_world for ulx3s
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 13:11:46 +0000 (13:11 +0000)]
re-enable hello_world for ulx3s

2 years agodrop clock frequency for ulx3s to 25 mhz
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 12:53:13 +0000 (12:53 +0000)]
drop clock frequency for ulx3s to 25 mhz

2 years agofound chiselwatt ulx3s constraint file
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 12:51:54 +0000 (12:51 +0000)]
found chiselwatt ulx3s constraint file
https://github.com/antonblanchard/chiselwatt/blob/master/constraints/ecp5-ulx3s.lpf

2 years agoadd ULX3S Makefile target
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 12:40:20 +0000 (12:40 +0000)]
add ULX3S Makefile target

2 years agoadd ulx3s openocd config for ft232
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 12:40:07 +0000 (12:40 +0000)]
add ulx3s openocd config for ft232

2 years agoadd first cut of ulx3s constraint file
Luke Kenneth Casson Leighton [Fri, 11 Feb 2022 12:28:28 +0000 (12:28 +0000)]
add first cut of ulx3s constraint file

2 years agoadd EXTRA_CFLAGS to CFLAGS
Luke Kenneth Casson Leighton [Wed, 26 Jan 2022 19:20:17 +0000 (19:20 +0000)]
add EXTRA_CFLAGS to CFLAGS

2 years agowhoops, test of variables.mak was the wrong way round
Luke Kenneth Casson Leighton [Wed, 26 Jan 2022 18:42:00 +0000 (18:42 +0000)]
whoops, test of variables.mak was the wrong way round

2 years agowhoops when TRIGGER_OCCURRENCES is enabled trace must not be on by default
Luke Kenneth Casson Leighton [Sun, 23 Jan 2022 14:02:04 +0000 (14:02 +0000)]
whoops when TRIGGER_OCCURRENCES is enabled trace must not be on by default

2 years agowhen TRIGGER_COUNTDOWN not enabled, make it on all the time
Luke Kenneth Casson Leighton [Sun, 23 Jan 2022 13:52:49 +0000 (13:52 +0000)]
when TRIGGER_COUNTDOWN not enabled, make it on all the time

2 years agosave interval too short, also normalise it
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 21:01:02 +0000 (21:01 +0000)]
save interval too short, also normalise it

2 years agocrank up the snapshot window to reasonable (500,000 cycles)
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 15:20:04 +0000 (15:20 +0000)]
crank up the snapshot window to reasonable (500,000 cycles)
so that disks do not fill up with 256 mbyte memory-snapshots

2 years agogrr, save/restore in verilator, use class member os.read/write
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 15:15:52 +0000 (15:15 +0000)]
grr, save/restore in verilator, use class member os.read/write
not daft "<<" or ">>" operator-overload

2 years agoadd uart save/restore state to microwatt-verilator
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 15:01:11 +0000 (15:01 +0000)]
add uart save/restore state to microwatt-verilator

2 years agomove all of uart state to a struct, preparing for save/restore
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 14:52:25 +0000 (14:52 +0000)]
move all of uart state to a struct, preparing for save/restore

2 years agoadd save/restore snapshot, seems to work except for UART, sigh,
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 14:51:58 +0000 (14:51 +0000)]
add save/restore snapshot, seems to work except for UART, sigh,
which does actually need adding to save/restore

2 years agoadd snapshot-saving currently every 1000 cycles for test purposes
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 13:38:50 +0000 (13:38 +0000)]
add snapshot-saving currently every 1000 cycles for test purposes

2 years agocode-comments on uart in microwatt_verilator
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 13:28:48 +0000 (13:28 +0000)]
code-comments on uart in microwatt_verilator

2 years agoadd save/restore and memdump function to microwatt-verilator,
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 13:25:28 +0000 (13:25 +0000)]
add save/restore and memdump function to microwatt-verilator,
for save/restore of simulation state

2 years agogoing to be adding verilator save/restore state
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 13:06:31 +0000 (13:06 +0000)]
going to be adding verilator save/restore state
however the simulated-uart will be in some unknown state at the time,
on restore.  as a "cheat", only save when the tx and rx state machines
are both in IDLE

2 years agoadd trigger occurrences option in microwatt-verilator. useful for tracing
Luke Kenneth Casson Leighton [Fri, 21 Jan 2022 13:03:41 +0000 (13:03 +0000)]
add trigger occurrences option in microwatt-verilator. useful for tracing
loops or just when something goes wrong only on the 3rd, 4th or Nth call

2 years agoadd trace-activation for a #defined number of cycles
Luke Kenneth Casson Leighton [Tue, 11 Jan 2022 07:43:07 +0000 (07:43 +0000)]
add trace-activation for a #defined number of cycles

2 years agoadd means to trigger vcd trace from inside microwatt-verilator
Luke Kenneth Casson Leighton [Mon, 10 Jan 2022 13:29:19 +0000 (13:29 +0000)]
add means to trigger vcd trace from inside microwatt-verilator
under #defined program control. TODO: command-line enable

2 years agoadd verilator snoop of LDST request address
Luke Kenneth Casson Leighton [Sun, 9 Jan 2022 21:19:39 +0000 (21:19 +0000)]
add verilator snoop of LDST request address
(to capture requests which go through the MMU. current dump only outputs
physical address: this is the virtual address)

2 years agoadd MSR to verilator output debug reporting
Luke Kenneth Casson Leighton [Fri, 7 Jan 2022 00:41:46 +0000 (00:41 +0000)]
add MSR to verilator output debug reporting

2 years agoadd reporting of PC and instruction being executed to verilator
Luke Kenneth Casson Leighton [Wed, 5 Jan 2022 16:39:02 +0000 (16:39 +0000)]
add reporting of PC and instruction being executed to verilator

2 years agoadd extra suppression of verilator warnings
Luke Kenneth Casson Leighton [Wed, 5 Jan 2022 15:16:30 +0000 (15:16 +0000)]
add extra suppression of verilator warnings

2 years agoremove next-read debug printouts
Luke Kenneth Casson Leighton [Wed, 5 Jan 2022 15:16:04 +0000 (15:16 +0000)]
remove next-read debug printouts

2 years agoadd means to run an external core from a verilog file.
Luke Kenneth Casson Leighton [Mon, 3 Jan 2022 22:21:19 +0000 (22:21 +0000)]
add means to run an external core from a verilog file.
basically turns soc.vhdl (etc) into a mini general-purpose fabric
interconnect (oh and allows Libre-SOC to use it)

2 years agomove linux kernel (dtbImage-microwatt) loading to 0x600000
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 23:29:00 +0000 (23:29 +0000)]
move linux kernel (dtbImage-microwatt) loading to 0x600000
and it now works.  takes about 2 hours to get to the login prompt,
but it works.

2 years agoadd SIM_BRAM_CHAINBOOT parameter to SYSCON
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 16:15:27 +0000 (16:15 +0000)]
add SIM_BRAM_CHAINBOOT parameter to SYSCON
this allows the mini-BIOS to jump to a specific address rather than
always jump to 0x0

2 years agoadd startup debug print indicating file loaded, size and offset
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 16:13:13 +0000 (16:13 +0000)]
add startup debug print indicating file loaded, size and offset

2 years agoadd extra debug print of BRAM BOOT address
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 15:56:26 +0000 (15:56 +0000)]
add extra debug print of BRAM BOOT address

2 years agorrright. ok. these modifications to sdram_init allow it
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 15:34:38 +0000 (15:34 +0000)]
rrright.  ok.  these modifications to sdram_init allow it
to be compiled and used stand-alone.  sdram initialisation is disabled.
the general idea here is to make this a useful mini-BIOS bootloader,
focussing initially on verilator start-up.  to that end, the first
addition is a SYS_REG_BRAM_BOOTADDR addition to syscon which is the
location where the chain-loading continues (if SPI and SDRAM are not
available, where SDRAM is definitely out at this point)

2 years agoadd ability to load multiple files in microwatt-verilator.cpp
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 14:44:32 +0000 (14:44 +0000)]
add ability to load multiple files in microwatt-verilator.cpp
(currently only 2 supported, one at a hard-coded address of 0x500000)

2 years agoadd ability to override the default RESET address (commented-out)
Luke Kenneth Casson Leighton [Sun, 2 Jan 2022 14:24:48 +0000 (14:24 +0000)]
add ability to override the default RESET address (commented-out)
also add extra settings to generic top-level to add UART1 if required

2 years agomove verilator tick() to correct location, and increase memory size
Luke Kenneth Casson Leighton [Sat, 1 Jan 2022 17:03:31 +0000 (17:03 +0000)]
move verilator tick() to correct location, and increase memory size

2 years agocopy mmapd file into large buffer to allow read/write past end
Luke Kenneth Casson Leighton [Sat, 1 Jan 2022 03:16:07 +0000 (03:16 +0000)]
copy mmapd file into large buffer to allow read/write past end

2 years agogotten over the logic-dyslexia of what in/out mean in VHDL.
Luke Kenneth Casson Leighton [Sat, 1 Jan 2022 02:46:54 +0000 (02:46 +0000)]
gotten over the logic-dyslexia of what in/out mean in VHDL.
BRAM can now be read/written using the contents of a file to initialise
from, at the command-line

2 years agoadd microwatt-verilator.cpp local-memory-writer which seems to work
Luke Kenneth Casson Leighton [Fri, 31 Dec 2021 21:22:33 +0000 (21:22 +0000)]
add microwatt-verilator.cpp local-memory-writer which seems to work
discrepancies which used to show up after bram reads are no longer there

2 years agoadd loading (mmap private) of bram file in microwatt-verilator.cpp
Luke Kenneth Casson Leighton [Fri, 31 Dec 2021 21:12:39 +0000 (21:12 +0000)]
add loading (mmap private) of bram file in microwatt-verilator.cpp
performs a comparison against what was loaded into the actual VHDL,
so that replacing it with runtime stands a chance of being correct

2 years agoadd ASCII dump of BRAM read/write data and add one-cycle delay on read
Luke Kenneth Casson Leighton [Thu, 30 Dec 2021 22:04:06 +0000 (22:04 +0000)]
add ASCII dump of BRAM read/write data and add one-cycle delay on read
the BRAM outputs its data one cycle late from the read-enable (bram_re)

2 years agobring bram signals out to top_level, initially for debugging purposes
Luke Kenneth Casson Leighton [Thu, 30 Dec 2021 21:25:53 +0000 (21:25 +0000)]
bring bram signals out to top_level, initially for debugging purposes
and ultimately with the purpose of replacing compiled-in verilator hex
dumps with reading/writing a file directly in the main verilator loop

Signed-off-by: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
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 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 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 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>
3 years agoloadstore1/dcache: Send store data one cycle later
Paul Mackerras [Sat, 31 Oct 2020 02:48:58 +0000 (13:48 +1100)]
loadstore1/dcache: Send store data one cycle later

This makes timing easier and also means that store floating-point
single precision instructions no longer need to take an extra cycle.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoloadstore1: Improve timing of data path from cache RAM to writeback
Paul Mackerras [Mon, 28 Sep 2020 04:02:03 +0000 (14:02 +1000)]
loadstore1: Improve timing of data path from cache RAM to writeback

Work out select inputs for writeback mux a cycle earlier.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoloadstore1: Decide on load formatting controls a cycle earlier
Paul Mackerras [Mon, 21 Sep 2020 01:41:46 +0000 (11:41 +1000)]
loadstore1: Decide on load formatting controls a cycle earlier

This helps timing.

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 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 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 agotests: Add tests for lq/stq and lqarx/stqcx.
Paul Mackerras [Mon, 14 Sep 2020 08:21:27 +0000 (18:21 +1000)]
tests: Add tests for lq/stq and lqarx/stqcx.

Lq and stq are tested in both BE and LE modes (though only 64-bit
mode) by the 'modes' test.

Lqarx and stqcx. are tested by the 'reservation' test in LE mode mode
(64-bit).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore: Implement quadword loads and stores
Paul Mackerras [Sat, 12 Sep 2020 10:35:03 +0000 (20:35 +1000)]
core: Implement quadword loads and stores

This implements the lq, stq, lqarx and stqcx. instructions.

These instructions all access two consecutive GPRs; for example the
"lq %r6,0(%r3)" instruction will load the doubleword at the address
in R3 into R7 and the doubleword at address R3 + 8 into R6.  To cope
with having two GPR sources or destinations, the instruction gets
repeated at the decode2 stage, that is, for each lq/stq/lqarx/stqcx.
coming in from decode1, two instructions get sent out to execute1.

For these instructions, the RS or RT register gets modified on one
of the iterations by setting the LSB of the register number.  In LE
mode, the first iteration uses RS|1 or RT|1 and the second iteration
uses RS or RT.  In BE mode, this is done the other way around.  In
order for decode2 to know what endianness is currently in use, we
pass the big_endian flag down from icache through decode1 to decode2.
This is always in sync with what execute1 is using because only rfid
or an interrupt can change MSR[LE], and those operations all cause
a flush and redirect.

There is now an extra column in the decode tables in decode1 to
indicate whether the instruction needs to be repeated.  Decode1 also
enforces the rule that lq with RT = RT and lqarx with RA = RT or
RB = RT are illegal.

Decode2 now passes a 'repeat' flag and a 'second' flag to execute1,
and execute1 passes them on to loadstore1.  The 'repeat' flag is set
for both iterations of a repeated instruction, and 'second' is set
on the second iteration.  Execute1 does not take asynchronous or
trace interrupts on the second iteration of a repeated instruction.

Loadstore1 uses 'next_addr' for the second iteration of a repeated
load/store so that we access the second doubleword of the memory
operand.  Thus loadstore1 accesses the doublewords in increasing
memory order.  For 16-byte loads this means that the first iteration
writes GPR RT|1.  It is possible that RA = RT|1 (this is a legal
but non-preferred form), meaning that if the memory operand was
misaligned, the first iteration would overwrite RA but then the
second iteration might take a page fault, leading to corrupted state.
To avoid that possibility, 16-byte loads in LE mode take an
alignment interrupt if the operand is not 16-byte aligned.  (This
is the case anyway for lqarx, and we enforce it for lq as well.)

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodcache: Add more commentary, no code change
Paul Mackerras [Fri, 30 Oct 2020 11:08:54 +0000 (22:08 +1100)]
dcache: Add more commentary, no code change

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agodecode1: Fix decoding of recommended NOP instruction
Paul Mackerras [Thu, 26 Nov 2020 11:08:47 +0000 (22:08 +1100)]
decode1: Fix decoding of recommended NOP instruction

We were decoding nop with the wrong major opcode.  Fix it.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore_debug: Stop logging 256 cycles after trigger
Paul Mackerras [Tue, 15 Dec 2020 22:34:56 +0000 (09:34 +1100)]
core_debug: Stop logging 256 cycles after trigger

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agocore_debug: Add an address trigger to stop logging at a given address
Paul Mackerras [Thu, 12 Nov 2020 04:06:38 +0000 (15:06 +1100)]
core_debug: Add an address trigger to stop logging at a given address

This compares the address being fetched with the contents of a
register that can be set via DMI, and if they match, stops the
logging.  Since this works on the address being fetched rather than
executed, it is subject to false positives.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoFPU: Don't use mask generator for rounding
Paul Mackerras [Mon, 21 Sep 2020 01:37:10 +0000 (11:37 +1000)]
FPU: Don't use mask generator for rounding

Instead of using the mask generator in the rounding process, this uses
simpler logic to add in a 1 at the appropriate position (bit 2 or bit
31, depending on precision) and mask off the low-order bits.  Since
there are only two positions at which the masking and incrementing
need to be done, we don't need the full generality of the mask
generator.  This reduces the amount of logic and improves timing.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoFPU: Relax timing around multiplier output
Paul Mackerras [Sat, 19 Sep 2020 09:01:49 +0000 (19:01 +1000)]
FPU: Relax timing around multiplier output

At present there is a state transition in the handling of the fmadd
instructions where the next state depends on the sign bit of the
multiplier result.  This creates a critical path which doesn't make
timing on the A7-100.  To fix this, we make the state transition
independent of the sign of the multiplier result, which improves
timing, but means we take one more cycle to do a fmadd-family
instruction in some cases.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agomw_debug: Display terminated status when stopping
Paul Mackerras [Tue, 22 Sep 2020 10:33:08 +0000 (20:33 +1000)]
mw_debug: Display terminated status when stopping

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agomw_debug: Extend to handle FPRs
Paul Mackerras [Tue, 22 Sep 2020 10:22:24 +0000 (20:22 +1000)]
mw_debug: Extend to handle FPRs

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoArty A7: Document pin connections for on-board headers
Paul Mackerras [Wed, 13 Jan 2021 08:51:46 +0000 (19:51 +1100)]
Arty A7: Document pin connections for on-board headers

This adds, as comments, lines which would if uncommented define
properties which associate the pins of the headers on the Arty A7
board with FPGA pins.  It also adds properties for LEDs 1--3, also
commented out for now.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoexecute1: Update comments about XER forwarding
Paul Mackerras [Wed, 13 Jan 2021 08:45:57 +0000 (19:45 +1100)]
execute1: Update comments about XER forwarding

This deletes some commentary that is now out of date and replaces it
with a simple statement about the XER common bits being forwarded from
the output of execute1 to the input.

The comment being deleted talked about a hazard if an instruction that
modifies XER[SO] is immediately followed by a store conditional.  That
is no longer a problem because the operands for loadstore1 are sent
from execute1 (and therefore have the forwarded value) rather than
decode2.  This was in fact fixed in 5422007f83bf ("Plumb loadstore1
input from execute1 not decode2", 2020-01-14).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
3 years agoMerge pull request #263 from antonblanchard/reset-pid
Paul Mackerras [Thu, 7 Jan 2021 03:47:11 +0000 (14:47 +1100)]
Merge pull request #263 from antonblanchard/reset-pid

Initialize PID register

3 years agoMerge pull request #262 from antonblanchard/reset-tb-decr
Paul Mackerras [Thu, 7 Jan 2021 03:46:42 +0000 (14:46 +1100)]
Merge pull request #262 from antonblanchard/reset-tb-decr

Reset TB and DECR

3 years agoMerge pull request #259 from antonblanchard/dmi-reset
Paul Mackerras [Thu, 7 Jan 2021 03:46:04 +0000 (14:46 +1100)]
Merge pull request #259 from antonblanchard/dmi-reset

Reset JTAG/DMI

3 years agoMerge pull request #265 from antonblanchard/another-spi-rxtx-reset-issu
Anton Blanchard [Tue, 5 Jan 2021 09:17:37 +0000 (20:17 +1100)]
Merge pull request #265 from antonblanchard/another-spi-rxtx-reset-issu

Fix another reset issue in spi_rxtx

3 years agoMerge pull request #264 from antonblanchard/reset-spi-txrx
Anton Blanchard [Tue, 5 Jan 2021 09:16:50 +0000 (20:16 +1100)]
Merge pull request #264 from antonblanchard/reset-spi-txrx

Reset cmd_ready_o in spi_txrx