microwatt.git
5 years agoMerge pull request #120 from antonblanchard/spr-decode-cleanup
Anton Blanchard [Mon, 18 Nov 2019 03:07:16 +0000 (14:07 +1100)]
Merge pull request #120 from antonblanchard/spr-decode-cleanup

spr: Cleanup decoding of SPR numbers

5 years agoMerge pull request #119 from antonblanchard/reduce-pipe-depth
Anton Blanchard [Mon, 18 Nov 2019 03:05:48 +0000 (14:05 +1100)]
Merge pull request #119 from antonblanchard/reduce-pipe-depth

control: Reduce pipeline depth to 1

5 years agoMerge pull request #118 from antonblanchard/bus-pipeline
Anton Blanchard [Fri, 15 Nov 2019 05:02:57 +0000 (16:02 +1100)]
Merge pull request #118 from antonblanchard/bus-pipeline

Bus pipeline

5 years agocontrol: Reduce pipeline depth to 1
Benjamin Herrenschmidt [Thu, 31 Oct 2019 08:43:58 +0000 (19:43 +1100)]
control: Reduce pipeline depth to 1

To match our one stage execute.

This might change back if we end up adding 2 stages to match the
LSU, but in that case we'll want forwards as well.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agospr: Cleanup decoding of SPR numbers
Benjamin Herrenschmidt [Thu, 31 Oct 2019 00:42:10 +0000 (11:42 +1100)]
spr: Cleanup decoding of SPR numbers

Use a function to obtain the integer number and use constants
with the architected numbers. Replace std_match with a case
statement.

This also has the side effect of returning 0 instead of some
random previous result on mfspr of an unknown SPR.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowb_arbiter: Early master selection
Benjamin Herrenschmidt [Wed, 23 Oct 2019 04:06:39 +0000 (15:06 +1100)]
wb_arbiter: Early master selection

This flips the arbiter muxes on the same cycle as a new request
comes in, thus avoiding a cycle latency.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowb_arbiter: Make arbiter size parametric
Benjamin Herrenschmidt [Wed, 23 Oct 2019 03:28:12 +0000 (14:28 +1100)]
wb_arbiter: Make arbiter size parametric

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowb_arbiter: Avoid IDLE cycle when not changing master
Benjamin Herrenschmidt [Wed, 23 Oct 2019 03:01:48 +0000 (14:01 +1100)]
wb_arbiter: Avoid IDLE cycle when not changing master

Consecutive accesses from the same master shouldn't need an IDLE
cycle. Completely remove the IDLE state and switch master when
the bus is idle, but stay on the last selected one between cycles.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoram: Ack stores early
Benjamin Herrenschmidt [Wed, 23 Oct 2019 03:00:30 +0000 (14:00 +1100)]
ram: Ack stores early

Stores only need a single cycle, so we can ack them early if there
isn't an older ack already in the pipeline

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoram: Rework main RAM interface
Benjamin Herrenschmidt [Wed, 23 Oct 2019 01:08:55 +0000 (12:08 +1100)]
ram: Rework main RAM interface

This replaces the simple_ram_behavioural and mw_soc_memory modules
with a common wishbone_bram_wrapper.vhdl that interfaces the
pipelined WB with a lower-level RAM module, along with an FPGA
and a sim variants of the latter.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoMove log2/ispow2 to a utils package
Benjamin Herrenschmidt [Tue, 22 Oct 2019 23:52:37 +0000 (10:52 +1100)]
Move log2/ispow2 to a utils package

(Out of icache and dcache)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoram: Add block RAM pipelining
Benjamin Herrenschmidt [Tue, 22 Oct 2019 05:05:18 +0000 (16:05 +1100)]
ram: Add block RAM pipelining

This adds an output buffer to help with timing and allows the BRAMs
to actually pipeline.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodecode: Reformat decode_types.vhdl
Benjamin Herrenschmidt [Mon, 21 Oct 2019 11:57:51 +0000 (22:57 +1100)]
decode: Reformat decode_types.vhdl

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoAdd option to not flatten hierarchy
Benjamin Herrenschmidt [Mon, 21 Oct 2019 04:15:07 +0000 (15:15 +1100)]
Add option to not flatten hierarchy

