microwatt.git
4 years agofetch2: Remove blank line
Benjamin Herrenschmidt [Wed, 2 Oct 2019 06:17:42 +0000 (16:17 +1000)]
fetch2: Remove blank line

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoicache: Use narrower block RAMs
Benjamin Herrenschmidt [Mon, 30 Sep 2019 08:17:10 +0000 (18:17 +1000)]
icache: Use narrower block RAMs

We only ever access the cache memory for at most the wishbone bus
width at a time. So having the BRAMs organized as a cache-line-wide
port is a waste of resources.

Instead, use a wishbone-wide memory and store a line as consecutive
rows in the BRAM.

This significantly improves BRAM usage in the FPGA as we can now use
more rows in the BRAM blocks. It also saves a few LUTs and muxes.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agofetch/icache: Fit icache in BRAM
Benjamin Herrenschmidt [Fri, 27 Sep 2019 03:23:56 +0000 (13:23 +1000)]
fetch/icache: Fit icache in BRAM

The goal is to have the icache fit in BRAM by latching the output
into a register. In order to avoid timing issues , we need to give
the BRAM a full cycle on reads, and thus we souce the BRAM address
directly from fetch1 latched NIA.

(Note: This will be problematic if/when we want to hash the address,
we'll probably be better off having fetch1 latch a fully hashed address
along with the normal one, so the icache can use the former to address
the BRAM and pass the latter along)

One difficulty is that we cannot really stall the icache without adding
more combo logic that would break the "one full cycle" BRAM model. This
means that on stalls from decode, by the time we stall fetch1, it has
already gone to the next address, which the icache is already latching.

We work around this by having a "stash" buffer in fetch2 that will stash
away the icache output on a stall, and override the output of the icache
with the content of the stash buffer when unstalling.

This requires a rewrite of the stop/step debug logic as well. We now
do most of the hard work in fetch1 which makes more sense.

Note: Vivado is still not inferring an built-in output register for the
BRAMs. I don't want to add another cycle... I don't fully understand why
it wouldn't be able to treat current_row as such but clearly it won't. At
least the timing seems good enough now for 100Mhz, possibly more.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agofetch1: Simplify a bit
Benjamin Herrenschmidt [Tue, 1 Oct 2019 04:24:07 +0000 (14:24 +1000)]
fetch1: Simplify a bit

There is no need to have two different state records

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoicache: Reformat icache
Benjamin Herrenschmidt [Wed, 25 Sep 2019 06:50:24 +0000 (16:50 +1000)]
icache: Reformat icache

No code change

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #78 from paulusmack/new-decode
Anton Blanchard [Mon, 7 Oct 2019 23:20:22 +0000 (10:20 +1100)]
Merge pull request #78 from paulusmack/new-decode

New decode

4 years agoAdd a rotate/mask/shift unit and use it in execute1
Paul Mackerras [Mon, 7 Oct 2019 07:26:11 +0000 (18:26 +1100)]
Add a rotate/mask/shift unit and use it in execute1

This adds a new entity 'rotator' which contains combinatorial logic
for rotating and masking 64-bit values.  It implements the operations
of the rlwinm, rlwnm, rlwimi, rldicl, rldicr, rldic, rldimi, rldcl,
rldcr, sld, slw, srd, srw, srad, sradi, sraw and srawi instructions.
It consists of a 3-stage 64-bit rotator using 4:1 multiplexors at
each stage, two mask generators, output logic and control logic.

The insn_type_t values used for these instructions have been reduced
to just 5: OP_RLC, OP_RLCL and OP_RLCR for the rotate and mask
instructions (clear both left and right, clear left, clear right
variants), OP_SHL for left shifts, and OP_SHR for right shifts.
The control signals for the rotator are derived from the opcode
and from the is_32bit and is_signed fields of the decode_rom_t.

The rotator is instantiated as an entity in execute1 so that we can
be sure we only have one of it.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoGeneralize the mul_32bit and mul_signed fields of decode_rom_t
Paul Mackerras [Sun, 6 Oct 2019 04:21:27 +0000 (15:21 +1100)]
Generalize the mul_32bit and mul_signed fields of decode_rom_t

