Line 1... |
Line 1... |
///////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Filename: cpudefs.v
|
// Filename: cpudefs.v
|
//
|
//
|
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
//
|
//
|
Line 24... |
Line 24... |
//
|
//
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
Line 38... |
Line 38... |
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
|
// target there if the PDF file isn't present.) If not, see
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
|
//
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// http://www.gnu.org/licenses/gpl.html
|
// http://www.gnu.org/licenses/gpl.html
|
//
|
//
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
//
|
`ifndef CPUDEFS_H
|
`ifndef CPUDEFS_H
|
`define CPUDEFS_H
|
`define CPUDEFS_H
|
//
|
//
|
//
|
//
|
// The first couple options control the Zip CPU instruction set, and how
|
// The first couple options control the Zip CPU instruction set, and how
|
Line 60... |
Line 67... |
// unit. As I'm not there yet, it just catches illegal instructions and
|
// unit. As I'm not there yet, it just catches illegal instructions and
|
// interrupts the CPU on any such instruction--when defined. Otherwise,
|
// interrupts the CPU on any such instruction--when defined. Otherwise,
|
// illegal instructions are quietly ignored and their behaviour is ...
|
// illegal instructions are quietly ignored and their behaviour is ...
|
// undefined. (Many get treated like NOOPs ...)
|
// undefined. (Many get treated like NOOPs ...)
|
//
|
//
|
// I recommend setting this flag, although it can be taken out if area is
|
// I recommend setting this flag so highly, that I'm likely going to remove
|
// critical ...
|
// the option to turn this off in future versions of this CPU.
|
//
|
//
|
`define OPT_ILLEGAL_INSTRUCTION
|
`define OPT_ILLEGAL_INSTRUCTION
|
//
|
//
|
//
|
//
|
//
|
//
|
Line 74... |
Line 81... |
// includes the multiply. (This parameter may still be overridden, as with
|
// includes the multiply. (This parameter may still be overridden, as with
|
// any parameter ...) If the multiply is not included and
|
// any parameter ...) If the multiply is not included and
|
// OPT_ILLEGAL_INSTRUCTION is set, then the multiply will create an illegal
|
// OPT_ILLEGAL_INSTRUCTION is set, then the multiply will create an illegal
|
// instruction that will then trip the illegal instruction trap.
|
// instruction that will then trip the illegal instruction trap.
|
//
|
//
|
|
// Either not defining this value, or defining it to zero will disable the
|
|
// hardware multiply. A value of '1' will cause the multiply to occurr in one
|
|
// clock cycle only--often at the expense of the rest of the CPUs speed.
|
|
// A value of 2 will cause the multiply to have a single delay cycle, 3 will
|
|
// have two delay cycles, and 4 (or more) will have 3 delay cycles.
|
//
|
//
|
`define OPT_MULTIPLY 2
|
//
|
|
`define OPT_MULTIPLY 4
|
//
|
//
|
//
|
//
|
//
|
//
|
// OPT_DIVIDE controls whether or not the divide instruction is built and
|
// OPT_DIVIDE controls whether or not the divide instruction is built and
|
// included into the ZipCPU by default. Set this option and a parameter will
|
// included into the ZipCPU by default. Set this option and a parameter will
|
Line 106... |
Line 119... |
//
|
//
|
// `define OPT_IMPLEMENT_FPU
|
// `define OPT_IMPLEMENT_FPU
|
//
|
//
|
//
|
//
|
//
|
//
|
// OPT_NEW_INSTRUCTION_SET controls whether or not the new instruction set
|
|
// is in use. The new instruction set contains space for floating point
|
|
// operations, signed and unsigned divide instructions, as well as bit reversal
|
|
// and ... at least two other operations yet to be defined. The decoder alone
|
|
// uses about 70 fewer LUTs, although in practice this works out to 12 fewer
|
|
// when all works out in the wash. Further, floating point and divide
|
|
// instructions will cause an illegal instruction exception if they are not
|
|
// implemented--so software capability can be built to use these instructions
|
|
// immediately, even if the hardware is not yet ready.
|
|
//
|
|
// This option is likely to go away in the future, obsoleting the previous
|
|
// instruction set, so I recommend setting this option and switching to the
|
|
// new instruction set as soon as possible.
|
|
//
|
//
|
`define OPT_NEW_INSTRUCTION_SET
|
// The instruction set defines an optional compressed instruction set (CIS)
|
|
// complement. These were at one time erroneously called Very Long Instruction
|
|
// Words. They are more appropriately referred to as compressed instructions.
|
|
// The compressed instruction format allows two instructions to be packed into
|
|
// the same instruction word. Some instructions can be compressed, not all.
|
|
// Compressed instructions take the same time to complete. Set OPT_CIS to
|
|
// include these double instructions as part of the instruction set. These
|
|
// instructions are designed to get more code density from the instruction set,
|
|
// and to hopefully take some pain off of the performance of the pre-fetch and
|
|
// instruction cache.
|
|
//
|
|
// These new instructions, however, also necessitate a change in the Zip
|
|
// CPU--the Zip CPU can no longer execute instructions atomically. It must
|
|
// now execute non-CIS instructions, or CIS instruction pairs, atomically.
|
|
// This logic has been added into the ZipCPU, but it has not (yet) been
|
|
// tested thoroughly.
|
//
|
//
|
|
// Oh, and the debugger and the simulator also need to be updated as well
|
|
// to properly handle these.
|
//
|
//
|
|
// `define OPT_CIS // Adds about 80 LUTs on a Spartan 6
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
//
|
// OPT_SINGLE_FETCH controls whether or not the prefetch has a cache, and
|
// OPT_SINGLE_FETCH controls whether or not the prefetch has a cache, and
|
Line 221... |
Line 239... |
//
|
//
|
`define OPT_PIPELINED_BUS_ACCESS
|
`define OPT_PIPELINED_BUS_ACCESS
|
//
|
//
|
//
|
//
|
//
|
//
|
`ifdef OPT_NEW_INSTRUCTION_SET
|
|
//
|
|
//
|
|
//
|
|
// The new instruction set also defines a set of very long instruction words.
|
|
// Well, calling them "very long" instruction words is probably a misnomer,
|
|
// although we're going to do it. They're really 2x16-bit instructions---
|
|
// instruction words that pack two instructions into one word. (2x14 bit
|
|
// really--'cause you need a bit to note the instruction is a 2x instruction,
|
|
// and then 3-bits for the condition codes ...) Set OPT_VLIW to include these
|
|
// double instructions as part of the new instruction set. These allow a single
|
|
// instruction to contain two instructions within. These instructions are
|
|
// designed to get more code density from the instruction set, and to hopefully
|
|
// take some pain off of the performance of the pre-fetch and instruction cache.
|
|
//
|
|
// These new instructions, however, also necessitate a change in the Zip
|
|
// CPU--the Zip CPU can no longer execute instructions atomically. It must
|
|
// now execute non-VLIW instructions, or VLIW instruction pairs, atomically.
|
|
// This logic has been added into the ZipCPU, but it has not (yet) been
|
|
// tested thoroughly.
|
|
//
|
|
// Oh, and the assembler, the debugger, and the object file dumper, and the
|
|
// simulator all need to be updated as well ....
|
|
//
|
|
`define OPT_VLIW
|
|
//
|
//
|
//
|
//
|
`endif // OPT_NEW_INSTRUCTION_SET
|
|
//
|
//
|
//
|
//
|
`endif // OPT_SINGLE_FETCH
|
`endif // OPT_SINGLE_FETCH
|
//
|
//
|
//
|
//
|