Vivado by default tries to flatten the module hierarchy to improve
placement and timing. However this makes debugging timing issues
really hard as the net names in the timing report can be pretty
bogus.

This adds a generic that can be used to control attributes to stop
vivado from flattening the main core components. The resulting design
will have worst timing overall but it will be easier to understand
what the worst timing path are and address them.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowriteback: Slightly improve timing
Benjamin Herrenschmidt [Mon, 21 Oct 2019 04:11:47 +0000 (15:11 +1100)]
writeback: Slightly improve timing

The CR update currently depends on the complete data formatting
mux chain. This makes it source its inputs from a bit earlier in
the chian, thus improving timing a bit

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agosimple_ram: Turn on pipelining
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:34:48 +0000 (10:34 +1100)]
simple_ram: Turn on pipelining

With a 1 cycle delay

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowb_debug: Add wishbone pipelining support
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:33:31 +0000 (10:33 +1100)]
wb_debug: Add wishbone pipelining support

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoicache: Add wishbone pipelining support
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:33:04 +0000 (10:33 +1100)]
icache: Add wishbone pipelining support

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodcache: Add wishbone pipelining support
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:32:46 +0000 (10:32 +1100)]
dcache: Add wishbone pipelining support

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agofpga/bram: Generate stall signal
Benjamin Herrenschmidt [Sat, 19 Oct 2019 10:22:33 +0000 (21:22 +1100)]
fpga/bram: Generate stall signal

This doesn't yet pipeline the block RAM, just generate a valid stall
signal so it's compatible with a pipelined master

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agosimple_ram: Add pipelining support
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:30:39 +0000 (10:30 +1100)]
simple_ram: Add pipelining support

The generic PIPELINE_DEPTH can be set to 0 to keep it operating
as a non-pipelined slave, or a larger value indicating
the amount of extra cycles between requests and acks.

It will always generate a valid stall signal, so it can be used
in either mode with a pipelined master (but only in non-pipelined
mode with a non-pipelined master).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agointercon: Generate stall signals for non-pipelined slaves
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:27:56 +0000 (10:27 +1100)]
intercon: Generate stall signals for non-pipelined slaves

So far the UART and the "miss" case. Memory will be
pipelined

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowb_arbiter: Forward stall signals
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:27:02 +0000 (10:27 +1100)]
wb_arbiter: Forward stall signals

They are set to '1' for non-selected devices

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoicache_tb: Initialize stop_mark
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:26:09 +0000 (10:26 +1100)]
icache_tb: Initialize stop_mark

Too much red in gtkwave..

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowishbone: Add stall signal
Benjamin Herrenschmidt [Thu, 17 Oct 2019 09:07:18 +0000 (20:07 +1100)]
wishbone: Add stall signal

Pipelined wishbone needs it

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agopp_uart: reformat
Benjamin Herrenschmidt [Fri, 18 Oct 2019 22:21:42 +0000 (09:21 +1100)]
pp_uart: reformat

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoMerge pull request #115 from antonblanchard/reduce-wishbone
Anton Blanchard [Fri, 25 Oct 2019 06:10:01 +0000 (17:10 +1100)]
Merge pull request #115 from antonblanchard/reduce-wishbone

Reduce wishbone

5 years agoMerge pull request #113 from mikey/exec-sim-remove
Anton Blanchard [Fri, 25 Oct 2019 04:52:24 +0000 (15:52 +1100)]
Merge pull request #113 from mikey/exec-sim-remove

Remove SIM generic from execute1

5 years agoMerge pull request #114 from antonblanchard/dcache
Anton Blanchard [Fri, 25 Oct 2019 04:49:33 +0000 (15:49 +1100)]
Merge pull request #114 from antonblanchard/dcache

Dcache from Ben

