pacoblaze_inc.v

来自「PacoBlaze is a from-scratch synthesizabl」· Verilog 代码 · 共 657 行 · 第 1/2 页

V
657
字号
/*
	Copyright (c) 2004, 2006 Pablo Bleyer Kocik.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice, this
	list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright notice,
	this list of conditions and the following disclaimer in the documentation
	and/or other materials provided with the distribution.

	3. The name of the author may not be used to endorse or promote products
	derived from this software without specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
	WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
	MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
	EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
	IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

/** @file
	PacoBlaze definitions include file.
*/

`ifndef PACOBLAZE_INC_V_
`define PACOBLAZE_INC_V_

`define HAS_RESET_LATCH
//`define USE_ONEHOT_ENCODING

`ifdef PACOBLAZE3
	`define HAS_INTERRUPT_ACK
	`define HAS_SCRATCH_MEMORY
	`define HAS_COMPARE_OPERATION
	`define HAS_TEST_OPERATION
`endif

`ifdef PACOBLAZE3M
	`define HAS_INTERRUPT_ACK
	`define HAS_SCRATCH_MEMORY
	`define HAS_COMPARE_OPERATION
	`define HAS_TEST_OPERATION
	`define HAS_MUL_OPERATION
	`define HAS_WIDE_ALU
`endif

`ifdef HAS_DEBUG
`define debug_width 32
`endif

`define operand_width 8 ///< Operand width

/** Instruction memory data, address width */
`ifdef PACOBLAZE1
	`define code_width 16
	`define code_depth 8 // 256 instructions
`endif
`ifdef PACOBLAZE2
	`define code_width 18
	`define code_depth 10 // 1024 instructions
`endif
`ifdef PACOBLAZE3
	`define code_width 18
	`define code_depth 10 // 1024 instructions
`endif
`ifdef PACOBLAZE3M
	`define code_width 18
	`define code_depth 10 // 1024 instructions
`endif
`define code_size (1<<`code_depth) ///< Instruction memory size

`define port_width `operand_width ///< Port IO data width
`define port_depth `operand_width ///< Port id (address) width
`define port_size (1<<`port_depth) ///< Port size

`define stack_width `code_depth ///< Call/return stack width
/** Call/return stack depth */
`ifdef PACOBLAZE1
	`define stack_depth 4
`endif
`ifdef PACOBLAZE2
	`define stack_depth 5
`endif
`ifdef PACOBLAZE3
	`define stack_depth 5
`endif
`ifdef PACOBLAZE3M
	`define stack_depth 5
`endif
`define stack_size (1<<`stack_depth) ///< Call/return stack size

`define register_width `operand_width ///< Register file width
/** Register file depth */
`ifdef PACOBLAZE1
	`define register_depth 4
`endif
`ifdef PACOBLAZE2
	`define register_depth 5
`endif
`ifdef PACOBLAZE3
	`define register_depth 4
`endif
`ifdef PACOBLAZE3M
	`define register_depth 4
`endif
`define register_size (1<<`register_depth) ///< Register file size

`ifdef PACOBLAZE3
	`define scratch_width `operand_width ///< Scratchpad ram width
	`define scratch_depth 6 ///< Scratchpad ram depth
	`define scratch_size (1<<`scratch_depth) ///< Scratchpad ram size
`endif
`ifdef PACOBLAZE3M
	`define scratch_width `operand_width ///< Scratchpad ram width
	`define scratch_depth 6 ///< Scratchpad ram depth
	`define scratch_size (1<<`scratch_depth) ///< Scratchpad ram size
`endif

`ifdef USE_ONEHOT_ENCODING

`ifdef PACOBLAZE1
	`define operation_width 16
`endif
`ifdef PACOBLAZE2
	`define operation_width 16
`endif
`ifdef PACOBLAZE3
	`define operation_width 20
`endif
`ifdef PACOBLAZE3M
	`define operation_width (20+5) // mul+addw(cy)+subw(cy)
`endif

`else // !USE_ONEHOT_ENCODING

`ifdef PACOBLAZE1
	`define operation_width 4
`endif
`ifdef PACOBLAZE2
	`define operation_width 4
`endif
`ifdef PACOBLAZE3
	`define operation_width 5
`endif
`ifdef PACOBLAZE3M
	`define operation_width 5
`endif

`endif


`define reset_vector 0 ///< Reset vector
`define interrupt_vector (`code_size-1) ///< Interrupt vector