This changes the names of the mul_32bit and mul_signed fields of
decode_rom_t to is_32bit and is_signed, so they can be used with
other types of operations besides multiplies.

This plumbs the is_32bit and is_signed flags down into execute1,
though they are not used at this point.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Avoid multiplexing from instruction reg fields to regfile address ports
Paul Mackerras [Fri, 4 Oct 2019 09:26:37 +0000 (19:26 +1000)]
decode: Avoid multiplexing from instruction reg fields to regfile address ports

This aims to simplify the logic between the instruction image and
the register file read address ports and reduce the size of the decode
tables.  With this patch, the input_reg_a column of the decode tables
can only select RA or zeroes, the input_reg_b column can only select
RB or a constant (0, -1, or an immediate value from the instruction),
and the input_reg_c columns can only select RS or zeroes.

That means that the rotate/shift/logical ops now have their first
input coming in via the input_reg_c column.  That means we need to
add a read_data3 field to the Decode2ToExecuteType record, but that
will go away again when we split out the rotate/mask/logical ops to
their own unit.

As a related but not tightly connected change, this patch also sets
the read1_enable signal to the register file be 0 when RA=0 and the
input_reg_a for the instruction is RA_OR_ZERO (previously it was 1).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoConsolidate add/subtract instructions into a single op
Paul Mackerras [Fri, 4 Oct 2019 06:11:21 +0000 (16:11 +1000)]
Consolidate add/subtract instructions into a single op

All of the PPC add and subtract instructions, including carrying
and extended versions, do much the same arithmetic operation:

result = (I xor A) + B + C

where A is the value from RA, I provides a logical inversion of A
(i.e. I is 0 or -1), B is either from RB or is a constant 0 or -1,
and C is 0, 1 or the carry bit from XER (CA).

To consolidate all the add/subtract instructions into a single
OP_ADD, we add a column to decode_rom_t to indicate when A should
be inverted, and change the input_carry field to a 3-state selector
to select C in the equation above.

This also adds a new "CONST_M1" value for input_reg_b_t to indicate
that B is a constant -1.  This allows us to implement addme and
subfme.

The addex instruction appears not to exist, so the comments referring
to it are removed.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoMerge pull request #80 from antonblanchard/misc
Anton Blanchard [Fri, 4 Oct 2019 00:32:13 +0000 (10:32 +1000)]
Merge pull request #80 from antonblanchard/misc

Reduce register file footprint

4 years agodecode: Make all update-form indexed loads and stores use RA_OR_ZERO
Paul Mackerras [Thu, 3 Oct 2019 22:25:53 +0000 (08:25 +1000)]
decode: Make all update-form indexed loads and stores use RA_OR_ZERO

Experimentation on POWER9 indicates that the invalid form of lbzux
with RA=0 uses just RB as the address, not R0 + RB.  Extrapolating
this to all update-form loads and stores with RA=0, change all the
update-form loads and stores to use RA_OR_ZERO rather than RA.

This then means that all decode ROM entries with insn_type = LDST
have input_reg_a = RA_OR_ZERO.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoregister_file: Move GPRs into distributed RAM
Benjamin Herrenschmidt [Thu, 3 Oct 2019 02:38:49 +0000 (12:38 +1000)]
register_file: Move GPRs into distributed RAM

The register file is currently implemented as a whole pile of individual
1-bit registers instead of LUT memory which is a huge waste of FPGA
space.

This is caused by the output signal exposing the register file to the
outside world for simulation debug.

This removes that output, and moves the dumping of the register file
to the register file module itself. This saves about 8% of fpga on
the little Arty A7-35T.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agodecode: Remove const fields from decode_rom_t
Paul Mackerras [Wed, 2 Oct 2019 12:21:09 +0000 (22:21 +1000)]
decode: Remove const fields from decode_rom_t

The const* fields of decode_rom_t drove multiplexers in decode2 that
picked out various instruction fields and put them into the const*
fields of the Decode2ToExecute1Type record, from where they were
used in execute1.  However, the code in execute1 can just as easily
use the appropriate fields of the original instruction word, since
that is now available in execute1.  This therefore changes the
code to do that, resulting in smaller decode tables.

Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodebug/sim: Make connect/disconnect messages quieter
Benjamin Herrenschmidt [Tue, 1 Oct 2019 23:58:44 +0000 (09:58 +1000)]
debug/sim: Make connect/disconnect messages quieter