5 years agoRemove SIM generic from execute1
Michael Neuling [Thu, 24 Oct 2019 06:07:58 +0000 (17:07 +1100)]
Remove SIM generic from execute1

This does nothing, so remove.

Signed-off-by: Michael Neuling <mikey@neuling.org>
5 years agoReduce wishbone address size to 32-bit
Benjamin Herrenschmidt [Wed, 16 Oct 2019 23:21:41 +0000 (10:21 +1100)]
Reduce wishbone address size to 32-bit

For now ... it reduces the routing pressure on the FPGA

This needs manual adjustment of the address decoder in soc.vhdl, at
least until I can figure out how to deal with std_match

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
# Conflicts:
# soc.vhdl

# Conflicts:
# soc.vhdl

5 years agoMake it possible to change wishbone address size
Benjamin Herrenschmidt [Wed, 25 Sep 2019 06:54:25 +0000 (16:54 +1000)]
Make it possible to change wishbone address size

All that needs to be changed now is the size in wishbone_types.vhdl
and the address decoder in soc.vhdl

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodcache: Add testbench
Benjamin Herrenschmidt [Fri, 18 Oct 2019 23:31:39 +0000 (10:31 +1100)]
dcache: Add testbench

A very simple one for now...

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoinsn: Simplistic implementation of icbi
Benjamin Herrenschmidt [Tue, 22 Oct 2019 03:56:31 +0000 (14:56 +1100)]
insn: Simplistic implementation of icbi

We don't yet have a proper snooper for the icache, so for now make
icbi just flush the whole thing

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoinsn: Implement isync instruction
Benjamin Herrenschmidt [Tue, 22 Oct 2019 03:49:35 +0000 (14:49 +1100)]
insn: Implement isync instruction

The instruction works by redirecting fetch to nia+4 (hopefully using
the same adder used to generate LR) and doing a backflush. Along with
being single issue, this should guarantee that the next instruction
only gets fetched after the pipe's been emptied.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoicache & dcache: Fix store way variable
Benjamin Herrenschmidt [Thu, 17 Oct 2019 05:41:19 +0000 (16:41 +1100)]
icache & dcache: Fix store way variable

We used the variable "way" in the wrong state in the cache when
updating a line valid bit after the end of the wishbone transactions,
we need to use the latched "store_way".

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodcache: Cleanup (mostly cosmetic)
Benjamin Herrenschmidt [Wed, 16 Oct 2019 04:10:27 +0000 (15:10 +1100)]
dcache: Cleanup (mostly cosmetic)

Clearly separate the 2 stages of load hits, improve naming and
comments, clarify the writeback controls etc...

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoicache/dcache: Make both caches 32 lines, 2 ways
Benjamin Herrenschmidt [Tue, 15 Oct 2019 05:21:32 +0000 (16:21 +1100)]
icache/dcache: Make both caches 32 lines, 2 ways

Adding lines seems to add only little extra as the BRAMs aren't
full, 2 ways is our current comprimise to limit pressure on small
FPGAs. We could go to 64 lines for a little more, but timing is
becoming a bit too right to my linking on the tags/LRU path of
the icache, so let's leave it at 32 for now.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodcache: Introduce an extra cycle latency to make timing
Benjamin Herrenschmidt [Thu, 10 Oct 2019 00:25:16 +0000 (11:25 +1100)]
dcache: Introduce an extra cycle latency to make timing

This makes the BRAMs use an output buffer, introducing an extra
cycle latency. Without this, Vivado won't make timing at 100Mhz.

We stash all the necessary response data in delayed latches, the
extra cycle is NOT a state in the state machine, thus it's fully
pipelined and doesn't involve stalling.

This introduces an extra non-pipelined cycle for loads with update
to avoid collision on the writeback output between the now delayed
load data and the register update. We could avoid it by moving
the register update in the pipeline bubble created by the extra
update state, but it's a bit trickier, so I leave that for a latter
optimization.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agodcache: Add a dcache
Benjamin Herrenschmidt [Wed, 9 Oct 2019 13:40:46 +0000 (00:40 +1100)]
dcache: Add a dcache

