如何在 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 循环? 的相关文章

  • 在 SystemVerilog 中 fork join_none 后仅等待一些线程完成

    在 SystemVerilog 中 我需要等待在 fork join none 结构内执行的一些线程完成 但是在另一个 fork join none 结构中还有另一个永远不会结束的进程 我的代码如下所示 fork process that
  • 「Verilog学习笔记」游戏机计费程序

    专栏前言 本专栏的内容主要是记录本人学习Verilog过程中的一些知识点 刷题网站用的是牛客网 timescale 1ns 1ns module game count input rst n 异位复位信号 低电平有效 input clk 时
  • Modelsim 对 SV 的支持

    我目前正在使用 modelsim SE 5 8e 它不支持SystemVerilog 我需要使用 SystemVerilog 来设计和验证我的项目 您知道哪个版本的 Modelsim 能够很好地支持 sytemverilog 的设计和验证子
  • 使用forever和always语句

    以下两个代码都会生成一个时钟 我需要知道除了时钟生成之外 永远循环是否还有其他用途 我只在时钟一代中遇到过永远 如果只是为了这个目的 那岂不是毫无用处 initial begin clk 0 forever begin 5 clk clk
  • 如何在verilog中逐行读取文本文件?

    我有一个 SREC 文件 它是一个简单的文本文件 我想在 verilog 中逐行读取它 我怎样才能做到这一点 以下读取文件 每个时钟周期 1 行 预期的数据格式是每行一个十进制数 integer data file file handler
  • 在断言中使用“sequence.triggered”时重置感知

    我有一些断言使用triggered序列的性质 这对于检查 当 X 发生时 Y 一定在过去的某个时间发生 形式的属性很有用 让我们举一个简单的例子 给定三个信号 a b and c c仅允许在以下情况下走高 a3 个周期前为高 并且b2 个周
  • 如何在RTL中使用时钟门控?

    我正在对一些时钟进行门控latch以及我设计中的逻辑 我在综合和布局布线方面没有太多经验 在 RTL 中实现时钟门控的正确方法是什么 示例1 always comb begin gated clk clk latch update en e
  • 修改后的 baugh-wooley 算法乘法 verilog 代码不能正确乘法

    以下 verilog 源代码和 或测试平台可以很好地工作商业模拟器 iverilog https www edaplayground com x 3TuQ也形式化验证工具 yosys smtbmc https gist github com
  • Verilog:添加寄存器的各个位(组合逻辑,寄存器宽度可参数化)

    我正在尝试想出一种方法来添加寄存器的各个位 例如 if regA 111000 then regB 3 位的总和regA 1 Verilog或SystemVerilog中是否有可以直接使用的可综合函数 运算符来执行此操作 如果不是 那么问题
  • 从测试台访问 uvm_config_db 的最佳方式?

    我想在我的顶级测试平台中创建一个时钟 其周期可以通过测试进行控制 我所做的是将周期设置到 uvm config db 中并将其返回到测试台中 我必须输入 1 以确保构建阶段已完成 否则 get 返回错误值 module testbench
  • 始终块中的 Veriloggenerate/genvar

    我试图让一个模块通过 ISE 12 4 中的语法检查 但它给了我一个我不明白的错误 首先是代码片段 parameter ROWBITS 4 reg ROWBITS 1 0 temp genvar c generate always pose
  • 系统verilog中的打包向量与未打包向量

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

    我正在使用 Verilog 设计芯片 我有一个 3 位计数器 我希望当计数器处于第 8 次循环时 应该有一个时钟故障 之后就可以正常工作了 在 Verilog 设计中产生时钟故障的可能方法是什么 在时钟信号上注入毛刺的一种方法是使用forc
  • 如何在Verilog中将二维数组中的所有位设置为0?

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

    我试图弄清楚基于组合逻辑分配电线的基础知识 I have wire val wire x wire a wire b always begin if val 00 I want to assign x a if val 01 I want
  • 在测试台中显示信号名称/文字

    是否可以在 Verilog 中引用 显示信号的名称 文字 对于在 Verilog 测试台中创建通用信号检查功能来说 这将是一个有用的功能 我知道使用 display 时 m 将打印信号的范围 是否有显示信号名称的等效项 在 Verilog
  • reg 声明中的位顺序

    如果我需要使用 4 个 8 位数字 我会声明以下 reg reg 7 0 numbers 3 0 我对第一个和第二个声明 7 0 和 3 0 之间的区别感到很困惑 他们应该按什么顺序来 第一个是保留数字的大小 而第二个是保留数字的数量 还是
  • 使用正则表达式进行 Verilog 端口映射

    我有一个很长的端口映射 我想在其中替换一堆 SignalName i with SignalName SignalName i 我想我可以用正则表达式轻松地做到这一点 但我无法弄清楚如何做到这一点 有任何想法吗 假设 SignalData
  • 具有内部赋值延迟的阻塞和非阻塞语句之间的区别

    以下 2 个 verilog 代码片段有什么区别 1 always in out 5 in AND 2 always in out lt 5 in 考虑到always块中不存在其他行 输出会有什么不同吗 问题参考幻灯片 16 参见 o5 和
  • 如何匹配和删除队列中的元素?

    根据1800 2012 规格 http standards ieee org getieee 1800 download 1800 2012 pdf Queue delete input int index 删除 SystemVerilog

随机推荐

  • 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