Those don't need to go to stderr, send them to stdout instead

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agodecode: Fix larx/stcx instructions to use RA_OR_ZERO not RA
Paul Mackerras [Tue, 1 Oct 2019 05:49:07 +0000 (15:49 +1000)]
decode: Fix larx/stcx instructions to use RA_OR_ZERO not RA

The l?arx and st?cx. instructions are defined to use the normal indexed
mode address calculations, i.e. (RA|0) + RB.  Fix their entries in the
decode table to say RA_OR_ZERO rather than RA.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Index minor op table with insn bits for opcode 31
Paul Mackerras [Mon, 30 Sep 2019 05:03:06 +0000 (15:03 +1000)]
decode: Index minor op table with insn bits for opcode 31

This changes decode_op_31_array from being indexed by a ppc_insn_t
(which is derived from the instruction word by a whole series of
if/elsif statements) to being indexed directly by bits 10...1 of
the instruction word.  With this we no longer need ppc_insn.

This then means that the decode1 stage doesn't distinguish between
mfcr and mfocrf, or between mtcrf and mtocrf, since those are
distinguished by the value in bit 20 of the instruction.  To
accommodate that, execute1 changes so that the one op value (OP_MFCR)
does either the mfcr or the mfocrf behaviour depending on bit 20
of the instruction word; and similarly for mtcrf/mtocrf.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Index minor op table with insn bits for opcode 30
Paul Mackerras [Sun, 29 Sep 2019 06:41:52 +0000 (16:41 +1000)]
decode: Index minor op table with insn bits for opcode 30

This comprises the 64-bit rotate and mask instructions.  In order to
reduce the table index to 3 bits, we combine rldcl and rdlcr into a
single op (OP_RLDCX), and choose the right mask at execute time based
on bit 1 of the instruction word.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Index minor op table with insn bits for opcode 19
Paul Mackerras [Sun, 29 Sep 2019 06:26:07 +0000 (16:26 +1000)]
decode: Index minor op table with insn bits for opcode 19

This changes the decoding of major opcode 19 from using the ppc_insn_t
index to using bits of the instruction word directly.  Opcode 19 has
a 10-bit minor opcode field (bits 10..1) but the space is sparsely
filled.  Therefore we index a table of single-bit entries with the
10-bit minor opcode to filter out the illegal minor opcodes, and
index a table using just 3 bits -- 5, 3 and 2 -- of the instruction
to get the decode entry.  This groups together all the instructions
in 4 columns of the opcode map as a single entry.  That means that
mcrf and all the CR logical ops get grouped together, and bcctr, bclr
and bctar get grouped together.  At present the CR logical ops are not
implemented, so their grouping has no impact.

The code for bclr and bcctr in execute1 is now common, using a single
op, and it now determines the branch address by looking at bit 10 of
the instruction word at execute time.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Start moving towards decoding by major opcode first
Paul Mackerras [Sat, 28 Sep 2019 23:17:39 +0000 (09:17 +1000)]
decode: Start moving towards decoding by major opcode first

With this, we have a table for most major opcodes and separate
tables for each major opcode that has further decoding required.
These tables are still mostly indexed by the ppc_insn_t values,
however.

A few things are still decoded completely at the top level: nop,
attn and sim_config.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodecode: Push mtspr/mfspr register decoding down into execute1
Paul Mackerras [Sat, 28 Sep 2019 04:43:46 +0000 (14:43 +1000)]
decode: Push mtspr/mfspr register decoding down into execute1

Instead of doing mfctr, mflr, mftb, mtctr, mtlr as separate ops,
just pass down mfspr and mtspr ops with the spr number and let
execute1 decode which SPR we're addressing.  This will help reduce
the number of instruction bits decode1 needs to look at.

In fact we now pass down the whole instruction from decode2 to
execute1.  We will need more bits of the instruction in future,
and the tools should just optimize away any that we don't end
up using.  Since the 'aa' bit was just a copy of an instruction
bit, we can now remove it from the record.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoAdd MCRF instruction
Benjamin Herrenschmidt [Tue, 24 Sep 2019 14:09:35 +0000 (00:09 +1000)]
Add MCRF instruction

