0

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.

0

1 Answer 1

-1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.