DSP48E1 (primitive)原语例化实例

2024-04-04 18:18

本文主要是介绍DSP48E1 (primitive)原语例化实例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

DSP48E1 (primitive)原语例化实例

之前倒腾dsp48e1的时候发现网上虽然有一些文章,但是大部分都是无用的文章,

正如某位同仁说的,高手都忙于泡妞,哪有精力来写文章,

把之前倒腾的代码贴出来供大家参考。

先把OPMODE和ALUMODE贴上,来自网上的文章

OPMODE用来决定下面这个图X,Y,Z这些mux的选择,一时半会看不懂,稍微花点时间是可以看懂的

上图有两个X,圆圈里面的那个X是乘法,输出就是下面表格里的M,右边的这个X才是下面表格里的MUX X

Z

OPMODE[6:4]

Y

OPMODE[3:2]

X

OPMODE[1:0]

X

Multiplexer Output

Notes

xxx

xx

00

0

Default

xxx

01

01

M

Must select with

OPMODE[3:2] = 01

xxx

xx

10

P

Must select with PREG = 1

xxx

xx

11

A:B

48 bits wide

这个表格表示X选择

可以选择M,P或者A:B,

01选M,10选P,11选A:B

Z

OPMODE[6:4]

Y

OPMODE[3:2]

X

OPMODE[1:0]

Y

Multiplexer Output

Notes

xxx

00

xx

0

Default

xxx

01

01

M

Must select with

OPMODE[1:0] = 01

xxx

10

xx

48'FFFFFFFFFFFF

Used mainly for logic unit

bitwise operations on the X and

Z multiplexers

xxx

11

xx

C

这个表格表示Y的选择,

Z

OPMODE[6:4]

Y

OPMODE[3:2]

X

OPMODE[1:0]

Z

Multiplexer Output

Notes

000

xx

xx

0

Default

001

xx

xx

PCIN

010

xx

xx

P

Must select with PREG = 1

011

xx

xx

C

100

10

00

P

Use for MACC extend only.

Must select with PREG = 1

101

xx

xx

17-bit Shift (PCIN)

110

xx

xx

17-bit Shift (P)

Must select with PREG = 1

111

xx

xx

xx

Illegal selection

这个表格表示Z的选择

ALUMODE

4ALUMODE控制第二阶段加//逻辑单元的行为。

ALUMODE = 0000 选择表单Z + (X + Y)的添加操作。

ALUMODE = 0011 选择Z - (X + Y )形式的减运算。

ALUMODE = 0001 可以实现- z + (X + Y) - 1 = not (Z) + X + Y

ALUMODE = 0010 可以实现 - (Z + X + Y) - 1 = not (Z + X + Y)

2的补数的负数是通过按位反转和加1得到的,例如-k = not (k) + 1

INMODE暂时还没试验过

INMODE[3]

INMODE[2]

INMODE[1]

INMODE[0]

USE_DPORT

Multiplier A Port

0

0

0

0

FALSE

A2

0

0

0

1

FALSE

A1

0

0

1

0

FALSE

Zero

0

0

1

1

FALSE

Zero

0

0

0

0

TRUE

A2

0

0

0

1

TRUE

A1

0

0

1

0

TRUE

Zero

0

0

1

1

TRUE

Zero

0

1

0

0

TRUE

D + A2(1)

0

1

0

1

TRUE

D + A1(1)

0

1

1

0

TRUE

D

0

1

1

1

TRUE

D

1

0

0

0

TRUE

-A2

1

0

0

1

TRUE

-A1

1

0

1

0

TRUE

Zero

1

0

1

1

TRUE

Zero

1

1

0

0

TRUE

D – A2(1)

1

1

0

1

TRUE

D – A1(1)

1

1

1

0

TRUE

D

1

1

1

1

TRUE

D

INMODE[4]

Multiplier B Port

0

B2

1

B1

之前尝试例化dsp48e1的时候,google百度都解决不了问题,直接拿dsp48e1的代码来仿,这样还更快一点,

为了节省大家的时间,我把DSP48E1的仿真工程放到github里,大家可以下载下来调试,

https://github.com/tishi43/dsp48e1

加了如下中间变量的打印,如果结果不如预期,可以观察这些变量,继续跟踪哪步结果异常,

a_o_mux根据A_INPUT=DIRECT还是CASCADE 选择a_in,还是acin_in

qd_o_mux 根据DREG,选择d_in还是延迟一周期的d_in

ad_addsub, 顾名思义,就是选择A+D,还是A-D

直接上代码更直观一点

assign ad_addsub = qinmode_o_mux[3]?(-a_preaddsub + (qinmode_o_mux[2]?qd_o_mux:25'b0)):(a_preaddsub + (qinmode_o_mux[2]?qd_o_mux:25'b0));

qad_o_mux 根据ADREG=0还是1,选择ad_addsub还是延迟一周期的ad_addsub

mult_o就是上面图中(A+D)*B的结果,即M

qopmode_o_mux,根据OPMODEREG,选择opmode_in还是延迟1周期的opmode_in

qx_o_mux,上图中X的选择,选择M,还是A:B,还是P

alu_o差不多最终的结果了,直接看代码更容易理解

qp_o_mux,根据PREG选择alu_o还是alu_o延迟1周期

qc_o_mux,根据CREG选择c_in还是c_in延迟1周期

qz_o_mux,第三个表格中Z的选择

下面是之前我调试时的打印,把.USE_DPORT误设为TRUE时,结果为0,可以看到mult_o这一步为0了,再跟着代码拉几根信号到波形窗口,就发现问题了,

run 1us

#                    0 a_o_mux[24:0]        x

#                    0 ADREG1 qad_o_mux        0

#                    0 ALU qx_o_mux               x qx_o_mux               x qz_o_mux               0

#                    0 qopmode_o_mux[1:0] 1 qx_o_mux               x

#                    0 ALU qx_o_mux               x qx_o_mux               0 qz_o_mux               0