Hopefully it's not too timing catastrophic. The variable newcrf will
be handy for the other CR ops when we implement them I suspect.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoImplement absolute branches
Benjamin Herrenschmidt [Tue, 24 Sep 2019 05:47:25 +0000 (15:47 +1000)]
Implement absolute branches

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #77 from antonblanchard/timing
Anton Blanchard [Mon, 30 Sep 2019 08:21:54 +0000 (18:21 +1000)]
Merge pull request #77 from antonblanchard/timing

A number of timing fixes

4 years agoMerge pull request #76 from antonblanchard/misc
Anton Blanchard [Mon, 30 Sep 2019 08:00:41 +0000 (18:00 +1000)]
Merge pull request #76 from antonblanchard/misc

Some misc updates

4 years agoImprove PLL/MMCM clocks configuration
Benjamin Herrenschmidt [Tue, 24 Sep 2019 04:57:34 +0000 (14:57 +1000)]
Improve PLL/MMCM clocks configuration

We can now pass both the input clock and target clock frequency
via generics. Add support for both 50Mhz and 100Mhz target freqs
for both cases.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoDon't reset JTAG request register asynchronously
Benjamin Herrenschmidt [Thu, 26 Sep 2019 01:09:46 +0000 (11:09 +1000)]
Don't reset JTAG request register asynchronously

There's no point and it causes Vivado to spew a pile of warnings

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMultiply needs to be 16 stages to fix all timing issues
Benjamin Herrenschmidt [Thu, 26 Sep 2019 00:53:55 +0000 (10:53 +1000)]
Multiply needs to be 16 stages to fix all timing issues

This seems dependent on the FPGA type/size, so we should probably
make it a toplevel generic, but for now this helps on the
Arty A7-35

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoloadstore2: Do data formatting after a register stage
Paul Mackerras [Wed, 25 Sep 2019 10:27:08 +0000 (20:27 +1000)]
loadstore2: Do data formatting after a register stage

This moves the data formatting for read data to after a register,
instead of before, in order to improve timing.  The data formatting
is now effectively combinational logic on the input side of the
writeback stage.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agocorefile: Remove duplicate wishbone_debug_master
Benjamin Herrenschmidt [Mon, 30 Sep 2019 03:54:04 +0000 (13:54 +1000)]
corefile: Remove duplicate wishbone_debug_master

It's both in core and soc, it should only be in the latter

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agofpga: Arty A7's don't need multiple filesets
Benjamin Herrenschmidt [Mon, 30 Sep 2019 02:56:09 +0000 (12:56 +1000)]
fpga: Arty A7's don't need multiple filesets

the XDC is identical between variants, so is the fileset

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoexecute1: simplify flush_out
Benjamin Herrenschmidt [Wed, 25 Sep 2019 06:42:44 +0000 (16:42 +1000)]
execute1: simplify flush_out

It's always set when f_out.redirect is set, so may as well set it once
at the end. It's all combo from the register.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoReformat fetch2
Benjamin Herrenschmidt [Wed, 25 Sep 2019 01:28:20 +0000 (11:28 +1000)]
Reformat fetch2

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMove fetch2 <-> icache definitions
Benjamin Herrenschmidt [Wed, 25 Sep 2019 01:26:36 +0000 (11:26 +1000)]
Move fetch2 <-> icache definitions

To a more logical place before decode related ones

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoRemove unused pipe_stop in Fetch1ToFetch2Type
Benjamin Herrenschmidt [Wed, 25 Sep 2019 02:48:15 +0000 (12:48 +1000)]
Remove unused pipe_stop in Fetch1ToFetch2Type

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoFix PLL reset signal name in toplevel
Benjamin Herrenschmidt [Wed, 11 Sep 2019 11:18:22 +0000 (12:18 +0100)]
Fix PLL reset signal name in toplevel

It shouldn't have a _n suffix, it's active positive.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoSimplify fetch1
Benjamin Herrenschmidt [Tue, 24 Sep 2019 02:17:42 +0000 (12:17 +1000)]
Simplify fetch1

Do the +4 in a single place. This shouldn't cause any difference
in behaviour as these are sequential variable assignments.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoReformat fetch1
Benjamin Herrenschmidt [Tue, 24 Sep 2019 02:11:24 +0000 (12:11 +1000)]
Reformat fetch1

