8x8乘法器代码和测试台不工作(shift-add-verilog)

8x8乘法器代码和测试台不工作(shift-add-verilog),verilog,Verilog,我对verilog非常陌生,正在尝试使用shift-add方法制作8x8位乘法器。我似乎无法让我的代码正常工作,我不确定这是语法问题还是逻辑错误。我还附加了testbench文件,因为我不确定是否100%正确。当我运行模拟时,它说所有的输入和输出都是z。更新:我已经将实例添加到测试台上,但仍然得到z输出和输入 `timescale 1ns / 1ps module lab6code( input [7:0] mp, mc, input start, output r

我对verilog非常陌生,正在尝试使用shift-add方法制作8x8位乘法器。我似乎无法让我的代码正常工作,我不确定这是语法问题还是逻辑错误。我还附加了testbench文件,因为我不确定是否100%正确。当我运行模拟时,它说所有的输入和输出都是z。更新:我已经将实例添加到测试台上,但仍然得到z输出和输入

 `timescale 1ns / 1ps
  module lab6code(
    input [7:0] mp, mc,
    input start,
    output reg done,
    reg state,
    reg i, // i is the variable that gets used to check a specific bit in the mplier
    reg [15:0] x, //holder
    output reg [15:0] product,
    input clk);


initial
 begin
    state=0;
    i=0;
    x=0;
 end

always @(posedge clk)
begin
    case(state)
    0:
    begin
        if(start==1)
            begin
            x[15:0] <= 4'b0000;
            x[7:0] <= mc; //assign multiplicand to holder
            state <= 1;
            end
    end

    1, 3, 5, 7, 9, 11, 13, 15:
    begin
        if(x[i]==0) //checks specific place within mplier array, shifts and moves ahead 2 states
            begin
             x = x << 1; //shifts mcand holder
             state <= state+2; //moves ahead 2 states
             i <= i + 1; //updates i so in the next case the next bit in mplier will be looked at
            end
        else //adds mplier and mcand, moves ahead one state
            begin
             x[7:0] <= x + mp; //adds mplier to the mplier register
             i <= i + 1; //updates i
            end

    end

    2, 4, 6, 8, 10, 12, 14, 16: //shifts mcand and goes to next state
    begin
        x = x << 1; //shifts mcand holder
        state <= state + 1; // moves ahead one state
    end

    17:
        begin
        state <=0;
        done = 1;
        end
       endcase
product = x;

end   


endmodule

您不是在驱动lab6code模块的所有输入,最重要的是,您不是在驱动时钟。 clk信号保持打开状态,因此它将是x,并且基于其上升沿的任何事件都不会发生。 在您的测试台上,您需要创建一个小的无限循环,它将切换该时钟,并在模块中带来一些生命

比如:

reg clk;

initial
  clk = 1'b0;

always
begin
  #10
  clk = ~clk;
end

其中#10是时钟周期的一半。

好的,我再次运行了模拟,它说mc、mp、start和CLK是z,这意味着高阻抗,所以我认为我的测试台文件有问题。你怎么知道这些值是“z”?verilog将所有变量初始化为“x”,而不是“z”。所以,你应该看“x”来代替。
reg clk;

initial
  clk = 1'b0;

always
begin
  #10
  clk = ~clk;
end