/** Exploded operations */
`ifdef USE_ONEHOT_ENCODING
// PB1,2,3
`define op_load (1<<0)
`define op_add (1<<1)
`define op_addcy (1<<2)
`define op_and (1<<3)
`define op_or (1<<4)
`define op_rs (1<<5)
`define op_sub (1<<6)
`define op_subcy (1<<7)
`define op_xor (1<<8)
`define op_jump (1<<9)
`define op_call (1<<10)
`define op_return (1<<11)
`define op_returni (1<<12)
`define op_interrupt (1<<13)
`define op_input (1<<14)
`define op_output (1<<15)
// PB3
`define op_compare (1<<16)
`define op_test (1<<17)
`define op_fetch (1<<18)
`define op_store (1<<19)

`ifdef PACOBLAZE3M
`define op_mul (1<<20)
`define op_addw (1<<21)
`define op_subw (1<<22)
`define op_addwcy (1<<23)
`define op_subwcy (1<<24)
`endif

`else

`ifdef PACOBLAZE1
`define op_load 'h0
`define op_add 'h1
`define op_addcy 'h2
`define op_and 'h3
`define op_or 'h4
`define op_rs 'h5
`define op_sub 'h6
`define op_subcy 'h7
`define op_xor 'h8
`define op_jump 'h9
`define op_call 'ha
`define op_return 'hb
`define op_returni 'hc
`define op_interrupt 'hd
`define op_input 'he
`define op_output 'hf
`endif
`ifdef PACOBLAZE2
`define op_load 'h0
`define op_add 'h1
`define op_addcy 'h2
`define op_and 'h3
`define op_or 'h4
`define op_rs 'h5
`define op_sub 'h6
`define op_subcy 'h7
`define op_xor 'h8
`define op_jump 'h9
`define op_call 'ha
`define op_return 'hb
`define op_returni 'hc
`define op_interrupt 'hd
`define op_input 'he
`define op_output 'hf
`endif
`ifdef PACOBLAZE3
`define op_load 'h0
`define op_add 'hc
`define op_addcy 'hd
`define op_and 'h5
`define op_or 'h6
`define op_rs 'h10
`define op_sub 'he
`define op_subcy 'hf
`define op_xor 'h7
`define op_jump 'h1a
`define op_call 'h18
`define op_return 'h15
`define op_returni 'h1c
`define op_interrupt 'h1e
`define op_input 'h2
`define op_output 'h16
`define op_compare 'ha
`define op_test 'h9
`define op_fetch 'h3
`define op_store 'h17
`endif
`ifdef PACOBLAZE3M
`define op_load 'h0
`define op_add 'hc
`define op_addcy 'hd
`define op_and 'h5
`define op_or 'h6
`define op_rs 'h10
`define op_sub 'he
`define op_subcy 'hf
`define op_xor 'h7
`define op_jump 'h1a
`define op_call 'h18
`define op_return 'h15
`define op_returni 'h1c
`define op_interrupt 'h1e
`define op_input 'h2
`define op_output 'h16
`define op_compare 'ha
`define op_test 'h9
`define op_fetch 'h3
`define op_store 'h17
`define op_mul 'h1f
`define op_addw 'h11
`define op_addwcy 'h12
`define op_subw 'h13
`define op_subwcy 'h14
`endif
`endif // !USE_ONEHOT_ENCODING

/** Operation string names */
`define os_load "load"
`define os_add "add"
`define os_addcy "addcy"
`define os_and "and"
`define os_or "or"
`define os_rs "rs"
	`define os_sr0 "sr0"
	`define os_sr1 "sr1"
	`define os_srx "srx"
	`define os_sra "sra"
	`define os_rr "rr"
	`define os_sl0 "sl0"
	`define os_sl1 "sl1"
	`define os_slx "slx"
	`define os_sla "sla"
	`define os_rl "rl"
`define os_sub "sub"
`define os_subcy "subcy"
`define os_xor "xor"
`define os_jump "jump"
`define os_call "call"
`define os_return "return"
`define os_returni "returni"
`define os_interrupt "interrupt"
`define os_input "input"
`define os_output "output"
`define os_invalid "(n/a)"
// PB3
`define os_compare "compare"
`define os_test "test"
`define os_fetch "fetch"
`define os_store "store"
// PB3M
`define os_mul "mul"
`define os_addw "addw"
`define os_addwcy "addwcy"
`define os_subw "subw"
`define os_subwcy "subwcy"

// flags
`define os_z "z "
`define os_nz "nz"
`define os_c "c "
`define os_nc "nc"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?