No code change

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoUpdate dependency
Benjamin Herrenschmidt [Wed, 25 Sep 2019 06:54:25 +0000 (16:54 +1000)]
Update dependency

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #75 from paulusmack/master
Anton Blanchard [Sat, 28 Sep 2019 04:32:31 +0000 (14:32 +1000)]
Merge pull request #75 from paulusmack/master

fpga: Add definitions for Arty A7-100 board

4 years agoMerge pull request #74 from paulusmack/divider
Anton Blanchard [Sat, 28 Sep 2019 04:32:14 +0000 (14:32 +1000)]
Merge pull request #74 from paulusmack/divider

Divider

4 years agofpga: Add definitions for Arty A7-100 board
Paul Mackerras [Fri, 27 Sep 2019 23:08:13 +0000 (09:08 +1000)]
fpga: Add definitions for Arty A7-100 board

These are a copy of the A7-35 definitions with 35 changed to 100.
The A7-100 uses the same .xdc file (arty_a7-35.xdc) as the A7-35
since the only difference between the two is the FPGA part; the
hardware and connections on the two boards are identical.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodivider: Do absolute-value ops in divider instead of decode
Paul Mackerras [Fri, 27 Sep 2019 22:55:08 +0000 (08:55 +1000)]
divider: Do absolute-value ops in divider instead of decode

This moves the negation of negative operands for signed divide and
modulus operations out of the decode2 stage and into the divider.
If either of the operands for a signed divide or modulus operation
is negative, the divider now takes an extra cycle to negate the
operands that are negative.

The interface to the divider now has an 'is_signed' signal rather
than a 'neg_result' signal, and the dividend and divisor can be
negative, so divider_tb had to be updated for the new interface.

The reason for doing this is that one of the worst timing violations
on the Arty A7-100 at 100MHz involved the carry chain in the adders
that did the negation of the dividend and divisor in the decode stage.
Moving the negations to a separate cycle fixes that and also seems to
reduce the total number of slice LUTs used.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agodivider: Always compute result/sresult/d_out.write_reg_data
Paul Mackerras [Wed, 25 Sep 2019 10:03:46 +0000 (20:03 +1000)]
divider: Always compute result/sresult/d_out.write_reg_data

These are intended to be combinatorial.  The previous code was giving
warnings in vivado about registers/latches with no clock defined.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoMerge pull request #73 from antonblanchard/remove-divide-patch
Anton Blanchard [Tue, 24 Sep 2019 23:13:18 +0000 (09:13 +1000)]
Merge pull request #73 from antonblanchard/remove-divide-patch

Remove gcc software divide patch

4 years agoRemove gcc software divide patch
Anton Blanchard [Tue, 24 Sep 2019 22:03:10 +0000 (08:03 +1000)]
Remove gcc software divide patch

We have a divider, thanks to Paul.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #72 from antonblanchard/build-error
Anton Blanchard [Tue, 24 Sep 2019 10:54:28 +0000 (20:54 +1000)]
Merge pull request #72 from antonblanchard/build-error

Fix build issue in dmi_dtm_dummy.vhdl

4 years agoMerge pull request #71 from antonblanchard/dependencies
Anton Blanchard [Tue, 24 Sep 2019 10:34:52 +0000 (20:34 +1000)]
Merge pull request #71 from antonblanchard/dependencies

Update Makefile dependencies

4 years agoFix build issue in dmi_dtm_dummy.vhdl
Anton Blanchard [Tue, 24 Sep 2019 10:27:34 +0000 (20:27 +1000)]
Fix build issue in dmi_dtm_dummy.vhdl

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoUpdate Makefile dependencies
Anton Blanchard [Tue, 24 Sep 2019 07:50:17 +0000 (17:50 +1000)]
Update Makefile dependencies

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge branch 'divider' of https://github.com/paulusmack/microwatt
Anton Blanchard [Tue, 24 Sep 2019 07:33:21 +0000 (17:33 +1000)]
Merge branch 'divider' of https://github.com/paulusmack/microwatt

