0

So I'm getting a syntax error for my program counter test bench and I can not figure out why I keep getting Following verilog source has syntax error: "pc_tb.v", 20: token is 'initial' initial ^

Am i using initial wrong? Making a pipelined datapath and this the only part I got that isn't working for me so far

//PC_TB.V USED TO TEST THE PC MODULE
`include"pc.v"
module pc_tb;
wire[15:0]out;
reg stall,hold
reg[9:0]Mux,Haz
reg[7:0]Mem[0:65535];
ProgramCounter g1(stall,hold,Mem,out,Mux,Haz);
initial begin
stall=1'b0
hold=1'b0;
Mem=0;
Mux=9'b000000010;
Haz=9'b000000000;
#5 Mem[2]=1;
#10 hold=1'b1;
#30 halt=1'b1;
#40 
initial
#100 $finish;
end
endmodule
Nuf
  • 1
  • 4
  • 3
    Please indent your code, then you will see your missing an end for your first initial statement. – Morgan May 02 '16 at 09:50

1 Answers1

2

You cannot declare another initial block inside an initial block, so you need to close your begin (heres the corrected code, see comments for corrections):

//PC_TB.V USED TO TEST THE PC MODULE
`include"pc.v"
`define MEM_SIZE 65535

module pc_tb;
  wire [15:0] out;
  reg stall, hold; // Missing ;
  reg [9:0] Mux, Haz; // Missing ;
  reg [7:0] Mem[0:`MEM_SIZE-1]; // Convert to macro
  integer i;

  ProgramCounter g1(stall, hold, Mem, out, Mux, Haz);

  // First initial block
  initial begin
    stall = 1'b0; // Missing ;
    hold = 1'b0;
    // Canot set unpacked array to 0, need to loop through to set each element
    for (i = 0; i < `MEM_SIZE; i = i + 1) begin
      Mem[i] = 8'd0;
    end
    Mux = 9'b000000010;
    Haz = 9'b000000000;

    #5 Mem[2] = 1;
    #10 hold = 1'b1;
    #30 halt = 1'b1; // halt undeclared, not sure what you meant to do here
    // #40 does nothing here
  end // This end was missing 

  // Second initial block
  initial begin
    #100 $finish; // 100 time units from start, simulation will terminate
  end
endmodule
Unn
  • 4,775
  • 18
  • 30