⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spdp_cast_comp_top.v.bak

📁 nios里面用自定义指令集来实现三角函数
💻 BAK
📖 第 1 页 / 共 2 页
字号:
//Legal Notice: (C)2007 Altera Corporation. All rights reserved.  Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated documentation or information are
//expressly subject to the terms and conditions of the Altera Program
//License Subscription Agreement or other applicable license agreement,
//including, without limitation, that your use is for the sole purpose
//of programming logic devices manufactured by Altera and sold by Altera
//or its authorized distributors.  Please refer to the applicable
//agreement for further details.

// synthesis translate_off
`timescale 1ns / 1ps
// synthesis translate_on

// turn off superfluous verilog processor warnings 
// altera message_level Level1 
// altera message_off 10034 10035 10036 10037 10230 10240 10030 

// *** casting operations ***
// * -mcustom-ftruncds=        Integer id (N) of ftruncds custom instruction	-- double to float
// * -mcustom-fextsd=          Integer id (N) of fextsd custom instruction		-- float to double

// * -mcustom-fixdu=           Integer id (N) of fixdu custom instruction		-- double to unsigned int
// * -mcustom-fixdi=           Integer id (N) of fixdi custom instruction		-- double to int
//   -mcustom-fixsu=           Integer id (N) of fixsu custom instruction		-- float to unsigned int
//   -mcustom-fixsi=           Integer id (N) of fixsi custom instruction		-- float to int

// * -mcustom-floatud=         Integer id (N) of floatud custom instruction		-- unsigned int to double
// * -mcustom-floatid=         Integer id (N) of floatid custom instruction		-- int to double
//   -mcustom-floatus=         Integer id (N) of floatus custom instruction		-- unsigned int to float
//   -mcustom-floatis=         Integer id (N) of floatis custom instruction		-- int to float

// *** double precision operations ***
// * -mcustom-fcmpned=         Integer id (N) of fcmpned custom instruction
// * -mcustom-fcmpeqd=         Integer id (N) of fcmpeqd custom instruction
// * -mcustom-fcmpged=         Integer id (N) of fcmpged custom instruction
// * -mcustom-fcmpgtd=         Integer id (N) of fcmpgtd custom instruction
// * -mcustom-fcmpled=         Integer id (N) of fcmpled custom instruction
// * -mcustom-fcmpltd=         Integer id (N) of fcmpltd custom instruction

//   -mcustom-flogd=           Integer id (N) of flogd custom instruction
//   -mcustom-fexpd=           Integer id (N) of fexpd custom instruction
//   -mcustom-fatand=          Integer id (N) of fatand custom instruction
//   -mcustom-ftand=           Integer id (N) of ftand custom instruction
//   -mcustom-fsind=           Integer id (N) of fsind custom instruction
//   -mcustom-fcosd=           Integer id (N) of fcosd custom instruction
//   -mcustom-fsqrtd=          Integer id (N) of fsqrtd custom instruction
//   -mcustom-fabsd=           Integer id (N) of fabsd custom instruction
//   -mcustom-fnegd=           Integer id (N) of fnegd custom instruction
//   -mcustom-fmaxd=           Integer id (N) of fmaxd custom instruction
//   -mcustom-fmind=           Integer id (N) of fmind custom instruction

// * -mcustom-fdivd=           Integer id (N) of fdivd custom instruction
// * -mcustom-fmuld=           Integer id (N) of fmuld custom instruction
// * -mcustom-fsubd=           Integer id (N) of fsubd custom instruction
// * -mcustom-faddd=           Integer id (N) of faddd custom instruction

// *** single precision operations ***
//   -mcustom-fcmpnes=         Integer id (N) of fcmpnes custom instruction
//   -mcustom-fcmpeqs=         Integer id (N) of fcmpeqs custom instruction
//   -mcustom-fcmpges=         Integer id (N) of fcmpges custom instruction
//   -mcustom-fcmpgts=         Integer id (N) of fcmpgts custom instruction
//   -mcustom-fcmples=         Integer id (N) of fcmples custom instruction
//   -mcustom-fcmplts=         Integer id (N) of fcmplts custom instruction

//   -mcustom-flogs=           Integer id (N) of flogs custom instruction
//   -mcustom-fexps=           Integer id (N) of fexps custom instruction
//   -mcustom-fatans=          Integer id (N) of fatans custom instruction
//   -mcustom-ftans=           Integer id (N) of ftans custom instruction
//   -mcustom-fsins=           Integer id (N) of fsins custom instruction
//   -mcustom-fcoss=           Integer id (N) of fcoss custom instruction
//   -mcustom-fsqrts=          Integer id (N) of fsqrts custom instruction
//   -mcustom-fabss=           Integer id (N) of fabss custom instruction
//   -mcustom-fnegs=           Integer id (N) of fnegs custom instruction
//   -mcustom-fmaxs=           Integer id (N) of fmaxs custom instruction
//   -mcustom-fmins=           Integer id (N) of fmins custom instruction

// * -mcustom-fdivs=           Integer id (N) of fdivs custom instruction
// * -mcustom-fmuls=           Integer id (N) of fmuls custom instruction
// * -mcustom-fsubs=           Integer id (N) of fsubs custom instruction
// * -mcustom-fadds=           Integer id (N) of fadds custom instruction

// *** double precision utility register manipulations ***
// * -mcustom-frdy=            Integer id (N) of frdy custom instruction
// * -mcustom-frdxhi=          Integer id (N) of frdxhi custom instruction
// * -mcustom-frdxlo=          Integer id (N) of frdxlo custom instruction
// * -mcustom-fwry=            Integer id (N) of fwry custom instruction
// * -mcustom-fwrx=            Integer id (N) of fwrx custom instruction

// current opcode assignments

// -mcustom-ftruncds=0x1B
// -mcustom-fextsd=0x1A
// -mcustom-fixdu=0x19
// -mcustom-fixdi=0x18
// -mcustom-floatud=0x17
// -mcustom-floatid=0x16
// -mcustom-fcmpned=0x15
// -mcustom-fcmpeqd=0x14
// -mcustom-fcmpged=0x13
// -mcustom-fcmpgtd=0x12
// -mcustom-fcmpled=0x11
// -mcustom-fcmpltd=0x10

// -mcustom-fwrx=0xF
// -mcustom-fwry=0xE
// -mcustom-frdxlo=0xC
// -mcustom-frdxhi=0xD
// -mcustom-frdy=0xB
// -mcustom-faddd=0xA
// -mcustom-fsubd=0x9
// -mcustom-fmuld=0x8
// -mcustom-fdivd=0x7
// -mcustom-fadds=0x6
// -mcustom-fsubs=0x5
// -mcustom-fmuls=0x4
// -mcustom-fdivs=0x3
// 0x2 unused
// 0x1 unused
// 0x0 FPU_ID

module SPDP_CAST_COMP_top (
                                            // inputs:
                                             clk,
                                             clk_en,
                                             dataa,
                                             datab,
                                             n,
                                             reset,
                                             start,

                                            // outputs:
                                             done,
                                             result
                                          )
;

localparam MCUSTOM_ftruncds = 5'h1B;
localparam MCUSTOM_fextsd   = 5'h1A;
localparam MCUSTOM_fixdu    = 5'h19;
localparam MCUSTOM_fixdi    = 5'h18;
localparam MCUSTOM_floatud  = 5'h17;
localparam MCUSTOM_floatid  = 5'h16;
localparam MCUSTOM_fcmpned  = 5'h15;
localparam MCUSTOM_fcmpeqd  = 5'h14;
localparam MCUSTOM_fcmpged  = 5'h13;
localparam MCUSTOM_fcmpgtd  = 5'h12;
localparam MCUSTOM_fcmpled  = 5'h11;
localparam MCUSTOM_fcmpltd  = 5'h10;
localparam MCUSTOM_fwrx     = 5'hF;
localparam MCUSTOM_fwry     = 5'hE;
localparam MCUSTOM_frdxhi   = 5'hD;
localparam MCUSTOM_frdxlo   = 5'hC;
localparam MCUSTOM_frdy     = 5'hB;
localparam MCUSTOM_faddd    = 5'hA;
localparam MCUSTOM_fsubd    = 5'h9;
localparam MCUSTOM_fmuld    = 5'h8;
localparam MCUSTOM_fdivd    = 5'h7;
localparam MCUSTOM_fadds    = 5'h6;
localparam MCUSTOM_fsubs    = 5'h5;
localparam MCUSTOM_fmuls    = 5'h4;
localparam MCUSTOM_fdivs    = 5'h3;
localparam MCUSTOM_UNUSED_2 = 5'h2;
localparam MCUSTOM_UNUSED_1 = 5'h1;
localparam MCUSTOM_FPU_ID   = 5'h0;

  output           done;
  output  [ 31: 0] result;
  input            clk;
  input            clk_en;
  input   [ 31: 0] dataa;
  input   [ 31: 0] datab;
  input   [  4: 0] n;
  input            reset;
  input            start;

  reg     [ 63: 0] DATA_reg;
  reg     [  7: 0] OPCODE_reg;
  wire    [  7: 0] OPCODE_reg_mux;
  reg     [ 63: 0] X_reg;
  reg     [ 31: 0] Y_reg;
  wire    [ 31: 0] Y_reg_mux;
  wire             busy_gpo;
  wire             done;
  wire             dp_present_gpo;
  reg              go_ci;
  wire             go_ci_mux;
  wire             op_is_arithmetic;
  wire    [ 31: 0] result;
  wire    [ 63: 0] result_gpo;
  reg              saw_my_start;
  wire             saw_my_start_mux;
  wire             sp_present_gpo;

reg saw_my_start_plus_1;
reg saw_my_start_plus_2;
reg saw_go_ci;
reg busy_gpo_plus_1;
reg busy_gpo_plus_2;
wire do_fixdu_subtract;
wire op_is_logical;
wire saw_go_ci_mux;

  always @(posedge clk or posedge reset)
    begin
      if (reset == 1)
          X_reg <= 0;
      else if (clk_en & start & (n == MCUSTOM_fwrx))
          X_reg <= {datab, dataa};
    end

  assign Y_reg_mux = ((start & (n == MCUSTOM_fwry)))? dataa :
    ((saw_my_start & done & op_is_arithmetic)) ? result_gpo[31 : 0] :
    ((saw_my_start & done & !op_is_arithmetic)) ? (non_arithmetic_result_Y) :
	Y_reg;

  always @(posedge clk or posedge reset)
    begin
      if (reset == 1)
          Y_reg <= 0;
      else if (clk_en)
          Y_reg <= Y_reg_mux;
    end

  always @(posedge clk or posedge reset)
    begin
      if (reset == 1)
          DATA_reg <= 0;
      else if (clk_en & start)
          DATA_reg <= {datab, dataa};
    end

  assign OPCODE_reg_mux = ((n == MCUSTOM_faddd))? (8'h10) :
    ((n == MCUSTOM_fsubd))? (8'h20) :
    ((n == MCUSTOM_fmuld))? (8'h40) :
    ((n == MCUSTOM_fdivd))? (8'h80) :
    ((n == MCUSTOM_fadds))? (8'h01) :
    ((n == MCUSTOM_fsubs))? (8'h02) :

⌨️ 快捷键说明

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