如何在 Verilog 中综合 While 循环?

2024-02-12

我尝试设计一个 Booth 乘法器,它在所有编译器中运行良好,包括:

Modelsim、Verilogger Extreme、Aldec Active Hdl 和 Xilinx Isim。.....

我知道模拟和综合是两个不同的过程,而且只有少数Verilog具有各种限制的构建体可供合成。但我不知道会发生什么While loop在我的程序中不起作用新思科技 Synplify 9.6以及在赛灵思伊势 14.2.

当我尝试合成时Synopsys says "loop iteration limit 2000 exceeded" while Xilinx 的 XST says " This Xilinx application has run out of memory or has encountered a memory conflict"

我在下面附上了我的代码。 我也写这个合成器产生错误的原因是while 循环......

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////Author/Coder-Shrikant Vaishnav///////////////////////////////////////////////
/////////////////////////////////////////Design-Booth Algorithm Demonstration////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


module booth_synt(input wire [4:0]a,input wire [4:0]b,output reg signed[9:0] g);
reg signed[10:0]c;// One extra bit for sign bit.....I mean 11th bit.
//We used Signed Reg bcoz ASR fill vacant bit with MSB and then shift other for unsigned reg they fill it with zeros and then shift.. 
reg[4:0]d;
reg [4:0]e;
reg [2:0]count1; 
reg [2:0]count2; 
reg [2:0]count3; 
reg [2:0]count4; 

//Always start whenever any changes happens

always@(a,b)
 begin :close



//If's for sign bit check...
//Then 2's Complement...

count1=3'b000; //Initialize Counter
count2=3'b000;
count3=3'b000;
count4=3'b000;