This replaces loadstore2 with a dcache

The dcache unit is losely based on the icache one (same basic cache
layout), but has some significant logic additions to deal with stores,
loads with update, non-cachable accesses and other differences due to
operating in the execution part of the pipeline rather than the fetch
part.

The cache is store-through, though a hit with an existing line will
update the line rather than invalidate it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoicache: Reduce simulation warnings
Benjamin Herrenschmidt [Wed, 9 Oct 2019 13:40:11 +0000 (00:40 +1100)]
icache: Reduce simulation warnings

This might slightly increase the logic in synthesis but avoids
us looking at uninitialized tags when not servicing an active
request

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agocache_ram: Add write-enables
Benjamin Herrenschmidt [Wed, 9 Oct 2019 13:38:03 +0000 (00:38 +1100)]
cache_ram: Add write-enables

They will be needed by the dcache

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoplru: Improve sensitivity list
Benjamin Herrenschmidt [Tue, 8 Oct 2019 12:26:23 +0000 (23:26 +1100)]
plru: Improve sensitivity list

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoMerge pull request #112 from hughhalf/patch-1
Anton Blanchard [Mon, 21 Oct 2019 09:15:37 +0000 (20:15 +1100)]
Merge pull request #112 from hughhalf/patch-1

Minor tweaks to README.md

5 years agoMinor tweaks to README.md
Hugh [Mon, 21 Oct 2019 05:51:59 +0000 (16:51 +1100)]
Minor tweaks to README.md

Few tweaks based on a newcomers experience getting an Arty A7-100 up and running

Forgot to add DCO in initial PR, now corrected.

Signed-off-by: Hugh Blemings <hugh@blemings.org>
5 years agoMerge pull request #110 from antonblanchard/misc
Anton Blanchard [Sat, 19 Oct 2019 23:09:42 +0000 (10:09 +1100)]
Merge pull request #110 from antonblanchard/misc

icache_tb: Improve test and include test file

5 years agoicache_tb: Improve test and include test file
Benjamin Herrenschmidt [Fri, 18 Oct 2019 05:41:05 +0000 (16:41 +1100)]
icache_tb: Improve test and include test file

The icache_test.bin file was missing. This adds it (along with a python3
script to generate it).

We also add better reporting on errors

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoMerge pull request #109 from antonblanchard/misc
Anton Blanchard [Thu, 17 Oct 2019 06:37:49 +0000 (17:37 +1100)]
Merge pull request #109 from antonblanchard/misc

Misc updates from Ben

5 years agoisel takes a CR bit, not a CR field
Anton Blanchard [Thu, 17 Oct 2019 06:16:09 +0000 (17:16 +1100)]
isel takes a CR bit, not a CR field

Fix a GHDL assert in isel.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agocommon: Reformat
Benjamin Herrenschmidt [Wed, 16 Oct 2019 06:47:08 +0000 (17:47 +1100)]
common: Reformat

No code change

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoexecute1: Remove mux on "write_data" and "rc" outputs
Benjamin Herrenschmidt [Wed, 16 Oct 2019 01:32:45 +0000 (12:32 +1100)]
execute1: Remove mux on "write_data" and "rc" outputs

Only "write_enable" needs to change, this shrinks the core a bit more

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agocrhelpers: Constraint "crnum" integer
Benjamin Herrenschmidt [Wed, 16 Oct 2019 01:11:16 +0000 (12:11 +1100)]
crhelpers: Constraint "crnum" integer

This seems to save quite a few LUTs

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoexecute1: Reformat
Benjamin Herrenschmidt [Wed, 16 Oct 2019 01:28:19 +0000 (12:28 +1100)]
execute1: Reformat

No functional change

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agowriteback: Remove a mux leg on data_in
Benjamin Herrenschmidt [Wed, 16 Oct 2019 01:05:36 +0000 (12:05 +1100)]
writeback: Remove a mux leg on data_in

Initialize to 0 forces the mux to have an extra leg fed with zeros.