#               200000 a_o_mux[24:0]      100

#               200000 ad_addsub[24:0]      100 qinmode_o_mux[3] 0 a_preaddsub[24:0]      100 qinmode_o_mux[2] 0 qd_o_mux[24:0]        0

#               200000 a_preaddsub[24:0]      100 qinmode_o_mux[1] 0 qinmode_o_mux[0] 0 qa_o_reg1[24:0]        0 qa_o_mux[24:0]      100

#               200000 qopmode_o_mux[1:0] 1 qx_o_mux               x

#               200000 mult_o             0

#               200000 qopmode_o_mux[1:0] 1 qx_o_mux               x

#               200000 ALU qx_o_mux               0 qx_o_mux               0 qz_o_mux               0

#               200000 alu_o               0

#               200001 qopmode_o_mux[1:0] 1 qx_o_mux               0

# p                0

不求弄清每种组合会是什么情况,只求最常用的一些用法,如下

1   assgin o=in1*in2 立即出结果

AREG,BREG,MREG,PREG设0

CREG,DREG,ADREG实际没有用到,这些设为1其实也无意义

CLK脚可以填0,也可以填实际时钟

ALUMODE=0

OPMODE=7'b0000101


`timescale 1ns / 10ps // timescale time_unit/time_presicionmodule test(input wire clk,input wire rst,input wire signed [24:0] in1,input wire signed [17:0] in2,output wire signed [47:0]  o,output wire signed [29:0] acout,output wire signed [17:0] bcout,output wire [3:0] carryout,output wire [3:0] carrycasout,output wire signed [47:0] pcout);DSP48E1 #(.A_INPUT("DIRECT"),.B_INPUT("DIRECT"),.USE_DPORT("FALSE"),.USE_MULT("MULTIPLY"),       .USE_SIMD("ONE48"),               .AUTORESET_PATDET("NO_RESET"),    // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH".MASK(48'h3fffffffffff),          // 48-bit mask value for pattern detect (1=ignore).PATTERN(48'h000000000000),       // 48-bit pattern match for pattern detect.SEL_MASK("MASK"),           // "C", "MASK", "ROUNDING_MODE1", "ROUNDING_MODE2".SEL_PATTERN("PATTERN"),          // Select pattern value ("PATTERN" or "C").USE_PATTERN_DETECT("NO_PATDET"),  // Enable pattern detect ("PATDET" or "NO_PATDET")// Register Control Attributes: Pipeline Register Configuration.ACASCREG(0),            //.ADREG(1),               // Number of pipeline stages for pre-adder (0 or 1).ALUMODEREG(0),          // Number of pipeline stages for ALUMODE (0 or 1).AREG(0),                 // Number of pipeline stages for A (0, 1 or 2)  .BCASCREG(0),            // Number of pipeline stages between B/BCIN and BCOUT (0, 1 or 2).BREG(0),                         // Number of pipeline stages for B (0, 1 or 2).CARRYINREG(0),                   // Number of pipeline stages for CARRYIN (0 or 1).CARRYINSELREG(0),                // Number of pipeline stages for CARRYINSEL (0 or 1).CREG(1),                         // Number of pipeline stages for C (0 or 1).DREG(1),                         // Number of pipeline stages for D (0 or 1).INMODEREG(0),                    // Number of pipeline stages for INMODE (0 or 1).MREG(0),                         // Number of multiplier pipeline stages (0 or 1)  .OPMODEREG(0),                    // Number of pipeline stages for OPMODE (0 or 1).PREG(0)                          // Number of pipeline stages for P (0 or 1))DSP48E1_inst (// Cascade: 30-bit (each) output: Cascade Ports.ACOUT(acout),                   // 30-bit output: A port cascade output.BCOUT(bcout),                   // 18-bit output: B port cascade output.CARRYCASCOUT(carrycasout),     // 1-bit output: Cascade carry output.MULTSIGNOUT(),       // 1-bit output: Multiplier sign cascade output.PCOUT(pcout),                   // 48-bit output: Cascade output//这些引脚空着就好// Control: 1-bit (each) output: Control Inputs/Status Bits.OVERFLOW(),             // 1-bit output: Overflow in add/acc output.PATTERNBDETECT(),        // 1-bit output: Pattern bar detect output.PATTERNDETECT(),   // 1-bit output: Pattern detect output.UNDERFLOW(),           // 1-bit output: Underflow in add/acc output//这些引脚也空着,没用// Data: 4-bit (each) output: Data Ports.CARRYOUT(carryout),                               // 4-bit output: Carry output.P(o),                           // 48-bit output: Primary data output//P输出48bit的// Cascade: 30-bit (each) input: Cascade Ports.ACIN(30'b0),                     // 30-bit input: A cascade data input.BCIN(18'b0),                     // 18-bit input: B cascade input.CARRYCASCIN(1'b0),              // 1-bit input: Cascade carry input.MULTSIGNIN(1'b0),         // 1-bit input: Multiplier sign input.PCIN(48'b0),                     // 48-bit input: P cascade input//这些引脚很重要,做流水线时,数据又这几个引脚输入。// Control: 4-bit (each) input: Control Inputs/Status Bits.ALUMODE(4'b0),               // 4-bit input: ALU control input.CARRYINSEL(3'b0),         // 3-bit input: Carry select input.CLK(0),                       // 1-bit input: Clock input               .INMODE(5'b0),                 // 5-bit input: INMODE control input.OPMODE(7'b0000101),                 // 7-bit input: Operation mode input// Data: 30-bit (each) input: Data Ports.A(in1),                           // 30-bit input: A data input.B(in2),                           // 18-bit input: B data input.C(48'hffffffffffff),              // 48-bit input: C data input.CARRYIN(1'b0),                      // 1-bit input: Carry input signal.D(25'b0),                           // 25-bit input: D data input// Reset/Clock Enable: 1-bit (each) input: Reset/Clock Enable Inputs.CEA1(1'b0),                      // 1-bit input: Clock enable input for 1st stage AREG.CEA2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage AREG.CEAD(1'b0),                      // 1-bit input: Clock enable input for ADREG.CEALUMODE(1'b0),                 // 1-bit input: Clock enable input for ALUMODE.CEB1(1'b0),                      // 1-bit input: Clock enable input for 1st stage BREG.CEB2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage BREG.CEC(1'b0),                       // 1-bit input: Clock enable input for CREG.CECARRYIN(1'b0),                 // 1-bit input: Clock enable input for CARRYINREG.CECTRL(1'b0),                    // 1-bit input: Clock enable input for OPMODEREG and CARRYINSELREG.CED(1'b0),                       // 1-bit input: Clock enable input for DREG.CEINMODE(1'b0),                  // 1-bit input: Clock enable input for INMODEREG.CEM(1'b0),                       // 1-bit input: Clock enable input for MREG.CEP(1'b0),                       // 1-bit input: Clock enable input for PREG.RSTA(1'b0),                       // 1-bit input: Reset input for AREG.RSTALLCARRYIN(1'b0),              // 1-bit input: Reset input for CARRYINREG.RSTALUMODE(1'b0),                 // 1-bit input: Reset input for ALUMODEREG.RSTB(1'b0),                       // 1-bit input: Reset input for BREG.RSTC(1'b0),                       // 1-bit input: Reset input for CREG.RSTCTRL(1'b0),                    // 1-bit input: Reset input for OPMODEREG and CARRYINSELREG.RSTD(1'b0),                       // 1-bit input: Reset input for DREG and ADREG.RSTINMODE(1'b0),                  // 1-bit input: Reset input for INMODEREG.RSTM(1'b0),                       // 1-bit input: Reset input for MREG.RSTP(1'b0)                        // 1-bit input: Reset input for PREG);endmodulemodule bitstream_tb;reg rst;reg dec_clk;reg signed [24:0] a;reg signed [17:0] b;reg signed [47:0] d;reg signed [47:0] c;wire signed [47:0] p;wire signed [29:0] ac;wire signed [17:0] bc;wire [3:0] co;wire [3:0] ccas;wire signed [47:0] pc;initial beginrst = 0;#200 a = 100;#0 b = 200;#0 d = 45;#0 c = 400;#50 rst = 1;#1 rst = 0;#100 $display("p %d",p);endalwaysbegin#1 dec_clk = 0;#1 dec_clk = 1;endtest test_inst(.clk(dec_clk),.rst(rst),.in1(a),.in2(b),.o(p),.acout(ac),.bcout(bc),.carryout(co),.carrycasout(ccas),.pcout(pc));endmodule

2  o <=in1*in2 延迟1周期出结果

和上面的唯一区别仅仅是是MREG=1,CEM=1,

注意CEM一定要等于1,否则结果是0

同样如果AREG=1, CEA要等于1,clock enable一定要相应置起来

延迟周期,也可以选择AREG,PREG这些,或者这些的组合,延迟多周期


`timescale 1ns / 10ps // timescale time_unit/time_presicionmodule test(input wire clk,input wire rst,input wire signed [24:0] in1,input wire signed [17:0] in2,output wire signed [47:0]  o,output wire signed [29:0] acout,output wire signed [17:0] bcout,output wire [3:0] carryout,output wire [3:0] carrycasout,output wire signed [47:0] pcout);DSP48E1 #(.A_INPUT("DIRECT"),.B_INPUT("DIRECT"),.USE_DPORT("FALSE"),.USE_MULT("MULTIPLY"),.USE_SIMD("ONE48"),.AUTORESET_PATDET("NO_RESET"),    // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH".MASK(48'h3fffffffffff),          // 48-bit mask value for pattern detect (1=ignore).PATTERN(48'h000000000000),       // 48-bit pattern match for pattern detect.SEL_MASK("MASK"),           // "C", "MASK", "ROUNDING_MODE1", "ROUNDING_MODE2".SEL_PATTERN("PATTERN"),          // Select pattern value ("PATTERN" or "C").USE_PATTERN_DETECT("NO_PATDET"),  // Enable pattern detect ("PATDET" or "NO_PATDET")// Register Control Attributes: Pipeline Register Configuration.ACASCREG(0),            //.ADREG(1),               // Number of pipeline stages for pre-adder (0 or 1).ALUMODEREG(0),          // Number of pipeline stages for ALUMODE (0 or 1).AREG(0),                 // Number of pipeline stages for A (0, 1 or 2)  .BCASCREG(0),            // Number of pipeline stages between B/BCIN and BCOUT (0, 1 or 2).BREG(0),                         // Number of pipeline stages for B (0, 1 or 2).CARRYINREG(0),                   // Number of pipeline stages for CARRYIN (0 or 1).CARRYINSELREG(0),                // Number of pipeline stages for CARRYINSEL (0 or 1).CREG(1),                         // Number of pipeline stages for C (0 or 1).DREG(1),                         // Number of pipeline stages for D (0 or 1).INMODEREG(0),                    // Number of pipeline stages for INMODE (0 or 1).MREG(1),                         // Number of multiplier pipeline stages (0 or 1)  .OPMODEREG(0),                    // Number of pipeline stages for OPMODE (0 or 1).PREG(0)                          // Number of pipeline stages for P (0 or 1))DSP48E1_inst (// Cascade: 30-bit (each) output: Cascade Ports.ACOUT(acout),                   // 30-bit output: A port cascade output.BCOUT(bcout),                   // 18-bit output: B port cascade output.CARRYCASCOUT(carrycasout),     // 1-bit output: Cascade carry output.MULTSIGNOUT(),       // 1-bit output: Multiplier sign cascade output.PCOUT(pcout),                   // 48-bit output: Cascade output//这些引脚空着就好// Control: 1-bit (each) output: Control Inputs/Status Bits.OVERFLOW(),             // 1-bit output: Overflow in add/acc output.PATTERNBDETECT(),        // 1-bit output: Pattern bar detect output.PATTERNDETECT(),   // 1-bit output: Pattern detect output.UNDERFLOW(),           // 1-bit output: Underflow in add/acc output//这些引脚也空着,没用// Data: 4-bit (each) output: Data Ports.CARRYOUT(carryout),                               // 4-bit output: Carry output.P(o),                           // 48-bit output: Primary data output//P输出48bit的// Cascade: 30-bit (each) input: Cascade Ports.ACIN(30'b0),                     // 30-bit input: A cascade data input.BCIN(18'b0),                     // 18-bit input: B cascade input.CARRYCASCIN(1'b0),              // 1-bit input: Cascade carry input.MULTSIGNIN(1'b0),         // 1-bit input: Multiplier sign input.PCIN(48'b0),                     // 48-bit input: P cascade input//这些引脚很重要,做流水线时,数据又这几个引脚输入。// Control: 4-bit (each) input: Control Inputs/Status Bits.ALUMODE(4'b0),               // 4-bit input: ALU control input.CARRYINSEL(3'b0),         // 3-bit input: Carry select input.CLK(clk),                       // 1-bit input: Clock input       .INMODE(5'b0),                 // 5-bit input: INMODE control input.OPMODE(7'b0000101),                 // 7-bit input: Operation mode input// Data: 30-bit (each) input: Data Ports.A(in1),                           // 30-bit input: A data input.B(in2),                           // 18-bit input: B data input.C(48'hffffffffffff),              // 48-bit input: C data input.CARRYIN(1'b0),                      // 1-bit input: Carry input signal.D(25'b0),                           // 25-bit input: D data input// Reset/Clock Enable: 1-bit (each) input: Reset/Clock Enable Inputs.CEA1(1'b0),                      // 1-bit input: Clock enable input for 1st stage AREG.CEA2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage AREG.CEAD(1'b0),                      // 1-bit input: Clock enable input for ADREG.CEALUMODE(1'b0),                 // 1-bit input: Clock enable input for ALUMODE.CEB1(1'b0),                      // 1-bit input: Clock enable input for 1st stage BREG.CEB2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage BREG.CEC(1'b0),                       // 1-bit input: Clock enable input for CREG.CECARRYIN(1'b0),                 // 1-bit input: Clock enable input for CARRYINREG.CECTRL(1'b0),                    // 1-bit input: Clock enable input for OPMODEREG and CARRYINSELREG.CED(1'b0),                       // 1-bit input: Clock enable input for DREG.CEINMODE(1'b0),                  // 1-bit input: Clock enable input for INMODEREG.CEM(1'b1),                       // 1-bit input: Clock enable input for MREG.CEP(1'b0),                       // 1-bit input: Clock enable input for PREG.RSTA(1'b0),                       // 1-bit input: Reset input for AREG.RSTALLCARRYIN(1'b0),              // 1-bit input: Reset input for CARRYINREG.RSTALUMODE(1'b0),                 // 1-bit input: Reset input for ALUMODEREG.RSTB(1'b0),                       // 1-bit input: Reset input for BREG.RSTC(1'b0),                       // 1-bit input: Reset input for CREG.RSTCTRL(1'b0),                    // 1-bit input: Reset input for OPMODEREG and CARRYINSELREG.RSTD(1'b0),                       // 1-bit input: Reset input for DREG and ADREG.RSTINMODE(1'b0),                  // 1-bit input: Reset input for INMODEREG.RSTM(1'b0),                       // 1-bit input: Reset input for MREG.RSTP(1'b0)                        // 1-bit input: Reset input for PREG);endmodulemodule bitstream_tb;reg rst;reg dec_clk;reg signed [24:0] a;reg signed [17:0] b;reg signed [47:0] d;reg signed [47:0] c;wire signed [47:0] p;wire signed [29:0] ac;wire signed [17:0] bc;wire [3:0] co;wire [3:0] ccas;wire signed [47:0] pc;initial beginrst = 0;#200 a = 100;#0 b = 200;#0 d = 45;#0 c = 400;#50 rst = 1;#1 rst = 0;#100 $display("p %d",p);endalwaysbegin#1 dec_clk = 0;#1 dec_clk = 1;endtest test_inst(.clk(dec_clk),.rst(rst),.in1(a),.in2(b),.o(p),.acout(ac),.bcout(bc),.carryout(co),.carrycasout(ccas),.pcout(pc));endmodule

