Modelsim displays unknown or garbage number in transcript

168 views Asked by At

I'm trying to write a testbench to test my processor using the $display() statement.

But I don't know why there are unexpected, there is unexpected or garbage numbers printed on the transcript.

This is the only display part of my code:

// to display 
    always @ (posedge clock)
    begin
        #1
        if (isInstruction)
        begin 
            // print the instruction number (order)
            $display ("instruction %h : ", i);
            // print thie instruction opcode
            $display ("OpCode = %h ", Processor.opCode);

            // print the instruction name
            case (Processor.opCode)

                _addi : begin
                    $display ("instruction name : ADDI");
                end
            
            endcase
        
            $display((Processor.RegWriteEn) ? "write on register file : Yes" : "write on register file : No");
            if (Processor.RegWriteEn)
            begin 
                $display ("Write on register number : %h", Processor.mux1Out);
                $display ("data written on register : %h", Processor.mux4Out);
            end
            
            $display((Processor.MemWriteEn) ? "write on Memory : Yes" : "write on Memory : No");
            if (Processor.MemWriteEn)
            begin 
                $display ("Write on address : %h", Processor.aluResult);
                $display ("data written on register : %h", Processor.data2);
            end

        end
        
        else
        
        begin
            $display ("no instruction loaded in this clock");
        end
    end

I'm still getting this output:

here is the image of the output

Each time I simulate the testbench, the same numbers are printed because of that, I don't think it is a garbage.

1

There are 1 answers

0
Abdalrahman Alshannaq On BEST ANSWER

sometimes $display statement with conditional operator makes no sense outputs

try to use :

$display("write on register file: %s", Processor.RegWriteEn ? "Yes" : "No");

instead of

$display((Processor.RegWriteEn) ? "write on register file : Yes" : "write on register file : No");

if it works, apply it to all $display statments