在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4722|回复: 11

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

[复制链接]
发表于 2012-5-17 13:48:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 flyamo 于 2012-5-17 13:54 编辑

这段程序综合不了,但是可以仿真。问题出在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
发表于 2012-5-17 14:29:42 | 显示全部楼层
因为finish写在两个always block里面啦。
多看看书,多从基本数字电路知识理解一下。这是基本概念。
发表于 2012-5-17 15:17:07 | 显示全部楼层
寄存器finish怎能在两个进程中赋值?
finish <= 1'b0;
always @ (result)
    finish <= 1'b1;
 楼主| 发表于 2012-5-17 15:58:17 | 显示全部楼层
谢谢,我把finish写到外面来了,用了initial finish <= 1'b0;
但是外面仍然会出现result报警,如下:
ERROR:HDLCompilers:27 - "multiplier8_05.v" line 30 Illegal redeclaration of 'result'
这是怎么回事啊?
发表于 2012-5-17 17:39:21 | 显示全部楼层
initial finish <= 1'b0;
不能综合
建议你先看下 ieee的可综合子集的标准
发表于 2012-5-17 20:58:04 | 显示全部楼层
不同always块不能对一个变量赋值。
这个直接用组合逻辑不就OK了?
发表于 2012-5-18 10:18:42 | 显示全部楼层
把最后的always模块删掉,该做 finish <= result||1会不会好点
发表于 2012-5-18 10:48:25 | 显示全部楼层
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
发表于 2012-5-18 10:51:53 | 显示全部楼层
补充一句第二个always进程里要加入c0这个敏感信号,否则会造成仿真结果和实测结果不一致的情况,我疏忽了 不好意思还请大家指正。
发表于 2012-5-18 11:22:49 | 显示全部楼层
output [15:0] result --> output reg [15:0]  result
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

X

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-6-2 11:40 , Processed in 0.029156 second(s), 11 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表