微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 8x8乘法器程序综合不了,求大侠帮忙看看。

8x8乘法器程序综合不了,求大侠帮忙看看。

时间:10-02 整理:3721RD 点击:

这段程序综合不了,但是可以仿真。问题出在result和finish上面,这两个模块出口的值一定要设计成wire型数据么?可是我改成wire数据还是综合不了,报警说reg型数据不能相加赋值给wire数据。
归到底问题就是:在模块里面,输入值是reg类型的,经过运算后得到输出值,那么这个输出值也是reg类型的了,可是综合时候就一定要认为输出是wire类型的,所以出错综合不了了,这个问题该如何解决呢,谢谢!
程序段如下:
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date:    10:53:47 05/17/2012
// Design Name:
// Module Name:    multiplier8_05
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module multiplier8_05(
    input clk,
  input rst_n,
  input [7:0] mul_a,
    input [7:0] mul_b,
    output [15:0] result,
  output finish
    );
    reg[15:0] result;
    reg[15:0] store7;
    reg[15:0] store6;
    reg[15:0] store5;
    reg[15:0] store4;
    reg[15:0] store3;
    reg[15:0] store2;
    reg[15:0] store1;
    reg[15:0] store0;
    reg       finish;
always @ (posedge clk or negedge rst_n)
begin
   if(!rst_n)
       begin
           store7 <= 16'b0;
           store6 <= 16'b0;
           store5 <= 16'b0;
           store4 <= 16'b0;
           store3 <= 16'b0;
           store2 <= 16'b0;
           store1 <= 16'b0;
           store0 <= 16'b0;
           finish <= 1'b0;
       end
   else
       begin
           store7 <= mul_b[7] ? {1'b0,mul_a,7'b0}:16'b0;
           store6 <= mul_b[6] ? {2'b0,mul_a,6'b0}:16'b0;
           store5 <= mul_b[5] ? {3'b0,mul_a,5'b0}:16'b0;
           store4 <= mul_b[4] ? {4'b0,mul_a,4'b0}:16'b0;
           store3 <= mul_b[3] ? {5'b0,mul_a,3'b0}:16'b0;
           store2 <= mul_b[2] ? {6'b0,mul_a,2'b0}:16'b0;
           store1 <= mul_b[1] ? {7'b0,mul_a,1'b0}:16'b0;
           store0 <= mul_b[0] ? {8'b0,mul_a}:16'b0;
           result <= store0 + store1 + store2 + store3 + store4 + store5 + store6 + store7;
       end
   end
always @ (result)
    finish <= 1'b1;
endmodule

因为finish写在两个always block里面啦。
多看看书,多从基本数字电路知识理解一下。这是基本概念。

寄存器finish怎能在两个进程中赋值?
finish <= 1'b0;
always @ (result)
    finish <= 1'b1;

谢谢,我把finish写到外面来了,用了initial finish <= 1'b0;
但是外面仍然会出现result报警,如下:
ERROR:HDLCompilers:27 - "multiplier8_05.v" line 30 Illegal redeclaration of 'result'
这是怎么回事啊?

initial finish <= 1'b0;
不能综合
建议你先看下 ieee的可综合子集的标准

不同always块不能对一个变量赋值。
这个直接用组合逻辑不就OK了?

把最后的always模块删掉,该做 finish <= result||1会不会好点

module multiplier8_05(
    input clk,
  input rst_n,
  input [7:0] mul_a,
    input [7:0] mul_b,
    output [15:0] result,
  output finish
    );
    reg[15:0] result;
    reg[15:0] store7;
    reg[15:0] store6;
    reg[15:0] store5;
    reg[15:0] store4;
    reg[15:0] store3;
    reg[15:0] store2;
    reg[15:0] store1;
    reg[15:0] store0;
    reg       finish,c0;
always @ (posedge clk or negedge rst_n)
begin
   if(!rst_n)
       begin
           store7 <= 16'b0;
           store6 <= 16'b0;
           store5 <= 16'b0;
           store4 <= 16'b0;
           store3 <= 16'b0;
           store2 <= 16'b0;
           store1 <= 16'b0;
           store0 <= 16'b0;
           c0<=1'b0;
       end
   else
       begin
           store7 <= mul_b[7] ? {1'b0,mul_a,7'b0}:16'b0;
           store6 <= mul_b[6] ? {2'b0,mul_a,6'b0}:16'b0;
           store5 <= mul_b[5] ? {3'b0,mul_a,5'b0}:16'b0;
           store4 <= mul_b[4] ? {4'b0,mul_a,4'b0}:16'b0;
           store3 <= mul_b[3] ? {5'b0,mul_a,3'b0}:16'b0;
           store2 <= mul_b[2] ? {6'b0,mul_a,2'b0}:16'b0;
           store1 <= mul_b[1] ? {7'b0,mul_a,1'b0}:16'b0;
           store0 <= mul_b[0] ? {8'b0,mul_a}:16'b0;
           result <= store0 + store1 + store2 + store3 + store4 + store5 + store6 + store7;
           c0<=1'b1;
       end
   end
always @ (result)
begin
finish<=c0 && result;
end  
endmodule

补充一句第二个always进程里要加入c0这个敏感信号,否则会造成仿真结果和实测结果不一致的情况,我疏忽了 不好意思还请大家指正。

output [15:0] result --> output reg [15:0]  result


你已经使用了verilog2001了,就直接always @(*),这样就不会因为漏写造成错误了

谢谢各位侠客的支持,bob_haohao的程序可以仿真,但是综合时候会出现错误:
ERROR:HDLCompilers:27 - "multiplier8_05.v" line 29 Illegal redeclaration of 'result'
ERROR:HDLCompilers:27 - "multiplier8_05.v" line 38 Illegal redeclaration of 'finish'
      我按照vongy的想法改了下程序,可以仿真及综合了,各位高手的帮忙,让我学到而来很多东西。谢谢各位的指导啊。yangyuf1,ureyhu,zzczx,yanrenyi,bob_haohao,vongy各位高手的真知灼见将永放光芒,我要好好努力上北大。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top