pacoblaze_inc.v
来自「和picoblaze完全兼容的mcu ip core」· Verilog 代码 · 共 819 行 · 第 1/2 页
V
819 行
/*
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 idu_debug_width 32
`define alu_debug_width 27
`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
/** 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"
// interrupt
`define os_enable "enable "
`define os_disable "disable"
/** Conditional flags */
`define flag_z 2'b00 // zero set
`define flag_nz 2'b01 // zero not set
`define flag_c 2'b10 // carry set
`define flag_nc 2'b11 // carry not set
/** Rotate/shift operations */
`define opcode_rsc 2'b11 // shift constant
`define opcode_rsa 2'b00 // shift all (through carry)
`define opcode_rr 2'b10
`define opcode_slx 2'b10
`define opcode_rl 2'b01
`define opcode_srx 2'b01
`ifdef PACOBLAZE1
`define opcode_reg 4'hc // register operation
`define opcode_load 4'h0
`define opcode_add 4'h4
`define opcode_addcy 4'h5
`define opcode_and 4'h1
`define opcode_or 4'h2
`define opcode_rs 4'hd
`define opcode_sub 4'h6
`define opcode_subcy 4'h7
`define opcode_xor 4'h3
`define opcode_ctl 3'b100 // flow control operation: jump, call, return(i), interrupt
`define opcode_jump 2'b01
`define opcode_call 2'b11
`define opcode_return 4'b0010
`define opcode_returni 4'b0011
`define opcode_interrupt 4'b0000
`define opcode_input 3'b101
`define opcode_output 3'b111
`endif // PACOBLAZE1
`ifdef PACOBLAZE2
`define opcode_load 4'h0
`define opcode_add 4'h4
`define opcode_addcy 4'h5
`define opcode_and 4'h1
`define opcode_or 4'h2
`define opcode_rs 4'hc
`define opcode_sub 4'h6
`define opcode_subcy 4'h7
`define opcode_xor 4'h3
`define opcode_jump 4'ha // subop = 1
`define opcode_call 4'hb
`define opcode_return 4'ha // subop = 0
`define opcode_returni 4'he // subop = 0
`define opcode_interrupt 4'he // subop = 1
`define opcode_input 4'h8
`define opcode_output 4'h9
`endif // PACOBLAZE2
`ifdef PACOBLAZE3
`define opcode_add 5'h0c
`define opcode_addcy 5'h0d
`define opcode_and 5'h05
`define opcode_compare 5'h0a
`define opcode_or 5'h06
`define opcode_rs 5'h10
`define opcode_sub 5'h0e
`define opcode_subcy 5'h0f
`define opcode_test 5'h09
`define opcode_xor 5'h07
`define opcode_call 5'h18
`define opcode_interrupt 5'h1e
`define opcode_fetch 5'h03
`define opcode_input 5'h02
`define opcode_jump 5'h1a
`define opcode_load 5'h00
`define opcode_output 5'h16
`define opcode_return 5'h15
`define opcode_returni 5'h1c
`define opcode_store 5'h17
`endif // PACOBLAZE3
`ifdef PACOBLAZE3M
`define opcode_add 5'h0c
`define opcode_addcy 5'h0d
`define opcode_and 5'h05
`define opcode_compare 5'h0a
`define opcode_or 5'h06
`define opcode_rs 5'h10
`define opcode_sub 5'h0e
`define opcode_subcy 5'h0f
`define opcode_test 5'h09
`define opcode_xor 5'h07
`define opcode_call 5'h18
`define opcode_interrupt 5'h1e
`define opcode_fetch 5'h03
`define opcode_input 5'h02
`define opcode_jump 5'h1a
`define opcode_load 5'h00
`define opcode_output 5'h16
`define opcode_return 5'h15
`define opcode_returni 5'h1c
`define opcode_store 5'h17
`define opcode_mul 5'h1f
`define opcode_addw 5'h11
`define opcode_addwcy 5'h12
`define opcode_subw 5'h13
`define opcode_subwcy 5'h14
`endif // PACOBLAZE3M
/** Exploded operations. ALU operations come first as ALU operation subset */
`ifdef PACOBLAZE1
`ifdef USE_ONEHOT_ENCODING
`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
`define ob_load (1<<`op_load)
`define ob_add (1<<`op_add)
`define ob_addcy (1<<`op_addcy)
`define ob_and (1<<`op_and)
`define ob_or (1<<`op_or)
`define ob_rs (1<<`op_rs)
`define ob_sub (1<<`op_sub)
`define ob_subcy (1<<`op_subcy)
`define ob_xor (1<<`op_xor)
`define ob_jump (1<<`op_jump)
`define ob_call (1<<`op_call)
`define ob_return (1<<`op_return)
`define ob_returni (1<<`op_returni)
`define ob_interrupt (1<<`op_interrupt)
`define ob_input (1<<`op_input)
`define ob_output (1<<`op_output)
`else // !USE_ONEHOT_ENCODING
`define op_load `opcode_load
`define op_add `opcode_add
`define op_addcy `opcode_addcy
`define op_and `opcode_and
`define op_or `opcode_or
`define op_rs `opcode_rs
`define op_sub `opcode_sub
`define op_subcy `opcode_subcy
`define op_xor `opcode_xor
`define op_jump `opcode_jump
`define op_call `opcode_call
`define op_return `opcode_return
`define op_returni `opcode_returni
`define op_interrupt `opcode_interrupt
`define op_input `opcode_input
`define op_output `opcode_output
`endif
`endif
`ifdef PACOBLAZE2
`ifdef USE_ONEHOT_ENCODING
`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
`define ob_load (1<<`op_load)
`define ob_add (1<<`op_add)
`define ob_addcy (1<<`op_addcy)
`define ob_and (1<<`op_and)
`define ob_or (1<<`op_or)
`define ob_rs (1<<`op_rs)
`define ob_sub (1<<`op_sub)
`define ob_subcy (1<<`op_subcy)
`define ob_xor (1<<`op_xor)
`define ob_jump (1<<`op_jump)
`define ob_call (1<<`op_call)
`define ob_return (1<<`op_return)
`define ob_returni (1<<`op_returni)
`define ob_interrupt (1<<`op_interrupt)
`define ob_input (1<<`op_input)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?