Instead initialize data_in to one of the mux inputs

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 years agoMerge pull request #105 from paulusmack/writeback
Anton Blanchard [Wed, 16 Oct 2019 20:40:36 +0000 (07:40 +1100)]
Merge pull request #105 from paulusmack/writeback

Writeback

5 years agowriteback: Eliminate inferred latch
Paul Mackerras [Tue, 15 Oct 2019 20:56:15 +0000 (07:56 +1100)]
writeback: Eliminate inferred latch

This initializes data_in to all zeroes so that it doesn't become a
set of 64 inferred latches.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoMerge pull request #106 from paulusmack/master
Anton Blanchard [Tue, 15 Oct 2019 10:05:10 +0000 (21:05 +1100)]
Merge pull request #106 from paulusmack/master

wishbone_debug_master: Improve timing

5 years agowishbone_debug_master: Improve timing
Paul Mackerras [Tue, 15 Oct 2019 07:16:07 +0000 (18:16 +1100)]
wishbone_debug_master: Improve timing

The current code has the possibility that we could set reg_addr
or reg_ctrl and then increment reg_addr in the same cycle, resulting
in some long timing paths.  Rearrange the code to make it clear
that we are not trying to add an auto-increment to data from
outside the module; in any given cycle we either set one of
reg_addr and reg_ctrl, or we possibly increment reg_addr.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoRemove execute2 stage
Paul Mackerras [Tue, 15 Oct 2019 05:26:36 +0000 (16:26 +1100)]
Remove execute2 stage

Since the condition setting got moved to writeback, execute2 does
nothing aside from wasting a cycle.  This removes it.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoMerge pull request #104 from paulusmack/master
Anton Blanchard [Tue, 15 Oct 2019 05:17:12 +0000 (16:17 +1100)]
Merge pull request #104 from paulusmack/master

Implement neg using OP_ADD

5 years agoDo sign-extension instructions in writeback instead of execute1
Paul Mackerras [Mon, 14 Oct 2019 03:39:23 +0000 (14:39 +1100)]
Do sign-extension instructions in writeback instead of execute1

This makes the exts[bhw] instructions do the sign extension in the
writeback stage using the sign-extension logic there instead of
having unique sign extension logic in execute1.  This requires
passing the data length and sign extend flag from decode2 down
through execute1 and execute2 and into writeback.  As a side bonus
we reduce the number of values in insn_type_t by two.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agowriteback: Do data formatting and condition recording in writeback
Paul Mackerras [Mon, 14 Oct 2019 01:56:01 +0000 (12:56 +1100)]
writeback: Do data formatting and condition recording in writeback

This adds code to writeback to format data and test the result
against zero for the purpose of setting CR0.  The data formatter
is able to shift and mask by bytes and do byte reversal and sign
extension.  It can also put together bytes from two input
doublewords to support unaligned loads (including unaligned
byte-reversed loads).

The data formatter starts with an 8:1 multiplexer that is able
to direct any byte of the input to any byte of the output.  This
lets us rotate the data and simultaneously byte-reverse it.
The rotated/reversed data goes to a register for the unaligned
cases that overlap two doublewords.  Then there is per-byte logic
that does trimming, sign extension, and splicing together bytes
from a previous input doubleword (stored in data_latched) and the
current doubleword.  Finally the 64-bit result is tested to set
CR0 if rc = 1.

This removes the RC logic from the execute2, multiply and divide
units, and the shift/mask/byte-reverse/sign-extend logic from
loadstore2.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoMerge pull request #103 from paulusmack/divider
Anton Blanchard [Tue, 15 Oct 2019 04:20:34 +0000 (15:20 +1100)]
Merge pull request #103 from paulusmack/divider

Divider

5 years agoImplement neg using OP_ADD
Paul Mackerras [Mon, 14 Oct 2019 05:02:45 +0000 (16:02 +1100)]
Implement neg using OP_ADD