4 years agoMerge pull request #70 from antonblanchard/badly-named-carry
Anton Blanchard [Tue, 24 Sep 2019 07:25:44 +0000 (17:25 +1000)]
Merge pull request #70 from antonblanchard/badly-named-carry

Rename OP_SUBFC -> OP_SUBFE, OP_ADDC -> OP_ADDE

4 years agoRename OP_SUBFC -> OP_SUBFE, OP_ADDC -> OP_ADDE
Anton Blanchard [Tue, 24 Sep 2019 06:55:09 +0000 (16:55 +1000)]
Rename OP_SUBFC -> OP_SUBFE, OP_ADDC -> OP_ADDE

These were somewhat badly named.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #69 from antonblanchard/debug-module
Anton Blanchard [Tue, 24 Sep 2019 06:51:03 +0000 (16:51 +1000)]
Merge pull request #69 from antonblanchard/debug-module

Merge debug module patches

4 years agoTerminate test on illegal instruction
Anton Blanchard [Mon, 23 Sep 2019 11:22:18 +0000 (21:22 +1000)]
Terminate test on illegal instruction

This gets the CI going again, but we will want to fix the test
harness since it's useful to be able to debug the core after it
executes an illegal instruction.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoFix ghdl error
Anton Blanchard [Mon, 23 Sep 2019 11:20:12 +0000 (21:20 +1000)]
Fix ghdl error

I'm seeing an issue on my version of ghdl:

  core.vhdl:137:24:error: actual expression must be globally static

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoAdd core_debug.vhdl to fusesoc configs
Anton Blanchard [Mon, 23 Sep 2019 10:49:21 +0000 (20:49 +1000)]
Add core_debug.vhdl to fusesoc configs

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoSpeed up the divider a little
Paul Mackerras [Mon, 23 Sep 2019 04:39:50 +0000 (14:39 +1000)]
Speed up the divider a little

This looks for cases where the next 8 bits of the quotient are obviously
going to be zero, because the top 72 bits of the 128-bit dividend
register are all zero.  In those cases we shift 8 zero bits into the
quotient and increase count by 8.  We only do this if count < 56.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoAdd a divider unit and a testbench for it
Paul Mackerras [Sun, 22 Sep 2019 07:24:14 +0000 (17:24 +1000)]
Add a divider unit and a testbench for it

This adds a divider unit, connected to the core in much the same way
that the multiplier unit is connected.  The division algorithm is
very simple-minded, taking 64 clock cycles for any division (even
32-bit division instructions).

The decoding is simplified by making use of regularities in the
instruction encoding for div* and mod* instructions.  Instead of
having PPC_* encodings from the first-stage decoder for each of the
different div* and mod* instructions, we now just have PPC_DIV and
PPC_MOD, and the inputs to the divider that indicate what sort of
division operation to do are derived from instruction word bits.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
4 years agoAdd distclean to Makefile
Benjamin Herrenschmidt [Fri, 20 Sep 2019 06:45:26 +0000 (16:45 +1000)]
Add distclean to Makefile

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoNew C based JTAG debug tool
Benjamin Herrenschmidt [Mon, 16 Sep 2019 15:29:08 +0000 (16:29 +0100)]
New C based JTAG debug tool

This works with both the sim socket and urjtag, and supports the
new core functions, loading a file in memory etc...

The code still needs a lot of cleanup and a help!

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoAdd core debug module
Benjamin Herrenschmidt [Tue, 10 Sep 2019 16:43:52 +0000 (17:43 +0100)]
Add core debug module

This module adds some simple core controls:

  reset, stop, start, step

along with icache clear and reading the NIA and core
status bits

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org
4 years agoAdd jtag support in simulation via a socket
Benjamin Herrenschmidt [Mon, 16 Sep 2019 15:28:48 +0000 (16:28 +0100)]
Add jtag support in simulation via a socket

This adds a local socket that can be used to communicate with
the debug tool (which will be committed separately) and generates
the JTAG signals.

We generate the low level JTAG signals, thus directly driving the
simulated BSCANE2, and the Xilinx DTM

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoAdd DMI address decoder
Benjamin Herrenschmidt [Tue, 10 Sep 2019 16:39:59 +0000 (17:39 +0100)]
Add DMI address decoder