3  o <= in1*in2+c

OPMODE=7'b0110101


`timescale 1ns / 10ps // timescale time_unit/time_presicionmodule test(input wire clk,input wire rst,input wire signed [24:0] in1,input wire signed [17:0] in2,input wire signed [47:0] c,output wire signed [47:0]  o,output wire signed [29:0] acout,output wire signed [17:0] bcout,output wire [3:0] carryout,output wire [3:0] carrycasout,output wire signed [47:0] pcout);DSP48E1 #(.A_INPUT("DIRECT"),.B_INPUT("DIRECT"),.USE_DPORT("FALSE"),.USE_MULT("MULTIPLY"),       .USE_SIMD("ONE48"),               .AUTORESET_PATDET("NO_RESET"),    // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH".MASK(48'h3fffffffffff),          // 48-bit mask value for pattern detect (1=ignore).PATTERN(48'h000000000000),       // 48-bit pattern match for pattern detect.SEL_MASK("MASK"),           // "C", "MASK", "ROUNDING_MODE1", "ROUNDING_MODE2".SEL_PATTERN("PATTERN"),          // Select pattern value ("PATTERN" or "C").USE_PATTERN_DETECT("NO_PATDET"),  // Enable pattern detect ("PATDET" or "NO_PATDET")// Register Control Attributes: Pipeline Register Configuration.ACASCREG(0),            //.ADREG(1),               // Number of pipeline stages for pre-adder (0 or 1).ALUMODEREG(0),          // Number of pipeline stages for ALUMODE (0 or 1).AREG(0),                 // Number of pipeline stages for A (0, 1 or 2)  .BCASCREG(0),            // Number of pipeline stages between B/BCIN and BCOUT (0, 1 or 2).BREG(0),                         // Number of pipeline stages for B (0, 1 or 2).CARRYINREG(0),                   // Number of pipeline stages for CARRYIN (0 or 1).CARRYINSELREG(0),                // Number of pipeline stages for CARRYINSEL (0 or 1).CREG(0),                         // Number of pipeline stages for C (0 or 1).DREG(0),                         // Number of pipeline stages for D (0 or 1).INMODEREG(1),                    // Number of pipeline stages for INMODE (0 or 1).MREG(0),                         // Number of multiplier pipeline stages (0 or 1).OPMODEREG(0),                    // Number of pipeline stages for OPMODE (0 or 1).PREG(1)                          // Number of pipeline stages for P (0 or 1))DSP48E1_inst (// Cascade: 30-bit (each) output: Cascade Ports.ACOUT(acout),                   // 30-bit output: A port cascade output.BCOUT(bcout),                   // 18-bit output: B port cascade output.CARRYCASCOUT(carrycasout),     // 1-bit output: Cascade carry output.MULTSIGNOUT(),       // 1-bit output: Multiplier sign cascade output.PCOUT(pcout),                   // 48-bit output: Cascade output//这些引脚空着就好// Control: 1-bit (each) output: Control Inputs/Status Bits.OVERFLOW(),             // 1-bit output: Overflow in add/acc output.PATTERNBDETECT(),        // 1-bit output: Pattern bar detect output.PATTERNDETECT(),   // 1-bit output: Pattern detect output.UNDERFLOW(),           // 1-bit output: Underflow in add/acc output//这些引脚也空着,没用// Data: 4-bit (each) output: Data Ports.CARRYOUT(carryout),                               // 4-bit output: Carry output.P(o),                           // 48-bit output: Primary data output//P输出48bit的// Cascade: 30-bit (each) input: Cascade Ports.ACIN(30'b0),                     // 30-bit input: A cascade data input.BCIN(18'b0),                     // 18-bit input: B cascade input.CARRYCASCIN(1'b0),              // 1-bit input: Cascade carry input.MULTSIGNIN(1'b0),         // 1-bit input: Multiplier sign input.PCIN(48'b0),                     // 48-bit input: P cascade input//这些引脚很重要,做流水线时,数据又这几个引脚输入。// Control: 4-bit (each) input: Control Inputs/Status Bits.ALUMODE(4'b0),               // 4-bit input: ALU control input.CARRYINSEL(3'b0),         // 3-bit input: Carry select input.CLK(clk),                       // 1-bit input: Clock input.INMODE(5'b0),                 // 5-bit input: INMODE control input.OPMODE(7'b0110101),                 // 7-bit input: Operation mode input// Data: 30-bit (each) input: Data Ports.A(in1),                           // 30-bit input: A data input.B(in2),                           // 18-bit input: B data input//.C(48'hffffffffffff),              // 48-bit input: C data input.C(c),              // 48-bit input: C data input.CARRYIN(1'b0),                      // 1-bit input: Carry input signal.D(25'b0),                           // 25-bit input: D data input// Reset/Clock Enable: 1-bit (each) input: Reset/Clock Enable Inputs.CEA1(1'b0),                      // 1-bit input: Clock enable input for 1st stage AREG.CEA2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage AREG.CEAD(1'b0),                      // 1-bit input: Clock enable input for ADREG.CEALUMODE(1'b0),                 // 1-bit input: Clock enable input for ALUMODE.CEB1(1'b0),                      // 1-bit input: Clock enable input for 1st stage BREG.CEB2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage BREG.CEC(1'b0),                       // 1-bit input: Clock enable input for CREG.CECARRYIN(1'b0),                 // 1-bit input: Clock enable input for CARRYINREG.CECTRL(1'b0),                    // 1-bit input: Clock enable input for OPMODEREG and CARRYINSELREG.CED(1'b0),                       // 1-bit input: Clock enable input for DREG.CEINMODE(1'b0),                  // 1-bit input: Clock enable input for INMODEREG.CEM(1'b0),                       // 1-bit input: Clock enable input for MREG.CEP(1'b1),                       // 1-bit input: Clock enable input for PREG.RSTA(rst),.RSTALLCARRYIN(rst),.RSTALUMODE(rst),.RSTB(rst),.RSTC(rst),.RSTCTRL(rst),.RSTD(rst),.RSTINMODE(rst),.RSTM(rst),.RSTP(rst));endmodulemodule bitstream_tb;reg rst;reg dec_clk;reg signed [24:0] a;reg signed [17:0] b;reg signed [47:0] d;reg signed [47:0] c;wire signed [47:0] p;wire signed [29:0] ac;wire signed [17:0] bc;wire [3:0] co;wire [3:0] ccas;wire signed [47:0] pc;initial beginrst = 0;#200 a = 100;#0 b = 200;#0 d = 45;#0 c = 400;#50 rst = 1;#1 rst = 0;#100 $display("p %d",p);endalwaysbegin#1 dec_clk = 0;#1 dec_clk = 1;endtest test_inst(.clk(dec_clk),.rst(rst),.in1(a),.in2(b),.c(c),.o(p),.acout(ac),.bcout(bc),.carryout(co),.carrycasout(ccas),.pcout(pc));endmodule

4  o <= c-in1*in2

和o <= in1*in2+c的区别是ALUMODE选0011

`timescale 1ns / 10ps // timescale time_unit/time_presicionmodule test(input wire clk,input wire rst,input wire signed [24:0] in1,input wire signed [17:0] in2,input wire signed [47:0] c,output wire signed [47:0]  o,output wire signed [29:0] acout,output wire signed [17:0] bcout,output wire [3:0] carryout,output wire [3:0] carrycasout,output wire signed [47:0] pcout);DSP48E1 #(.A_INPUT("DIRECT"),.B_INPUT("DIRECT"),.USE_DPORT("FALSE"),.USE_MULT("MULTIPLY"),       .USE_SIMD("ONE48"),               .AUTORESET_PATDET("NO_RESET"),    // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH".MASK(48'h3fffffffffff),          // 48-bit mask value for pattern detect (1=ignore).PATTERN(48'h000000000000),       // 48-bit pattern match for pattern detect.SEL_MASK("MASK"),           // "C", "MASK", "ROUNDING_MODE1", "ROUNDING_MODE2".SEL_PATTERN("PATTERN"),          // Select pattern value ("PATTERN" or "C").USE_PATTERN_DETECT("NO_PATDET"),  // Enable pattern detect ("PATDET" or "NO_PATDET")// Register Control Attributes: Pipeline Register Configuration.ACASCREG(0),            //.ADREG(1),               // Number of pipeline stages for pre-adder (0 or 1).ALUMODEREG(0),          // Number of pipeline stages for ALUMODE (0 or 1).AREG(0),                 // Number of pipeline stages for A (0, 1 or 2)  .BCASCREG(0),            // Number of pipeline stages between B/BCIN and BCOUT (0, 1 or 2).BREG(0),                         // Number of pipeline stages for B (0, 1 or 2).CARRYINREG(0),                   // Number of pipeline stages for CARRYIN (0 or 1).CARRYINSELREG(0),                // Number of pipeline stages for CARRYINSEL (0 or 1).CREG(0),                         // Number of pipeline stages for C (0 or 1).DREG(0),                         // Number of pipeline stages for D (0 or 1).INMODEREG(1),                    // Number of pipeline stages for INMODE (0 or 1).MREG(0),                         // Number of multiplier pipeline stages (0 or 1).OPMODEREG(0),                    // Number of pipeline stages for OPMODE (0 or 1).PREG(1)                          // Number of pipeline stages for P (0 or 1))DSP48E1_inst (// Cascade: 30-bit (each) output: Cascade Ports.ACOUT(acout),                   // 30-bit output: A port cascade output.BCOUT(bcout),                   // 18-bit output: B port cascade output.CARRYCASCOUT(carrycasout),     // 1-bit output: Cascade carry output.MULTSIGNOUT(),       // 1-bit output: Multiplier sign cascade output.PCOUT(pcout),                   // 48-bit output: Cascade output//这些引脚空着就好// Control: 1-bit (each) output: Control Inputs/Status Bits.OVERFLOW(),             // 1-bit output: Overflow in add/acc output.PATTERNBDETECT(),        // 1-bit output: Pattern bar detect output.PATTERNDETECT(),   // 1-bit output: Pattern detect output.UNDERFLOW(),           // 1-bit output: Underflow in add/acc output//这些引脚也空着,没用// Data: 4-bit (each) output: Data Ports.CARRYOUT(carryout),                               // 4-bit output: Carry output.P(o),                           // 48-bit output: Primary data output//P输出48bit的// Cascade: 30-bit (each) input: Cascade Ports.ACIN(30'b0),                     // 30-bit input: A cascade data input.BCIN(18'b0),                     // 18-bit input: B cascade input.CARRYCASCIN(1'b0),              // 1-bit input: Cascade carry input.MULTSIGNIN(1'b0),         // 1-bit input: Multiplier sign input.PCIN(48'b0),                     // 48-bit input: P cascade input//这些引脚很重要,做流水线时,数据又这几个引脚输入。// Control: 4-bit (each) input: Control Inputs/Status Bits.ALUMODE(4'b0011),               // 4-bit input: ALU control input.CARRYINSEL(3'b0),         // 3-bit input: Carry select input.CLK(clk),                       // 1-bit input: Clock input.INMODE(5'b0),                 // 5-bit input: INMODE control input.OPMODE(7'b0110101),                 // 7-bit input: Operation mode input// Data: 30-bit (each) input: Data Ports.A(in1),                           // 30-bit input: A data input.B(in2),                           // 18-bit input: B data input//.C(48'hffffffffffff),              // 48-bit input: C data input.C(c),              // 48-bit input: C data input.CARRYIN(1'b0),                      // 1-bit input: Carry input signal.D(25'b0),                           // 25-bit input: D data input// Reset/Clock Enable: 1-bit (each) input: Reset/Clock Enable Inputs.CEA1(1'b0),                      // 1-bit input: Clock enable input for 1st stage AREG.CEA2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage AREG.CEAD(1'b0),                      // 1-bit input: Clock enable input for ADREG.CEALUMODE(1'b0),                 // 1-bit input: Clock enable input for ALUMODE.CEB1(1'b0),                      // 1-bit input: Clock enable input for 1st stage BREG.CEB2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage BREG.CEC(1'b0),                       // 1-bit input: Clock enable input for CREG.CECARRYIN(1'b0),                 // 1-bit input: Clock enable input for CARRYINREG.CECTRL(1'b0),                    // 1-bit input: Clock enable input for OPMODEREG and CARRYINSELREG.CED(1'b0),                       // 1-bit input: Clock enable input for DREG.CEINMODE(1'b0),                  // 1-bit input: Clock enable input for INMODEREG.CEM(1'b0),                       // 1-bit input: Clock enable input for MREG.CEP(1'b1),                       // 1-bit input: Clock enable input for PREG.RSTA(rst),.RSTALLCARRYIN(rst),.RSTALUMODE(rst),.RSTB(rst),.RSTC(rst),.RSTCTRL(rst),.RSTD(rst),.RSTINMODE(rst),.RSTM(rst),.RSTP(rst));endmodulemodule bitstream_tb;reg rst;reg dec_clk;reg signed [24:0] a;reg signed [17:0] b;reg signed [47:0] d;reg signed [47:0] c;wire signed [47:0] p;wire signed [29:0] ac;wire signed [17:0] bc;wire [3:0] co;wire [3:0] ccas;wire signed [47:0] pc;initial beginrst = 0;#200 a = 10;#0 b = 20;#0 d = 45;#0 c = 400;#50 rst = 1;#1 rst = 0;#100 $display("p %d",p);endalwaysbegin#1 dec_clk = 0;#1 dec_clk = 1;endtest test_inst(.clk(dec_clk),.rst(rst),.in1(a),.in2(b),.c(c),.o(p),.acout(ac),.bcout(bc),.carryout(co),.carrycasout(ccas),.pcout(pc));endmodule