We have all the machinery in place to implement the neg instruction
as OP_ADD.  Doing that means we can ditch OP_NEG, and saves about
66 slice LUTs on the A7-100.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agodivider: Reduce delay in detecting 32-bit overflow
Paul Mackerras [Tue, 15 Oct 2019 03:59:15 +0000 (14:59 +1100)]
divider: Reduce delay in detecting 32-bit overflow

Timing analysis showed that even with the output register, timing
was still a bit tight in the output stage, where the carry has to
propagate all the way through the 64-bit negater, and we were then
testing the top 33 bits to determine if a 32-bit operation had
overflowed.

Instead of detecting overflow at the end, we watch for any 1
bits getting shifted into the top 32 bits of the quotient register
as we are doing the division.  That is relatively easy to do and
simplifies the output stage.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoMerge pull request #102 from antonblanchard/gpr-hazard-5-c
Anton Blanchard [Tue, 15 Oct 2019 01:49:06 +0000 (12:49 +1100)]
Merge pull request #102 from antonblanchard/gpr-hazard-5-c

Add CR hazard detection

5 years agoAdd CR hazard detection
Anton Blanchard [Tue, 15 Oct 2019 00:22:59 +0000 (11:22 +1100)]
Add CR hazard detection

To keep things simple we treat the CR as a single entity.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #101 from antonblanchard/gpr-hazard-5-b
Anton Blanchard [Tue, 15 Oct 2019 00:22:48 +0000 (11:22 +1100)]
Merge pull request #101 from antonblanchard/gpr-hazard-5-b

Add GPR hazard detection

5 years agodivider: Add an output register
Paul Mackerras [Mon, 14 Oct 2019 23:29:53 +0000 (10:29 +1100)]
divider: Add an output register

This puts the output of the divider through a register.  With the
addition of the logic to detect overflow, the combinatorial output
logic of the divider was becoming a critical path.  Adding the
output register adds a cycle to the latency of the divider but
helps make timing at 100MHz on the A7-100.

This also makes the valid, write_reg_enable and write_cr_enable
fields of the output be registered, which eliminates warnings
about register/latch pins with no clock.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoRemove issue restrictions on a number of instructions
Anton Blanchard [Mon, 14 Oct 2019 05:20:07 +0000 (16:20 +1100)]
Remove issue restrictions on a number of instructions

Anything that isn't a load or store and anything that doesn't read the
CR can go as soon as its inputs are ready.

While we could also allow SPR read/write and carry read/write, we plan
to change them to be read in decode2 and written in writeback soon and
they will need separate hazard detection to be added.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoAdd GPR hazard detection
Anton Blanchard [Mon, 14 Oct 2019 02:27:45 +0000 (13:27 +1100)]
Add GPR hazard detection

Check GPRs against any writers in the pipeline.

All instructions are still marked single in pipeline at
this stage.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #100 from antonblanchard/gpr-hazard-5-a
Anton Blanchard [Mon, 14 Oct 2019 22:02:56 +0000 (09:02 +1100)]
Merge pull request #100 from antonblanchard/gpr-hazard-5-a

Separate issue control into its own unit

5 years agoMerge pull request #99 from paulusmack/logical
Anton Blanchard [Mon, 14 Oct 2019 02:14:04 +0000 (13:14 +1100)]
Merge pull request #99 from paulusmack/logical

Logical

5 years agoSeparate issue control into its own unit
Anton Blanchard [Mon, 14 Oct 2019 01:40:23 +0000 (12:40 +1100)]
Separate issue control into its own unit

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agocountzero: Add a testbench
Paul Mackerras [Thu, 10 Oct 2019 04:09:41 +0000 (15:09 +1100)]
countzero: Add a testbench

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agocountzero: Reorganize to have fewer levels of logic and fewer LUTs
Paul Mackerras [Fri, 11 Oct 2019 05:06:01 +0000 (16:06 +1100)]
countzero: Reorganize to have fewer levels of logic and fewer LUTs

By using 4:1 multiplexers rather than 2:1, this cuts the number of
levels of multiplexing from 4 to 2 and also reduces the total number
of slice LUTs required.  Because we are now handling 4 bits at each
level, including the bottom level, the logic to do the priority
encoding can be factored out into a function that is used at each
level.