And prepare signals for core DMI support

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoWishbone debug module
Benjamin Herrenschmidt [Tue, 10 Sep 2019 16:31:25 +0000 (17:31 +0100)]
Wishbone debug module

This adds a debug module off the DMI (debug) bus which can act as a
wishbone master to generate read and write cycles.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoAdd a debug (DMI) bus and a JTAG interface to it on Xilinx FPGAs
Benjamin Herrenschmidt [Tue, 10 Sep 2019 16:17:59 +0000 (17:17 +0100)]
Add a debug (DMI) bus and a JTAG interface to it on Xilinx FPGAs

This adds a simple bus that can be mastered from an external
system via JTAG, which will be used to hookup various debug
modules.

It's loosely based on the RiscV model (hence the DMI name).

The module currently only supports hooking up to a Xilinx BSCANE2
but it shouldn't be too hard to adapt it to support different TAPs
if necessary.

The JTAG protocol proper is not exactly the RiscV one at this point,
though I might still change it.

This comes with some sim variants of Xilinx BSCANE2 and BUFG and a
test bench.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoUse a 3 way WB arbiter and cleanup fpga toplevel
Benjamin Herrenschmidt [Tue, 10 Sep 2019 16:03:37 +0000 (17:03 +0100)]
Use a 3 way WB arbiter and cleanup fpga toplevel

The 3rd master is currently unused, it will host the WB debug module.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 years agoMerge pull request #66 from antonblanchard/reformat-4
Anton Blanchard [Thu, 19 Sep 2019 12:49:41 +0000 (22:49 +1000)]
Merge pull request #66 from antonblanchard/reformat-4

More reformatting

4 years agoReformat crhelpers, and remove some stale code
Anton Blanchard [Thu, 19 Sep 2019 11:53:27 +0000 (21:53 +1000)]
Reformat crhelpers, and remove some stale code

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat helpers
Anton Blanchard [Thu, 19 Sep 2019 11:53:09 +0000 (21:53 +1000)]
Reformat helpers

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat insn_helpers
Anton Blanchard [Thu, 19 Sep 2019 11:52:07 +0000 (21:52 +1000)]
Reformat insn_helpers

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #65 from antonblanchard/loadstore-opt
Anton Blanchard [Thu, 19 Sep 2019 11:48:22 +0000 (21:48 +1000)]
Merge pull request #65 from antonblanchard/loadstore-opt

A small loadstore optimisation, and some reformatting

4 years agoReformat loadstore1
Anton Blanchard [Thu, 19 Sep 2019 11:37:43 +0000 (21:37 +1000)]
Reformat loadstore1

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat loadstore2
Anton Blanchard [Thu, 19 Sep 2019 11:36:51 +0000 (21:36 +1000)]
Reformat loadstore2

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoloads don't do both byte reversal and sign extension
Anton Blanchard [Thu, 19 Sep 2019 11:31:34 +0000 (21:31 +1000)]
loads don't do both byte reversal and sign extension

Give the synthesis tools a clue that we don't need to do both byte reversal
and sign extension.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #64 from antonblanchard/reformat-3
Anton Blanchard [Thu, 19 Sep 2019 11:07:31 +0000 (21:07 +1000)]
Merge pull request #64 from antonblanchard/reformat-3

Reformat some more files

4 years agoMerge pull request #63 from antonblanchard/multiply-cleanup
Anton Blanchard [Thu, 19 Sep 2019 10:36:26 +0000 (20:36 +1000)]
Merge pull request #63 from antonblanchard/multiply-cleanup

Multiply cleanup