5    o <= o+in1*in2   累加操作

OPMODE=7'b0100101


`timescale 1ns / 10ps // timescale time_unit/time_presicionmodule test(input wire clk,input wire rst,input wire signed [24:0] in1,input wire signed [17:0] in2,input wire signed [47:0] c,output wire signed [47:0]  o,output wire signed [29:0] acout,output wire signed [17:0] bcout,output wire [3:0] carryout,output wire [3:0] carrycasout,output wire signed [47:0] pcout);DSP48E1 #(.A_INPUT("DIRECT"),.B_INPUT("DIRECT"),.USE_DPORT("FALSE"),.USE_MULT("MULTIPLY"),       .USE_SIMD("ONE48"),               .AUTORESET_PATDET("NO_RESET"),    // "NO_RESET", "RESET_MATCH", "RESET_NOT_MATCH".MASK(48'h3fffffffffff),          // 48-bit mask value for pattern detect (1=ignore).PATTERN(48'h000000000000),       // 48-bit pattern match for pattern detect.SEL_MASK("MASK"),           // "C", "MASK", "ROUNDING_MODE1", "ROUNDING_MODE2".SEL_PATTERN("PATTERN"),          // Select pattern value ("PATTERN" or "C").USE_PATTERN_DETECT("NO_PATDET"),  // Enable pattern detect ("PATDET" or "NO_PATDET")// Register Control Attributes: Pipeline Register Configuration.ACASCREG(0),            //.ADREG(1),               // Number of pipeline stages for pre-adder (0 or 1).ALUMODEREG(0),          // Number of pipeline stages for ALUMODE (0 or 1).AREG(0),                 // Number of pipeline stages for A (0, 1 or 2)  .BCASCREG(0),            // Number of pipeline stages between B/BCIN and BCOUT (0, 1 or 2).BREG(0),                         // Number of pipeline stages for B (0, 1 or 2).CARRYINREG(0),                   // Number of pipeline stages for CARRYIN (0 or 1).CARRYINSELREG(0),                // Number of pipeline stages for CARRYINSEL (0 or 1).CREG(0),                         // Number of pipeline stages for C (0 or 1).DREG(0),                         // Number of pipeline stages for D (0 or 1).INMODEREG(1),                    // Number of pipeline stages for INMODE (0 or 1).MREG(0),                         // Number of multiplier pipeline stages (0 or 1).OPMODEREG(0),                    // Number of pipeline stages for OPMODE (0 or 1).PREG(1)                          // Number of pipeline stages for P (0 or 1))DSP48E1_inst (// Cascade: 30-bit (each) output: Cascade Ports.ACOUT(acout),                   // 30-bit output: A port cascade output.BCOUT(bcout),                   // 18-bit output: B port cascade output.CARRYCASCOUT(carrycasout),     // 1-bit output: Cascade carry output.MULTSIGNOUT(),       // 1-bit output: Multiplier sign cascade output.PCOUT(pcout),                   // 48-bit output: Cascade output//这些引脚空着就好// Control: 1-bit (each) output: Control Inputs/Status Bits.OVERFLOW(),             // 1-bit output: Overflow in add/acc output.PATTERNBDETECT(),        // 1-bit output: Pattern bar detect output.PATTERNDETECT(),   // 1-bit output: Pattern detect output.UNDERFLOW(),           // 1-bit output: Underflow in add/acc output//这些引脚也空着,没用// Data: 4-bit (each) output: Data Ports.CARRYOUT(carryout),                               // 4-bit output: Carry output.P(o),                           // 48-bit output: Primary data output//P输出48bit的// Cascade: 30-bit (each) input: Cascade Ports.ACIN(30'b0),                     // 30-bit input: A cascade data input.BCIN(18'b0),                     // 18-bit input: B cascade input.CARRYCASCIN(1'b0),              // 1-bit input: Cascade carry input.MULTSIGNIN(1'b0),         // 1-bit input: Multiplier sign input.PCIN(48'b0),                     // 48-bit input: P cascade input//这些引脚很重要,做流水线时,数据又这几个引脚输入。// Control: 4-bit (each) input: Control Inputs/Status Bits.ALUMODE(4'b0),               // 4-bit input: ALU control input.CARRYINSEL(3'b0),         // 3-bit input: Carry select input.CLK(clk),                       // 1-bit input: Clock input.INMODE(5'b0),                 // 5-bit input: INMODE control input.OPMODE(7'b0100101),                 // 7-bit input: Operation mode input// Data: 30-bit (each) input: Data Ports.A(in1),                           // 30-bit input: A data input.B(in2),                           // 18-bit input: B data input//.C(48'hffffffffffff),              // 48-bit input: C data input.C(c),              // 48-bit input: C data input.CARRYIN(1'b0),                      // 1-bit input: Carry input signal.D(25'b0),                           // 25-bit input: D data input// Reset/Clock Enable: 1-bit (each) input: Reset/Clock Enable Inputs.CEA1(1'b0),                      // 1-bit input: Clock enable input for 1st stage AREG.CEA2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage AREG.CEAD(1'b0),                      // 1-bit input: Clock enable input for ADREG.CEALUMODE(1'b0),                 // 1-bit input: Clock enable input for ALUMODE.CEB1(1'b0),                      // 1-bit input: Clock enable input for 1st stage BREG.CEB2(1'b0),                      // 1-bit input: Clock enable input for 2nd stage BREG.CEC(1'b0),                       // 1-bit input: Clock enable input for CREG.CECARRYIN(1'b0),                 // 1-bit input: Clock enable input for CARRYINREG.CECTRL(1'b0),                    // 1-bit input: Clock enable input for OPMODEREG and CARRYINSELREG.CED(1'b0),                       // 1-bit input: Clock enable input for DREG.CEINMODE(1'b0),                  // 1-bit input: Clock enable input for INMODEREG.CEM(1'b0),                       // 1-bit input: Clock enable input for MREG.CEP(1'b1),                       // 1-bit input: Clock enable input for PREG.RSTA(rst),.RSTALLCARRYIN(rst),.RSTALUMODE(rst),.RSTB(rst),.RSTC(rst),.RSTCTRL(rst),.RSTD(rst),.RSTINMODE(rst),.RSTM(rst),.RSTP(rst));endmodulemodule bitstream_tb;reg rst;reg dec_clk;reg signed [24:0] a;reg signed [17:0] b;reg signed [47:0] d;reg signed [47:0] c;wire signed [47:0] p;wire signed [29:0] ac;wire signed [17:0] bc;wire [3:0] co;wire [3:0] ccas;wire signed [47:0] pc;initial beginrst = 0;#200 a = 100;#0 b = 200;#0 d = 45;#0 c = 400;#50 rst = 1;#1 rst = 0;#100 $display("p %d",p);endalwaysbegin#1 dec_clk = 0;#1 dec_clk = 1;endtest test_inst(.clk(dec_clk),.rst(rst),.in1(a),.in2(b),.c(c),.o(p),.acout(ac),.bcout(bc),.carryout(co),.carrycasout(ccas),.pcout(pc));endmodule

这篇关于DSP48E1 (primitive)原语例化实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/876502

相关文章

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss

C++操作符重载实例(独立函数)

C++操作符重载实例,我们把坐标值CVector的加法进行重载,计算c3=c1+c2时,也就是计算x3=x1+x2,y3=y1+y2,今天我们以独立函数的方式重载操作符+(加号),以下是C++代码: c1802.cpp源代码: D:\YcjWork\CppTour>vim c1802.cpp #include <iostream>using namespace std;/*** 以独立函数

实例:如何统计当前主机的连接状态和连接数

统计当前主机的连接状态和连接数 在 Linux 中,可使用 ss 命令来查看主机的网络连接状态。以下是统计当前主机连接状态和连接主机数量的具体操作。 1. 统计当前主机的连接状态 使用 ss 命令结合 grep、cut、sort 和 uniq 命令来统计当前主机的 TCP 连接状态。 ss -nta | grep -v '^State' | cut -d " " -f 1 | sort |

Java Websocket实例【服务端与客户端实现全双工通讯】

Java Websocket实例【服务端与客户端实现全双工通讯】 现很多网站为了实现即时通讯,所用的技术都是轮询(polling)。轮询是在特定的的时间间隔(如每1秒),由浏览器对服务器发 出HTTP request,然后由服务器返回最新的数据给客服端的浏览器。这种传统的HTTP request 的模式带来很明显的缺点 – 浏 览器需要不断的向服务器发出请求,然而HTTP

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群 华为云最近正在举办828 B2B企业节,Flexus X实例的促销力度非常大,特别适合那些对算力性能有高要求的小伙伴。如果你有自建MySQL、Redis、Nginx等服务的需求,一定不要错过这个机会。赶紧去看看吧! 什么是华为云Flexus X实例 华为云Flexus X实例云服务是新一代开箱即用、体

LLVM入门2:如何基于自己的代码生成IR-LLVM IR code generation实例介绍

概述 本节将通过一个简单的例子来介绍如何生成llvm IR,以Kaleidoscope IR中的例子为例,我们基于LLVM接口构建一个简单的编译器,实现简单的语句解析并转化为LLVM IR,生成对应的LLVM IR部分,代码如下,文件名为toy.cpp,先给出代码,后面会详细介绍每一步分代码: #include "llvm/ADT/APFloat.h"#include "llvm/ADT/S

OpenStack离线Train版安装系列—11.5实例使用-Cinder存储服务组件

本系列文章包含从OpenStack离线源制作到完成OpenStack安装的全部过程。 在本系列教程中使用的OpenStack的安装版本为第20个版本Train(简称T版本),2020年5月13日,OpenStack社区发布了第21个版本Ussuri(简称U版本)。 OpenStack部署系列文章 OpenStack Victoria版 安装部署系列教程 OpenStack Ussuri版

OpenStack实例操作选项解释:启动和停止instance实例

关于启动和停止OpenStack实例 如果你想要启动和停止OpenStack实例时,有四种方法可以考虑。 管理员可以暂停、挂起、搁置、停止OpenStack 的计算实例。但是这些方法之间有什么不同之处? 目录 关于启动和停止OpenStack实例1.暂停和取消暂停实例2.挂起和恢复实例3.搁置(废弃)实例和取消废弃实例4.停止(删除)实例 1.暂停和取消暂停实例

Cmake之3.0版本重要特性及用法实例(十三)

简介: CSDN博客专家、《Android系统多媒体进阶实战》一书作者 新书发布:《Android系统多媒体进阶实战》🚀 优质专栏: Audio工程师进阶系列【原创干货持续更新中……】🚀 优质专栏: 多媒体系统工程师系列【原创干货持续更新中……】🚀 优质视频课程:AAOS车载系统+AOSP14系统攻城狮入门视频实战课 🚀 人生格言: 人生从来没有捷径,只有行动才是治疗恐惧

实例demo理解面向接口思想

浅显的理解面向接口编程 Android开发的语言是java,至少目前是,所以理解面向接口的思想是有必要的。下面通过一个简单的例子来理解。具体的概括我也不知道怎么说。 例子: 现在我们要开发一个应用,模拟移动存储设备的读写,即计算机与U盘、MP3、移动硬盘等设备进行数据交换。已知要实现U盘、MP3播放器、移动硬盘三种移动存储设备,要求计算机能同这三种设备进行数据交换,并且以后可能会有新的第三方的