This rearranges the logic so that the encoding and selection of bits
is done whether or not the input operand is zero, and the if statement
testing whether the input is zero only affects what is assigned to
result.  With this we don't get the inferred latches and we can go
back to using signals rather than variables.

Also add some comments about what is being done.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoMerge pull request #98 from antonblanchard/fix-mod
Anton Blanchard [Sun, 13 Oct 2019 11:10:18 +0000 (22:10 +1100)]
Merge pull request #98 from antonblanchard/fix-mod

mod* doesn't have an RC form

5 years agomod* doesn't have an RC form
Anton Blanchard [Sun, 13 Oct 2019 10:42:27 +0000 (21:42 +1100)]
mod* doesn't have an RC form

The RC bit should be ignored for mod* instructions.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #96 from antonblanchard/clk_gen_bypass-fix
Anton Blanchard [Sun, 13 Oct 2019 04:36:37 +0000 (15:36 +1100)]
Merge pull request #96 from antonblanchard/clk_gen_bypass-fix

Fix clk_gen_bypass

5 years agoFix clk_gen_bypass
Anton Blanchard [Sun, 13 Oct 2019 03:41:53 +0000 (14:41 +1100)]
Fix clk_gen_bypass

clk_gen_bypass needed updating after the addition of CLK_INPUT_HZ and
CLK_OUTPUT_HZ.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #94 from antonblanchard/icbi-nop
Anton Blanchard [Sun, 13 Oct 2019 02:30:52 +0000 (13:30 +1100)]
Merge pull request #94 from antonblanchard/icbi-nop

decode: Handle icbi

5 years agoMerge pull request #93 from antonblanchard/fifo-fix
Anton Blanchard [Sun, 13 Oct 2019 02:11:46 +0000 (13:11 +1100)]
Merge pull request #93 from antonblanchard/fifo-fix

Remove shared variable from fifo, and reformat

5 years agodecode: Handle icbi
Anton Blanchard [Sun, 13 Oct 2019 01:59:14 +0000 (12:59 +1100)]
decode: Handle icbi

We will need a proper handler for icbi, but in the meantime treat it
as a nop.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agofifo: Reformat
Anton Blanchard [Sun, 13 Oct 2019 01:57:23 +0000 (12:57 +1100)]
fifo: Reformat

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agofifo: Remove shared variable
Anton Blanchard [Sun, 13 Oct 2019 01:52:39 +0000 (12:52 +1100)]
fifo: Remove shared variable

The shared variable used for FIFO memory is not VHDL 2008 compliant.
I can't see why it needs to be a shared variable since reads and writes
update top and bottom synchronously, meaning they don't need same cycle
access to the FIFO memory.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #92 from paulusmack/divider
Anton Blanchard [Sat, 12 Oct 2019 11:23:10 +0000 (22:23 +1100)]
Merge pull request #92 from paulusmack/divider

Divider

5 years agoMerge pull request #91 from tgingold/gpr-file-fix
Anton Blanchard [Sat, 12 Oct 2019 11:18:37 +0000 (22:18 +1100)]
Merge pull request #91 from tgingold/gpr-file-fix

Fix register file size (there are 32 gprs).

5 years agodivider: Return 0 for invalid and overflow cases, like P9 does
Paul Mackerras [Fri, 11 Oct 2019 04:16:47 +0000 (15:16 +1100)]
divider: Return 0 for invalid and overflow cases, like P9 does

This adds logic to detect the cases where the quotient of the
division overflows the range of the output representation, and
return all zeroes in those cases, which is what POWER9 does.
To do this, we extend the dividend register by 1 bit and we do
an extra step in the division process to get a 2^64 bit of the
quotient, which ends up in the 'overflow' signal.  This catches all
the cases where dividend >= 2^64 * divisor, including the case
where divisor = 0, and the divde/divdeu cases where |RA| >= |RB|.