4 years agoReformat wishbone code
Anton Blanchard [Thu, 19 Sep 2019 10:35:42 +0000 (20:35 +1000)]
Reformat wishbone code

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat glibc_random
Anton Blanchard [Thu, 19 Sep 2019 10:33:58 +0000 (20:33 +1000)]
Reformat glibc_random

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat simple_ram_behavioural
Anton Blanchard [Thu, 19 Sep 2019 10:32:07 +0000 (20:32 +1000)]
Reformat simple_ram_behavioural

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat sim_console
Anton Blanchard [Thu, 19 Sep 2019 10:28:37 +0000 (20:28 +1000)]
Reformat sim_console

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat multiply_tb
Anton Blanchard [Thu, 19 Sep 2019 10:26:55 +0000 (20:26 +1000)]
Reformat multiply_tb

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat execute2
Anton Blanchard [Thu, 19 Sep 2019 10:24:29 +0000 (20:24 +1000)]
Reformat execute2

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat CR file
Anton Blanchard [Thu, 19 Sep 2019 10:22:36 +0000 (20:22 +1000)]
Reformat CR file

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat register file
Anton Blanchard [Thu, 19 Sep 2019 10:21:58 +0000 (20:21 +1000)]
Reformat register file

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoReformat multiply code
Anton Blanchard [Thu, 19 Sep 2019 10:19:46 +0000 (20:19 +1000)]
Reformat multiply code

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoDon't use VHDL 2008 condition operator in multiply
Anton Blanchard [Thu, 19 Sep 2019 10:18:01 +0000 (20:18 +1000)]
Don't use VHDL 2008 condition operator in multiply

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #62 from antonblanchard/byte-reverse-store-opt
Anton Blanchard [Mon, 16 Sep 2019 03:17:37 +0000 (13:17 +1000)]
Merge pull request #62 from antonblanchard/byte-reverse-store-opt

Move byte reversal of stores to first cycle

4 years agoMerge pull request #61 from antonblanchard/execute-cleanup
Anton Blanchard [Mon, 16 Sep 2019 03:14:25 +0000 (13:14 +1000)]
Merge pull request #61 from antonblanchard/execute-cleanup

execute1 no longer needs sim_console

4 years agoMove byte reversal of stores to first cycle
Anton Blanchard [Mon, 16 Sep 2019 01:49:44 +0000 (11:49 +1000)]
Move byte reversal of stores to first cycle

We are seeing some timing issues with the second cycle of loadstore,
and  we aren't doing much in the first cycle, so move it here.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoexecute1 no longer needs sim_console
Anton Blanchard [Mon, 16 Sep 2019 01:18:53 +0000 (11:18 +1000)]
execute1 no longer needs sim_console

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #60 from antonblanchard/testbenches
Anton Blanchard [Sun, 15 Sep 2019 12:52:14 +0000 (22:52 +1000)]
Merge pull request #60 from antonblanchard/testbenches

Add a few more test benches

4 years agoFix multiply_tb
Anton Blanchard [Fri, 13 Sep 2019 10:35:08 +0000 (20:35 +1000)]
Fix multiply_tb

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoAdd an icache testbench
Anton Blanchard [Fri, 13 Sep 2019 10:17:17 +0000 (20:17 +1000)]
Add an icache testbench

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #56 from antonblanchard/writeback-fix3
Anton Blanchard [Sun, 15 Sep 2019 12:08:57 +0000 (22:08 +1000)]
Merge pull request #56 from antonblanchard/writeback-fix3

Remove cycle in writeback

4 years agoRemove cycle in writeback
Anton Blanchard [Sun, 15 Sep 2019 08:03:48 +0000 (18:03 +1000)]
Remove cycle in writeback

The pipeline had a cycle in writeback. Writeback is pretty
simple and unlikely to be a bottleneck, so lets remove it.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoMerge pull request #59 from antonblanchard/trap-decode
Anton Blanchard [Sun, 15 Sep 2019 11:37:47 +0000 (21:37 +1000)]
Merge pull request #59 from antonblanchard/trap-decode

Fix make check

4 years agoMerge pull request #58 from antonblanchard/decode2-assert
Anton Blanchard [Sun, 15 Sep 2019 11:30:30 +0000 (21:30 +1000)]
Merge pull request #58 from antonblanchard/decode2-assert

Fix spurious outstanding assert

4 years agoFix make check
Anton Blanchard [Sun, 15 Sep 2019 11:21:36 +0000 (21:21 +1000)]
Fix make check

We need to finish support for all the trap instructions, but for now
we at least need a decode entry for tw, so we know to stall until the
previous instruction completes. Some of our test cases were failing
because the trap executed before the previous instruction completed.

All these trap instructions need to be resolved at completion, not
in execute.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
4 years agoFix spurious outstanding assert
Anton Blanchard [Sun, 15 Sep 2019 08:59:24 +0000 (18:59 +1000)]
Fix spurious outstanding assert

Check it in the sequential process, not the combinatorial one.

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