//For negative
if(a[4]==1'b1) //Internal checking
  begin
  if(a==5'b10000)
    begin
     g[9:0]=10'b0000000000;
    end
  else
  begin
  d=~{1'b0,a[3],a[2],a[1],a[0]};  //we place 1'b0 because its inversion is 1   
  d=d+5'b00001;  //2's Complement we use additional register d for data holding.....bcoz wire not hold data
     if(d[4]==1'b0)//This "if" is used bcoz if due to calculation if accidently d[5]==1'b0 then this changs sign bit and thus ans
    begin
    d[4]=1'b1;
    end
    c[5:1]=d;
  end
  end

 if(b[4]==1'b1)
  begin 

   if(b==5'b10000)
    begin
     g[9:0]=10'b0000000000;
     disable close;
    end
  else
   begin
   e=~{1'b0,b[3],b[2],b[1],b[0]}; //we place 1'b0 because its inversion is 1
   e=e+5'b00001;
   if(e[4]==1'b0)//This "if" is used bcoz if due to calculation if accidently e[4]==1'b0 then this changs sign bit and thus ans
    begin
   e[4]=1'b1;
    end
   end
  end


//For positive 
if(b[4]==1'b0)
begin
e[4:0]=b[4:0];

end

if(a[4]==1'b0)
begin

c[1]=a[0];
c[2]=a[1]; //"a" is multiplier while "b" is multiplicand...
c[3]=a[2];
c[4]=a[3];
c[5]=a[4];

end



//Initialization of Output ........
c[0]=1'b0;

//All MSB's are Initially set to Zeros
c[6]=1'b0;
c[7]=1'b0;
c[8]=1'b0;
c[9]=1'b0;
c[10]=1'b0;



//Four Different Conditions Checking......
case({c[1],c[0]})

2'b00:begin   //Case 1

       while(count1<3'b101)  **<-------"Error Generated Here due to this while loop"**
      begin


         if({c[1],c[0]}==2'b10) //cond1 for 10
            begin
             c[10:6]=(c[10:6]-e[4:0]);
              c=c>>>1;
              count1=count1+1'b1;


            if(count1==3'b101)// Counter value check
             begin
               if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

                 end
            end //end if==4
          end
          if(({c[1],c[0]}==2'b00) || ({c[1],c[0]}==2'b11))      //cond 2 in it we describe both 00 and11.........Arithemetic Right Shift operation
             begin
              c=c>>>1;     
              count1=count1+1'b1;                    


             if(count1==3'b101) // Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

                 end

              end
              end   

           if({c[1],c[0]}==2'b01) //cond3 for 01
            begin
             c[10:6]=(c[10:6]+e[4:0]);
              c=c>>>1;
              count1=count1+1'b1;


             if(count1==3'b101) // Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

             end
              end
              end
     end  

   end//while's end


 //Case2
 2'b11:begin
      while(count2<3'b101) **<-------"Error Generated Here due to this while loop"**
      begin



         if({c[1],c[0]}==2'b10) //cond1 for 10
            begin
             c[10:6]=(c[10:6]-e[4:0]);
              c=c>>>1;
              count2=count2+1'b1;


             if(count2==3'b101) // Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

              end
              end
              end

          if(({c[1],c[0]}==2'b00)||({c[1],c[0]}==2'b11))//cond 2 in it we describe both 00 and11.........Arithemetic Right Shift operation
             begin
              c=c>>>1;     
              count2=count2+1'b1;                    


             if(count2==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity  
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                g[9:0]=c[10:1];

             end
              end
              end   

           if({c[1],c[0]}==2'b01) //cond3 for 01
            begin
            c[10:6]=(c[10:6]+e[4:0]);
              c=c>>>1;
              count2=count2+1'b1;


             if(count2==3'b101)// Counter value check
               begin
                 if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

              end
              end
             end
           end 
          end //while's end



  //Case 3
  2'b10:begin
     while(count3<3'b101) **<-------"Error Generated Here due to this while loop"**
      begin

     if({c[1],c[0]}==2'b10) //Cond1 for 10
            begin
             c[10:6]=(c[10:6]-e[4:0]);

              c=c>>>1;
              count3=count3+1'b1;


             if(count3==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

              end
              end
              end

          if(({c[1],c[0]}==2'b00)||({c[1],c[0]}==2'b11))//cond 2 in it we describe both 00 and11.........Arithemetic Right Shift operation
             begin
              c=c>>>1;     

              count3=count3+1'b1;                    


             if(count3==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

               end
              end
              end   

           if({c[1],c[0]}==2'b01) //cond3 for 01
            begin
             c[10:6]=(c[10:6]+e[4:0]); 

              c=c>>>1;
              count3=count3+1'd1;

             if(count3==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

                 end

               end
             end
           end 
          end //while's end



  //Case 4
  2'b01:begin
         while(count4<3'b101) **<-------"Error Generated Here due to this while loop"**
          begin

         if({c[1],c[0]}==2'b10) //cond1 for 10
            begin
             c[10:6]=(c[10:6]-e[4:0]);
              c=c>>>1;
              count4=count4+1'b1;


             if(count4==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

              end
              end
              end

          if(({c[1],c[0]}==2'b00)||({c[1],c[0]}==2'b11))//cond 2 in it we describe both 00 and11.........Arithemetic Right Shift operation
             begin
              c=c>>>1;     
              count4=count4+1'b1;                    


             if(count4==3'b101)// Counter value check
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

              end
              end
              end   

           if({c[1],c[0]}==2'b01) //cond3 for 01
            begin
             c[10:6]=(c[10:6]+e[4:0]);
              c=c>>>1;
              count4<=count4+1'b1;


             if(count4==3'b101)
               begin
                if(c[10]==1)
                 begin
                 c=~{1'b0,c[9],c[8],c[7],c[6],c[5],c[4],c[3],c[2],c[1],c[0]};//we place 1'b0 because its inversion is 1
                 c=c+10'b0000000010;
                 c[10]=1'b1; //Again giving 1 for surity 
                 g[9:0]=c[10:1];

                 end

                 if(c[10]==0)
                 begin
                 c[10]=1'b0;
                 g[9:0]=c[10:1];

                  end
                end
               end
              end  //while's end

          end//01's end  

   endcase //case end


end       //always end
endmodule

这是写得不好的代码。你把它写得像计算机程序一样。 Verilog 是一种硬件描述语言,而不是一种编程语言。在您的情况下,合成器正在尝试复制 case 语句中 while 循环内的逻辑。

  • 在将其转换为 HDL 之前在纸上设计硬件
  • 在编码之前识别设计中的组合逻辑和顺序逻辑。
  • 想想合成器将使用什么逻辑来实现您编写的逻辑。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Verilog 中综合 While 循环? 的相关文章

  • System Verilog fork join - 实际上不是并行的?

    我正在学习系统verilog 并认为为每个进程创建单独的线程fork join 但是 我发现如果我有一个while在我的第一个进程中循环 我的第二个进程没有启动 这让我想到fork join实际上并不平行 class A task run
  • Modelsim 对 SV 的支持

    我目前正在使用 modelsim SE 5 8e 它不支持SystemVerilog 我需要使用 SystemVerilog 来设计和验证我的项目 您知道哪个版本的 Modelsim 能够很好地支持 sytemverilog 的设计和验证子
  • 用于 Verilog 或 SystemVerilog 的 TAP(测试任何协议)模块

    是否有 TAP 测试任何协议 http testanything org Verilog 的实现 那就太好了 因为这样我就可以使用证明来自动检查我的结果 更新 10 9 09 有人问为什么不使用断言 部分 TAP 为我提供了一些很好的报告
  • Verilog 错误:必须连接到结构网络表达式

    我收到错误 output or inout port Qout must be connected to a structural net expression 我评论了下面代码中发生错误的行 代码被修剪 压缩 我搜索了答案 似乎我无法将输
  • if 语句导致 Verilog 中的锁存推断?

    我正在编写用于合成算法的 Verilog 代码 我对哪些情况可能导致推断锁存器有点困惑 下面是这样的一段代码 虽然它在模拟中工作得很好 但我担心它可能会导致硬件问题 always b1 or b2 b1 map b2 map m1 map
  • 在 Mac OS X 10.6.8 上用什么来编译和模拟 Verilog 程序?

    作为教学大纲的一部分 我需要模拟 Verilog 程序 但是 我的大学使用 Xilinx ISE 但它不适用于 Mac 因此 请帮助我提供最好的软件以及有关如何安装和使用它们的一些详细步骤 你可以尝试伊卡洛斯 Verilog http iv
  • 始终块中的 Veriloggenerate/genvar

    我试图让一个模块通过 ISE 12 4 中的语法检查 但它给了我一个我不明白的错误 首先是代码片段 parameter ROWBITS 4 reg ROWBITS 1 0 temp genvar c generate always pose
  • FPGA大输入数据

    我正在尝试向 FPGA 发送 4 KB 字符串 最简单的方法是什么 是我正在使用的fpga的链接 我正在使用 Verilog 和 Quartus 您的问题的答案在很大程度上取决于将数据输入 FPGA 的内容 即使没有您需要遵守的特定协议 S
  • 系统verilog中的打包向量与未打包向量

    看看我在 System Verilog 中维护的一些代码 我看到一些信号的定义如下 node range hi range lo x 以及其他定义如下 node y range hi range lo 我明白那个x被定义为打包的 而y被定义
  • 在 Verilog 设计中产生时钟故障

    我正在使用 Verilog 设计芯片 我有一个 3 位计数器 我希望当计数器处于第 8 次循环时 应该有一个时钟故障 之后就可以正常工作了 在 Verilog 设计中产生时钟故障的可能方法是什么 在时钟信号上注入毛刺的一种方法是使用forc
  • 自动任务和静态任务有什么区别,为什么我们不能通过引用传递静态任务

    静态任务和自动任务有什么区别 program class ref int index value class holding values int ass array task assign value int value int inde
  • 如何在Verilog中将二维数组中的所有位设置为0?

    我构建了一个 8 2bits 数组来表示 Verilog 中的一块内存 reg 1 0 m 0 7 该存储器有一个复位信号 如果复位为1 则该存储器中的所有位都应重置为0 但是我不知道如何以简洁的方式设置m的所有位 因为如果有数百个内存中有
  • 如何在 Verilog 中推断 Block RAM

    我在一个项目中遇到了一个非常具体的问题 这个问题已经困扰我好几天了 我有以下 RAM 模块的 Verilog 代码 module RAM param clk addr read write clear data in data out pa
  • 使用正则表达式进行 Verilog 端口映射

    我有一个很长的端口映射 我想在其中替换一堆 SignalName i with SignalName SignalName i 我想我可以用正则表达式轻松地做到这一点 但我无法弄清楚如何做到这一点 有任何想法吗 假设 SignalData
  • Verilog 按位或 ("|") 单子

    我见过 Verilog 代码 其中使用了按位或运算符 目的是什么 例如 address 15 14 0 or address 15 14 io din ramrd 不能省略 吗在这些情况下 在这种情况下 它充当归约运算符 例如 4 b100
  • 如何在 icarus verilog 中包含文件?

    我知道基本的 include filename v 命令 但是 我试图包含另一个文件夹中的模块 现在 该模块还包括同一文件夹中存在的其他模块 但是 当我尝试在最顶层运行该模块时 出现错误 C Users Dell Desktop MIPS
  • Verilog 数组语法

    我是 Verilog 新手 并且遇到了很多麻烦 例如 我想要一个包含八个单元的数组 每个单元都是 8 位宽 以下不起作用 reg 7 0 transitionTable 0 7 assign transitionTable 0 10 仅仅做
  • Verilog:如何取绝对值

    在 verilog 中 我有一个二进制值数组 如何取减去值的绝对值 Verilog代码 module aaa clk input clk reg 7 0 a 1 9 reg 7 0 s 1 9 always posedge clk begi
  • 从测试台访问子模块中的输入和输出

    我的被 测设备 DUT 有许多子模块 我想测试其中的一些 我的测试夹具将是我的项目的顶层 比 DUT 高一级 并且由于我似乎只能访问下一层模块的输入和输出 所以我只能访问顶层的输入和输出被测设备 我希望能够从测试夹具下方的两层或多层模块访问
  • 仿真输出全为零

    我的设计模块和测试平台代码已编译 但是 当我模拟时 我没有得到正确的输出 谁能告诉我我的代码哪里出了问题 这是测试平台的代码 module testbench reg 511 0 FROM LS reg CLK reg 63 0 TO IF

随机推荐

  • CALayer 作为子层不可见

    我正在尝试构建一个动画圆圈 该圆圈将按顺时针方向绘制 直到它变成完整的圆圈 如图所示iPhone 核心动画 画一个圆 https stackoverflow com questions 7991086 iphone core animati
  • Android findViewById 返回 NULL

    有时我的 xml 视图和 Android Eclipse SDK 中包含的子元素有一个奇怪的问题 例如 我有一个名为 main xml 的 xml 视图 其中有一个 LinearLayout 和一个 TextView 作为唯一的子视图 其
  • 如何在LUIS Dialog内部调用LUIS Dialog?

    我的机器人有 LUIS 对话框 有几个意图 我从 MessageController 调用 LUIS 对话框 如果检测到意图 我将启动一个子对话框 当子对话框完成后 我调用context Done response from user 在那
  • NULLS FIRST/LAST 覆盖在 Spring Boot 3/Hibernate 6 的 JPA 存储库中不再起作用

    在带有 Hibernate 5 的 Spring Boot 2 中 我们有一个如下查询 Query SELECT m FROM ProjectMember m ORDER BY m lastActive ASC NULLS LAST Lis
  • Box2D:如何手动渲染身体

    我成功地将 Box2D 安装到我的项目中 但我怎样才能渲染身体呢 假设我正在使用支持绘制多边形的东西 我只想找出主体多边形顶点的当前位置 以便用引擎绘制它 如果你能帮助我 我将非常感激 我找到了 void Box2DUtils DrawBo
  • C# 继承:更改派生类中的字段数据类型和值

    是否可以在派生类中更改基类字段数据类型和值 并且仍然调用基类方法但使用派生类值 示例代码 public class class1 protected DBContext DB get set public A DB new DBContex
  • hdfs - ls:本地异常失败:com.google.protobuf.InvalidProtocolBufferException:

    我正在尝试使用以下内容列出我在 hdfs 中的目录 ubuntu ubuntu hadoop fs ls hdfs 127 0 0 1 50075 ls Failed on local exception com google protob
  • 自动工厂注册

    我刚刚学习java 遇到了一些问题 这里我们有简单的工厂模式 public class SomeFactory public static void registerProduct String name Class
  • Swift 包和冲突的依赖项

    我见过的每个包管理器中最具挑战性的任务之一就是处理冲突的依赖关系 让我们研究以下假想的应用程序SwiftApp 这取决于一些第三方软件包 SwiftApp packageA latest email protected cdn cgi l
  • 从 AccountManager 获取基本的 google auth-token

    我想从 AccountManager 获取 Google Authtoken 我可以将其发送到我的 Web 服务 未托管在 App Engine 上 以对用户进行身份验证 我只需要电子邮件地址 最终需要他的姓名 如果不需要此权限 getAu
  • 核心数据总和性能

    我有一些理论问题要问核心数据和总和功能 我尝试将值相加核心数据表具有三种方式 获取全部并使用表达式对其进行总结 NSArray array1 self getAll self managedObjectContext int sum arr
  • 以离散的 x-y 步长“绘制”圆弧

    仅使用 x y 位置移动绘制圆弧的最佳方法是什么 例如 假设我想在点 4 4 处绘制一个半径为 4 的圆 让我们看看我的 抽屉 从 4 0 开始 每个方向的分辨率为 0 1 步 我如何创建一系列动作来完成圆圈 如果不清楚 我可以尝试更好地解
  • Qt Creator,项目套件中的编译器被忽略

    我正在运行 macOS High Sierra 10 13 2 和 Qt 5 10 0 我想在我的应用程序中使用 OpenMP 我已将以下标志添加到我的 pro 文件中 QMAKE CXXFLAGS fopenmp QMAKE LFLAGS
  • Android Studio:快照依赖项未正确更新

    我正在使用 Android Studio 8 9 我有一个 build gradle 定义了以下依赖项 compile my program commons my program commons 0 0 2 SNAPSHOT jar 此依赖
  • 如何恢复 Normalize.css 的 input[type="search"] 的 webkit 外观

    我正在使用normalize css 它确实删除了搜索输入的图标 input type search webkit search cancel button input type search webkit search decoratio
  • 如何处置 System.Windows.Media.MediaPlayer

    问题很简单 可以概括为 我怎样才能让这个 while 循环退出 System Windows Media MediaPlayer player new System Windows Media MediaPlayer WeakReferen
  • 选择要上传的文件会导致移动 Safari 崩溃

    至少在我的 iPhone 6 Plus 上 当我使用
  • 为什么我无法在 Android Studio 中安装 lldb

    我想在JNI期间设置断点 但是当我编辑配置时 我无法安装lldb插件 任何人都可以帮助我吗 安卓工作室 2 1 1 LLDB 现在可以通过集成到 Android Studio 中的 SDK 管理器来使用 该管理器位于 Android Stu
  • 属性存在但 property_exists() 返回 false;

    嗯 我真的很困惑 当我检查属性是否存在时 它返回 false if property exists pais id false 但当我调试时它告诉我它就在那里 print r pais gt id 1 print r property ex
  • 如何在 Verilog 中综合 While 循环?

    我尝试设计一个 Booth 乘法器 它在所有编译器中运行良好 包括 Modelsim Verilogger Extreme Aldec Active Hdl 和 Xilinx Isim 我知道模拟和综合是两个不同的过程 而且只有少数Veri