Then, in the output stage, we also check that the result fits in
the representable range, which depends on whether the division is
a signed division or not, and whether it is a 32-bit or 64-bit
division.  If dividend >= 2^64 or the result doesn't fit in the
representable range, write_data is set to 0 and write_cr_data to
0x20000000 (i.e. cr0.eq = 1).

POWER9 sets the top 32 bits of the result to zero for 32-bit signed
divisions, and sets CR0 when RC=1 according to the 64-bit value
(i.e. CR0.LT is always 0 for 32-bit signed divisions, even if the
32-bit result is negative).  However, modsw with a negative result
sets the top 32 bits to all 1s.  We follow suit.

This updates divider_tb to check the invalid cases as well as the
valid case.

This also fixes a small bug where the reset signal for the divider
was driven from rst when it should have been driven from core_rst.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agodecode2: Fix 32-bit flag passed to divider
Paul Mackerras [Sat, 12 Oct 2019 05:15:20 +0000 (16:15 +1100)]
decode2: Fix 32-bit flag passed to divider

Previously the 32-bit flag passed to the divider was always wrong;
this fixes it.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
5 years agoFix register file size (there are 32 gprs).
Tristan Gingold [Sat, 12 Oct 2019 04:56:32 +0000 (06:56 +0200)]
Fix register file size (there are 32 gprs).

5 years agoMerge pull request #84 from classilla/master
Anton Blanchard [Fri, 11 Oct 2019 05:47:37 +0000 (16:47 +1100)]
Merge pull request #84 from classilla/master

Add logo

5 years agoMerge pull request #89 from mikey/gitignore
Anton Blanchard [Fri, 11 Oct 2019 05:46:03 +0000 (16:46 +1100)]
Merge pull request #89 from mikey/gitignore

Update gitignore for new test bench build files

5 years agoMerge pull request #90 from antonblanchard/newcrf-inferred-latch
Anton Blanchard [Fri, 11 Oct 2019 05:45:45 +0000 (16:45 +1100)]
Merge pull request #90 from antonblanchard/newcrf-inferred-latch

Don't infer latch for newcrf

5 years agoDon't infer latch for newcrf
Anton Blanchard [Fri, 11 Oct 2019 05:31:14 +0000 (16:31 +1100)]
Don't infer latch for newcrf

Always initialize newcrf to avoid inferring a latch.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoUpdate gitignore for new test bench build files
Michael Neuling [Fri, 11 Oct 2019 05:02:04 +0000 (16:02 +1100)]
Update gitignore for new test bench build files

Just ignore all *_tb files

Signed-off-by: Michael Neuling <mikey@neuling.org>
5 years agoMerge pull request #87 from antonblanchard/cmod-a7-freq
Anton Blanchard [Thu, 10 Oct 2019 10:29:06 +0000 (21:29 +1100)]
Merge pull request #87 from antonblanchard/cmod-a7-freq

Fix cmod-a7 frequency

5 years agoFix cmod-a7 frequency
Anton Blanchard [Thu, 10 Oct 2019 09:59:49 +0000 (20:59 +1100)]
Fix cmod-a7 frequency

The cmod-a7 is ignoring the clk_frequency parameter and running at
100 MHz. Fix it.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
5 years agoMerge pull request #86 from antonblanchard/outstanding-range
Anton Blanchard [Thu, 10 Oct 2019 09:32:47 +0000 (20:32 +1100)]
Merge pull request #86 from antonblanchard/outstanding-range

Limit outstanding range

5 years agoMerge pull request #85 from antonblanchard/leadingzeroes-fix
Anton Blanchard [Thu, 10 Oct 2019 06:56:55 +0000 (17:56 +1100)]
Merge pull request #85 from antonblanchard/leadingzeroes-fix

Fix count-leading/trailing-zeroes

5 years agoMerge pull request #79 from deece/uart_address
Anton Blanchard [Thu, 10 Oct 2019 06:47:15 +0000 (17:47 +1100)]
Merge pull request #79 from deece/uart_address

Tighten UART address