Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 29.94 KB | None | 0 0
  1. # Starting Jump command simulation
  2. # ================================
  3. # Check Fetch state
  4. # Check Decode / Register Fetch state
  5. # Check execute1 state
  6. # Finished Jump command simulation!
  7. #  
  8. # Starting LW command simulation
  9. # ==============================
  10. # Check Fetch state
  11. # Check Decode / Register Fetch state
  12. # Check execute1 state
  13. # Check execute2 state
  14. # Check execute3 state
  15. # Finished LW command simulation!
  16. #  
  17. # Starting SW command simulation
  18. # ==============================
  19. # Check Fetch state
  20. # Check Decode / Register Fetch state
  21. # Check execute1 state
  22. # Check execute2 state
  23. # Finished SW command simulation!
  24. #  
  25. # Starting BEQ command simulation
  26. # ===============================
  27. # Check Fetch state
  28. # Check Decode / Register Fetch state
  29. # Check execute1 state
  30. # Finished BEQ command simulation!
  31. #  
  32. # Starting RTYPE command simulation
  33. # =================================
  34. # Check Fetch state
  35. # Check Decode / Register Fetch state
  36. # Check execute1 state
  37. # Check execute2 state
  38. # failed on checking RTYPE command EXEC2 state on output ALUOp      
  39. # failed on checking RTYPE command EXEC2 state on output ALUSrcA    
  40. # Finished RTYPE command simulation!
  41. #  
  42. # Done!
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. module test_controller;
  51.  
  52. reg [5:0] Op;
  53. reg Clk;
  54. wire [1:0] ALUOp, ALUSrcB, PCSource;
  55. wire PCWriteCond, PCWrite, lorD, MemRead, MemWrite, MemtoReg, IRWrite, ALUSrcA, RegWrite, RegDst;
  56.  
  57.  // OpCode constants
  58.  parameter RTYPE = 6'h00;
  59.  parameter LW = 6'h23;
  60.  parameter SW = 6'h2b;
  61.  parameter BEQ = 6'h04;
  62.  parameter J = 6'h02;
  63.  
  64.  
  65.   controller U0 (
  66.   .Op      (Op),
  67.   .Clk     (Clk),
  68.   .ALUOp   (ALUOp),
  69.   .ALUSrcB  (ALUSrcB),
  70.   .PCSource    (PCSource),
  71.   .PCWriteCond  (PCWriteCond),
  72.   .PCWrite (PCWrite),
  73.   .lorD  (lorD),
  74.   .MemRead    (MemRead),
  75.   .MemWrite  (MemWrite),
  76.   .MemtoReg (MemtoReg),
  77.   .IRWrite  (IRWrite) ,
  78.   .ALUSrcA  (ALUSrcA),
  79.   .RegWrite (RegWrite),
  80.   .RegDst  (RegDst)
  81.   );
  82.  
  83.  
  84. initial begin
  85.   Clk = 0;
  86.   Op = J;
  87.   $display("Starting Jump command simulation");
  88.   $display("================================");
  89.  
  90.   #1;
  91.   $display("Check Fetch state");
  92.     if (ALUOp       !== 2'b00) $display("failed on checking JUMP command FETCH state on output ALUOp       ");
  93.     if (ALUSrcB     !== 2'b01) $display("failed on checking JUMP command FETCH state on output ALUSrcB     ");
  94.     if (PCSource    !== 2'b00) $display("failed on checking JUMP command FETCH state on output PCSource    ");
  95.     if (PCWriteCond !== 0    ) $display("failed on checking JUMP command FETCH state on output PCWriteCond ");
  96.     if (PCWrite     !== 1    ) $display("failed on checking JUMP command FETCH state on output PCWrite     ");
  97.     if (lorD        !== 0    ) $display("failed on checking JUMP command FETCH state on output lorD        ");
  98.     if (MemRead     !== 1    ) $display("failed on checking JUMP command FETCH state on output MemRead     ");
  99.     if (MemWrite    !== 0    ) $display("failed on checking JUMP command FETCH state on output MemWrite    ");
  100.     if (MemtoReg    !== 0    ) $display("failed on checking JUMP command FETCH state on output MemtoReg    ");
  101.     if (IRWrite     !== 1    ) $display("failed on checking JUMP command FETCH state on output IRWrite     ");
  102.     if (ALUSrcA     !== 0    ) $display("failed on checking JUMP command FETCH state on output ALUSrcA     ");
  103.     if (RegWrite    !== 0    ) $display("failed on checking JUMP command FETCH state on output RegWrite    ");
  104.     if (RegDst      !== 0    ) $display("failed on checking JUMP command FETCH state on output RegDst      ");
  105.  
  106.   #2;
  107.   $display("Check Decode / Register Fetch state");
  108.     if (ALUOp       !== 2'b00) $display("failed on checking JUMP command DECODE state on output ALUOp       ");
  109.     if (ALUSrcB     !== 2'b11) $display("failed on checking JUMP command DECODE state on output ALUSrcB     ");
  110.     if (PCSource    !== 2'b00) $display("failed on checking JUMP command DECODE state on output PCSource    ");
  111.     if (PCWriteCond !== 0    ) $display("failed on checking JUMP command DECODE state on output PCWriteCond ");
  112.     if (PCWrite     !== 0    ) $display("failed on checking JUMP command DECODE state on output PCWrite     ");
  113.     if (lorD        !== 0    ) $display("failed on checking JUMP command DECODE state on output lorD        ");
  114.     if (MemRead     !== 0    ) $display("failed on checking JUMP command DECODE state on output MemRead     ");
  115.     if (MemWrite    !== 0    ) $display("failed on checking JUMP command DECODE state on output MemWrite    ");
  116.     if (MemtoReg    !== 0    ) $display("failed on checking JUMP command DECODE state on output MemtoReg    ");
  117.     if (IRWrite     !== 0    ) $display("failed on checking JUMP command DECODE state on output IRWrite     ");
  118.     if (ALUSrcA     !== 0    ) $display("failed on checking JUMP command DECODE state on output ALUSrcA     ");
  119.     if (RegWrite    !== 0    ) $display("failed on checking JUMP command DECODE state on output RegWrite    ");
  120.     if (RegDst      !== 0    ) $display("failed on checking JUMP command DECODE state on output RegDst      ");
  121.  
  122.   #2;
  123.   $display("Check execute1 state");
  124.     if (ALUOp       !== 2'b00) $display("failed on checking JUMP command EXEC1 state on output ALUOp       ");
  125.     if (ALUSrcB     !== 2'b00) $display("failed on checking JUMP command EXEC1 state on output ALUSrcB     ");
  126.     if (PCSource    !== 2'b10) $display("failed on checking JUMP command EXEC1 state on output PCSource    ");
  127.     if (PCWriteCond !== 0    ) $display("failed on checking JUMP command EXEC1 state on output PCWriteCond ");
  128.     if (PCWrite     !== 1    ) $display("failed on checking JUMP command EXEC1 state on output PCWrite     ");
  129.     if (lorD        !== 0    ) $display("failed on checking JUMP command EXEC1 state on output lorD        ");
  130.     if (MemRead     !== 0    ) $display("failed on checking JUMP command EXEC1 state on output MemRead     ");
  131.     if (MemWrite    !== 0    ) $display("failed on checking JUMP command EXEC1 state on output MemWrite    ");
  132.     if (MemtoReg    !== 0    ) $display("failed on checking JUMP command EXEC1 state on output MemtoReg    ");
  133.     if (IRWrite     !== 0    ) $display("failed on checking JUMP command EXEC1 state on output IRWrite     ");
  134.     if (ALUSrcA     !== 0    ) $display("failed on checking JUMP command EXEC1 state on output ALUSrcA     ");
  135.     if (RegWrite    !== 0    ) $display("failed on checking JUMP command EXEC1 state on output RegWrite    ");
  136.     if (RegDst      !== 0    ) $display("failed on checking JUMP command EXEC1 state on output RegDst      ");
  137.  
  138.   $display("Finished Jump command simulation!");
  139.   $display(" ");
  140.   $display("Starting LW command simulation");
  141.   $display("==============================");
  142.   Op = LW;
  143.  
  144.   #2;
  145.   $display("Check Fetch state");
  146.     if (ALUOp       !== 2'b00) $display("failed on checking LW command FETCH state on output ALUOp       ");
  147.     if (ALUSrcB     !== 2'b01) $display("failed on checking LW command FETCH state on output ALUSrcB     ");
  148.     if (PCSource    !== 2'b00) $display("failed on checking LW command FETCH state on output PCSource    ");
  149.     if (PCWriteCond !== 0    ) $display("failed on checking LW command FETCH state on output PCWriteCond ");
  150.     if (PCWrite     !== 1    ) $display("failed on checking LW command FETCH state on output PCWrite     ");
  151.     if (lorD        !== 0    ) $display("failed on checking LW command FETCH state on output lorD        ");
  152.     if (MemRead     !== 1    ) $display("failed on checking LW command FETCH state on output MemRead     ");
  153.     if (MemWrite    !== 0    ) $display("failed on checking LW command FETCH state on output MemWrite    ");
  154.     if (MemtoReg    !== 0    ) $display("failed on checking LW command FETCH state on output MemtoReg    ");
  155.     if (IRWrite     !== 1    ) $display("failed on checking LW command FETCH state on output IRWrite     ");
  156.     if (ALUSrcA     !== 0    ) $display("failed on checking LW command FETCH state on output ALUSrcA     ");
  157.     if (RegWrite    !== 0    ) $display("failed on checking LW command FETCH state on output RegWrite    ");
  158.     if (RegDst      !== 0    ) $display("failed on checking LW command FETCH state on output RegDst      ");
  159.  
  160.   #2;
  161.   $display("Check Decode / Register Fetch state");
  162.     if (ALUOp       !== 2'b00) $display("failed on checking LW command DECODE state on output ALUOp       ");
  163.     if (ALUSrcB     !== 2'b11) $display("failed on checking LW command DECODE state on output ALUSrcB     ");
  164.     if (PCSource    !== 2'b00) $display("failed on checking LW command DECODE state on output PCSource    ");
  165.     if (PCWriteCond !== 0    ) $display("failed on checking LW command DECODE state on output PCWriteCond ");
  166.     if (PCWrite     !== 0    ) $display("failed on checking LW command DECODE state on output PCWrite     ");
  167.     if (lorD        !== 0    ) $display("failed on checking LW command DECODE state on output lorD        ");
  168.     if (MemRead     !== 0    ) $display("failed on checking LW command DECODE state on output MemRead     ");
  169.     if (MemWrite    !== 0    ) $display("failed on checking LW command DECODE state on output MemWrite    ");
  170.     if (MemtoReg    !== 0    ) $display("failed on checking LW command DECODE state on output MemtoReg    ");
  171.     if (IRWrite     !== 0    ) $display("failed on checking LW command DECODE state on output IRWrite     ");
  172.     if (ALUSrcA     !== 0    ) $display("failed on checking LW command DECODE state on output ALUSrcA     ");
  173.     if (RegWrite    !== 0    ) $display("failed on checking LW command DECODE state on output RegWrite    ");
  174.     if (RegDst      !== 0    ) $display("failed on checking LW command DECODE state on output RegDst      ");
  175.  
  176.   #2;
  177.   $display("Check execute1 state");
  178.     if (ALUOp       !== 2'b00) $display("failed on checking LW command EXEC1 state on output ALUOp       ");
  179.     if (ALUSrcB     !== 2'b10) $display("failed on checking LW command EXEC1 state on output ALUSrcB     ");
  180.     if (PCSource    !== 2'b00) $display("failed on checking LW command EXEC1 state on output PCSource    ");
  181.     if (PCWriteCond !== 0    ) $display("failed on checking LW command EXEC1 state on output PCWriteCond ");
  182.     if (PCWrite     !== 0    ) $display("failed on checking LW command EXEC1 state on output PCWrite     ");
  183.     if (lorD        !== 0    ) $display("failed on checking LW command EXEC1 state on output lorD        ");
  184.     if (MemRead     !== 0    ) $display("failed on checking LW command EXEC1 state on output MemRead     ");
  185.     if (MemWrite    !== 0    ) $display("failed on checking LW command EXEC1 state on output MemWrite    ");
  186.     if (MemtoReg    !== 0    ) $display("failed on checking LW command EXEC1 state on output MemtoReg    ");
  187.     if (IRWrite     !== 0    ) $display("failed on checking LW command EXEC1 state on output IRWrite     ");
  188.     if (ALUSrcA     !== 1    ) $display("failed on checking LW command EXEC1 state on output ALUSrcA     ");
  189.     if (RegWrite    !== 0    ) $display("failed on checking LW command EXEC1 state on output RegWrite    ");
  190.     if (RegDst      !== 0    ) $display("failed on checking LW command EXEC1 state on output RegDst      ");
  191.  
  192.   #2;
  193.   $display("Check execute2 state");
  194.     if (ALUOp       !== 2'b00) $display("failed on checking LW command EXEC2 state on output ALUOp       ");
  195.     if (ALUSrcB     !== 2'b10) $display("failed on checking LW command EXEC2 state on output ALUSrcB     ");
  196.     if (PCSource    !== 2'b00) $display("failed on checking LW command EXEC2 state on output PCSource    ");
  197.     if (PCWriteCond !== 0    ) $display("failed on checking LW command EXEC2 state on output PCWriteCond ");
  198.     if (PCWrite     !== 0    ) $display("failed on checking LW command EXEC2 state on output PCWrite     ");
  199.     if (lorD        !== 1    ) $display("failed on checking LW command EXEC2 state on output lorD        ");
  200.     if (MemRead     !== 1    ) $display("failed on checking LW command EXEC2 state on output MemRead     ");
  201.     if (MemWrite    !== 0    ) $display("failed on checking LW command EXEC2 state on output MemWrite    ");
  202.     if (MemtoReg    !== 0    ) $display("failed on checking LW command EXEC2 state on output MemtoReg    ");
  203.     if (IRWrite     !== 0    ) $display("failed on checking LW command EXEC2 state on output IRWrite     ");
  204.     if (ALUSrcA     !== 1    ) $display("failed on checking LW command EXEC2 state on output ALUSrcA     ");
  205.     if (RegWrite    !== 0    ) $display("failed on checking LW command EXEC2 state on output RegWrite    ");
  206.     if (RegDst      !== 0    ) $display("failed on checking LW command EXEC2 state on output RegDst      ");
  207.  
  208.   #2;
  209.   $display("Check execute3 state");
  210.     if (ALUOp       !== 2'b00) $display("failed on checking LW command EXEC3 state on output ALUOp       ");
  211.     if (ALUSrcB     !== 2'b10) $display("failed on checking LW command EXEC3 state on output ALUSrcB     ");
  212.     if (PCSource    !== 2'b00) $display("failed on checking LW command EXEC3 state on output PCSource    ");
  213.     if (PCWriteCond !== 0    ) $display("failed on checking LW command EXEC3 state on output PCWriteCond ");
  214.     if (PCWrite     !== 0    ) $display("failed on checking LW command EXEC3 state on output PCWrite     ");
  215.     if (lorD        !== 0    ) $display("failed on checking LW command EXEC3 state on output lorD        ");
  216.     if (MemRead     !== 0    ) $display("failed on checking LW command EXEC3 state on output MemRead     ");
  217.     if (MemWrite    !== 0    ) $display("failed on checking LW command EXEC3 state on output MemWrite    ");
  218.     if (MemtoReg    !== 1    ) $display("failed on checking LW command EXEC3 state on output MemtoReg    ");
  219.     if (IRWrite     !== 0    ) $display("failed on checking LW command EXEC3 state on output IRWrite     ");
  220.     if (ALUSrcA     !== 1    ) $display("failed on checking LW command EXEC3 state on output ALUSrcA     ");
  221.     if (RegWrite    !== 1    ) $display("failed on checking LW command EXEC3 state on output RegWrite    ");
  222.     if (RegDst      !== 0    ) $display("failed on checking LW command EXEC3 state on output RegDst      ");
  223.  
  224.   $display("Finished LW command simulation!");
  225.   $display(" ");
  226.   $display("Starting SW command simulation");
  227.   $display("==============================");
  228.   Op = SW;
  229.  
  230.   #2;
  231.   $display("Check Fetch state");
  232.     if (ALUOp       !== 2'b00) $display("failed on checking SW command FETCH state on output ALUOp       ");
  233.     if (ALUSrcB     !== 2'b01) $display("failed on checking SW command FETCH state on output ALUSrcB     ");
  234.     if (PCSource    !== 2'b00) $display("failed on checking SW command FETCH state on output PCSource    ");
  235.     if (PCWriteCond !== 0    ) $display("failed on checking SW command FETCH state on output PCWriteCond ");
  236.     if (PCWrite     !== 1    ) $display("failed on checking SW command FETCH state on output PCWrite     ");
  237.     if (lorD        !== 0    ) $display("failed on checking SW command FETCH state on output lorD        ");
  238.     if (MemRead     !== 1    ) $display("failed on checking SW command FETCH state on output MemRead     ");
  239.     if (MemWrite    !== 0    ) $display("failed on checking SW command FETCH state on output MemWrite    ");
  240.     if (MemtoReg    !== 0    ) $display("failed on checking SW command FETCH state on output MemtoReg    ");
  241.     if (IRWrite     !== 1    ) $display("failed on checking SW command FETCH state on output IRWrite     ");
  242.     if (ALUSrcA     !== 0    ) $display("failed on checking SW command FETCH state on output ALUSrcA     ");
  243.     if (RegWrite    !== 0    ) $display("failed on checking SW command FETCH state on output RegWrite    ");
  244.     if (RegDst      !== 0    ) $display("failed on checking SW command FETCH state on output RegDst      ");
  245.  
  246.   #2;
  247.   $display("Check Decode / Register Fetch state");
  248.     if (ALUOp       !== 2'b00) $display("failed on checking SW command DECODE state on output ALUOp       ");
  249.     if (ALUSrcB     !== 2'b11) $display("failed on checking SW command DECODE state on output ALUSrcB     ");
  250.     if (PCSource    !== 2'b00) $display("failed on checking SW command DECODE state on output PCSource    ");
  251.     if (PCWriteCond !== 0    ) $display("failed on checking SW command DECODE state on output PCWriteCond ");
  252.     if (PCWrite     !== 0    ) $display("failed on checking SW command DECODE state on output PCWrite     ");
  253.     if (lorD        !== 0    ) $display("failed on checking SW command DECODE state on output lorD        ");
  254.     if (MemRead     !== 0    ) $display("failed on checking SW command DECODE state on output MemRead     ");
  255.     if (MemWrite    !== 0    ) $display("failed on checking SW command DECODE state on output MemWrite    ");
  256.     if (MemtoReg    !== 0    ) $display("failed on checking SW command DECODE state on output MemtoReg    ");
  257.     if (IRWrite     !== 0    ) $display("failed on checking SW command DECODE state on output IRWrite     ");
  258.     if (ALUSrcA     !== 0    ) $display("failed on checking SW command DECODE state on output ALUSrcA     ");
  259.     if (RegWrite    !== 0    ) $display("failed on checking SW command DECODE state on output RegWrite    ");
  260.     if (RegDst      !== 0    ) $display("failed on checking SW command DECODE state on output RegDst      ");
  261.  
  262.   #2;
  263.   $display("Check execute1 state");
  264.     if (ALUOp       !== 2'b00) $display("failed on checking SW command EXEC1 state on output ALUOp       ");
  265.     if (ALUSrcB     !== 2'b10) $display("failed on checking SW command EXEC1 state on output ALUSrcB     ");
  266.     if (PCSource    !== 2'b00) $display("failed on checking SW command EXEC1 state on output PCSource    ");
  267.     if (PCWriteCond !== 0    ) $display("failed on checking SW command EXEC1 state on output PCWriteCond ");
  268.     if (PCWrite     !== 0    ) $display("failed on checking SW command EXEC1 state on output PCWrite     ");
  269.     if (lorD        !== 0    ) $display("failed on checking SW command EXEC1 state on output lorD        ");
  270.     if (MemRead     !== 0    ) $display("failed on checking SW command EXEC1 state on output MemRead     ");
  271.     if (MemWrite    !== 0    ) $display("failed on checking SW command EXEC1 state on output MemWrite    ");
  272.     if (MemtoReg    !== 0    ) $display("failed on checking SW command EXEC1 state on output MemtoReg    ");
  273.     if (IRWrite     !== 0    ) $display("failed on checking SW command EXEC1 state on output IRWrite     ");
  274.     if (ALUSrcA     !== 1    ) $display("failed on checking SW command EXEC1 state on output ALUSrcA     ");
  275.     if (RegWrite    !== 0    ) $display("failed on checking SW command EXEC1 state on output RegWrite    ");
  276.     if (RegDst      !== 0    ) $display("failed on checking SW command EXEC1 state on output RegDst      ");
  277.  
  278.   #2;
  279.   $display("Check execute2 state");
  280.     if (ALUOp       !== 2'b00) $display("failed on checking SW command EXEC2 state on output ALUOp       ");
  281.     if (ALUSrcB     !== 2'b10) $display("failed on checking SW command EXEC2 state on output ALUSrcB     ");
  282.     if (PCSource    !== 2'b00) $display("failed on checking SW command EXEC2 state on output PCSource    ");
  283.     if (PCWriteCond !== 0    ) $display("failed on checking SW command EXEC2 state on output PCWriteCond ");
  284.     if (PCWrite     !== 0    ) $display("failed on checking SW command EXEC2 state on output PCWrite     ");
  285.     if (lorD        !== 1    ) $display("failed on checking SW command EXEC2 state on output lorD        ");
  286.     if (MemRead     !== 0    ) $display("failed on checking SW command EXEC2 state on output MemRead     ");
  287.     if (MemWrite    !== 1    ) $display("failed on checking SW command EXEC2 state on output MemWrite    ");
  288.     if (MemtoReg    !== 0    ) $display("failed on checking SW command EXEC2 state on output MemtoReg    ");
  289.     if (IRWrite     !== 0    ) $display("failed on checking SW command EXEC2 state on output IRWrite     ");
  290.     if (ALUSrcA     !== 1    ) $display("failed on checking SW command EXEC2 state on output ALUSrcA     ");
  291.     if (RegWrite    !== 0    ) $display("failed on checking SW command EXEC2 state on output RegWrite    ");
  292.     if (RegDst      !== 0    ) $display("failed on checking SW command EXEC2 state on output RegDst      ");
  293.  
  294.   $display("Finished SW command simulation!");
  295.   $display(" ");
  296.   $display("Starting BEQ command simulation");
  297.   $display("===============================");
  298.   Op = BEQ;
  299.  
  300.   #2;
  301.   $display("Check Fetch state");
  302.     if (ALUOp       !== 2'b00) $display("failed on checking BEQ command FETCH state on output ALUOp       ");
  303.     if (ALUSrcB     !== 2'b01) $display("failed on checking BEQ command FETCH state on output ALUSrcB     ");
  304.     if (PCSource    !== 2'b00) $display("failed on checking BEQ command FETCH state on output PCSource    ");
  305.     if (PCWriteCond !== 0    ) $display("failed on checking BEQ command FETCH state on output PCWriteCond ");
  306.     if (PCWrite     !== 1    ) $display("failed on checking BEQ command FETCH state on output PCWrite     ");
  307.     if (lorD        !== 0    ) $display("failed on checking BEQ command FETCH state on output lorD        ");
  308.     if (MemRead     !== 1    ) $display("failed on checking BEQ command FETCH state on output MemRead     ");
  309.     if (MemWrite    !== 0    ) $display("failed on checking BEQ command FETCH state on output MemWrite    ");
  310.     if (MemtoReg    !== 0    ) $display("failed on checking BEQ command FETCH state on output MemtoReg    ");
  311.     if (IRWrite     !== 1    ) $display("failed on checking BEQ command FETCH state on output IRWrite     ");
  312.     if (ALUSrcA     !== 0    ) $display("failed on checking BEQ command FETCH state on output ALUSrcA     ");
  313.     if (RegWrite    !== 0    ) $display("failed on checking BEQ command FETCH state on output RegWrite    ");
  314.     if (RegDst      !== 0    ) $display("failed on checking BEQ command FETCH state on output RegDst      ");
  315.  
  316.   #2;
  317.   $display("Check Decode / Register Fetch state");
  318.     if (ALUOp       !== 2'b00) $display("failed on checking BEQ command DECODE state on output ALUOp       ");
  319.     if (ALUSrcB     !== 2'b11) $display("failed on checking BEQ command DECODE state on output ALUSrcB     ");
  320.     if (PCSource    !== 2'b00) $display("failed on checking BEQ command DECODE state on output PCSource    ");
  321.     if (PCWriteCond !== 0    ) $display("failed on checking BEQ command DECODE state on output PCWriteCond ");
  322.     if (PCWrite     !== 0    ) $display("failed on checking BEQ command DECODE state on output PCWrite     ");
  323.     if (lorD        !== 0    ) $display("failed on checking BEQ command DECODE state on output lorD        ");
  324.     if (MemRead     !== 0    ) $display("failed on checking BEQ command DECODE state on output MemRead     ");
  325.     if (MemWrite    !== 0    ) $display("failed on checking BEQ command DECODE state on output MemWrite    ");
  326.     if (MemtoReg    !== 0    ) $display("failed on checking BEQ command DECODE state on output MemtoReg    ");
  327.     if (IRWrite     !== 0    ) $display("failed on checking BEQ command DECODE state on output IRWrite     ");
  328.     if (ALUSrcA     !== 0    ) $display("failed on checking BEQ command DECODE state on output ALUSrcA     ");
  329.     if (RegWrite    !== 0    ) $display("failed on checking BEQ command DECODE state on output RegWrite    ");
  330.     if (RegDst      !== 0    ) $display("failed on checking BEQ command DECODE state on output RegDst      ");
  331.  
  332.   #2;
  333.   $display("Check execute1 state");
  334.     if (ALUOp       !== 2'b01) $display("failed on checking BEQ command EXEC1 state on output ALUOp       ");
  335.     if (ALUSrcB     !== 2'b00) $display("failed on checking BEQ command EXEC1 state on output ALUSrcB     ");
  336.     if (PCSource    !== 2'b01) $display("failed on checking BEQ command EXEC1 state on output PCSource    ");
  337.     if (PCWriteCond !== 1    ) $display("failed on checking BEQ command EXEC1 state on output PCWriteCond ");
  338.     if (PCWrite     !== 0    ) $display("failed on checking BEQ command EXEC1 state on output PCWrite     ");
  339.     if (lorD        !== 0    ) $display("failed on checking BEQ command EXEC1 state on output lorD        ");
  340.     if (MemRead     !== 0    ) $display("failed on checking BEQ command EXEC1 state on output MemRead     ");
  341.     if (MemWrite    !== 0    ) $display("failed on checking BEQ command EXEC1 state on output MemWrite    ");
  342.     if (MemtoReg    !== 0    ) $display("failed on checking BEQ command EXEC1 state on output MemtoReg    ");
  343.     if (IRWrite     !== 0    ) $display("failed on checking BEQ command EXEC1 state on output IRWrite     ");
  344.     if (ALUSrcA     !== 1    ) $display("failed on checking BEQ command EXEC1 state on output ALUSrcA     ");
  345.     if (RegWrite    !== 0    ) $display("failed on checking BEQ command EXEC1 state on output RegWrite    ");
  346.     if (RegDst      !== 0    ) $display("failed on checking BEQ command EXEC1 state on output RegDst      ");
  347.  
  348.   $display("Finished BEQ command simulation!");
  349.   $display(" ");
  350.   $display("Starting RTYPE command simulation");
  351.   $display("=================================");
  352.   Op = RTYPE;
  353.  
  354.   #2;
  355.   $display("Check Fetch state");
  356.     if (ALUOp       !== 2'b00) $display("failed on checking RTYPE command FETCH state on output ALUOp       ");
  357.     if (ALUSrcB     !== 2'b01) $display("failed on checking RTYPE command FETCH state on output ALUSrcB     ");
  358.     if (PCSource    !== 2'b00) $display("failed on checking RTYPE command FETCH state on output PCSource    ");
  359.     if (PCWriteCond !== 0    ) $display("failed on checking RTYPE command FETCH state on output PCWriteCond ");
  360.     if (PCWrite     !== 1    ) $display("failed on checking RTYPE command FETCH state on output PCWrite     ");
  361.     if (lorD        !== 0    ) $display("failed on checking RTYPE command FETCH state on output lorD        ");
  362.     if (MemRead     !== 1    ) $display("failed on checking RTYPE command FETCH state on output MemRead     ");
  363.     if (MemWrite    !== 0    ) $display("failed on checking RTYPE command FETCH state on output MemWrite    ");
  364.     if (MemtoReg    !== 0    ) $display("failed on checking RTYPE command FETCH state on output MemtoReg    ");
  365.     if (IRWrite     !== 1    ) $display("failed on checking RTYPE command FETCH state on output IRWrite     ");
  366.     if (ALUSrcA     !== 0    ) $display("failed on checking RTYPE command FETCH state on output ALUSrcA     ");
  367.     if (RegWrite    !== 0    ) $display("failed on checking RTYPE command FETCH state on output RegWrite    ");
  368.     if (RegDst      !== 0    ) $display("failed on checking RTYPE command FETCH state on output RegDst      ");
  369.  
  370.   #2;
  371.   $display("Check Decode / Register Fetch state");
  372.     if (ALUOp       !== 2'b00) $display("failed on checking RTYPE command DECODE state on output ALUOp       ");
  373.     if (ALUSrcB     !== 2'b11) $display("failed on checking RTYPE command DECODE state on output ALUSrcB     ");
  374.     if (PCSource    !== 2'b00) $display("failed on checking RTYPE command DECODE state on output PCSource    ");
  375.     if (PCWriteCond !== 0    ) $display("failed on checking RTYPE command DECODE state on output PCWriteCond ");
  376.     if (PCWrite     !== 0    ) $display("failed on checking RTYPE command DECODE state on output PCWrite     ");
  377.     if (lorD        !== 0    ) $display("failed on checking RTYPE command DECODE state on output lorD        ");
  378.     if (MemRead     !== 0    ) $display("failed on checking RTYPE command DECODE state on output MemRead     ");
  379.     if (MemWrite    !== 0    ) $display("failed on checking RTYPE command DECODE state on output MemWrite    ");
  380.     if (MemtoReg    !== 0    ) $display("failed on checking RTYPE command DECODE state on output MemtoReg    ");
  381.     if (IRWrite     !== 0    ) $display("failed on checking RTYPE command DECODE state on output IRWrite     ");
  382.     if (ALUSrcA     !== 0    ) $display("failed on checking RTYPE command DECODE state on output ALUSrcA     ");
  383.     if (RegWrite    !== 0    ) $display("failed on checking RTYPE command DECODE state on output RegWrite    ");
  384.     if (RegDst      !== 0    ) $display("failed on checking RTYPE command DECODE state on output RegDst      ");
  385.  
  386.   #2;
  387.   $display("Check execute1 state");
  388.     if (ALUOp       !== 2'b10) $display("failed on checking RTYPE command EXEC1 state on output ALUOp       ");
  389.     if (ALUSrcB     !== 2'b00) $display("failed on checking RTYPE command EXEC1 state on output ALUSrcB     ");
  390.     if (PCSource    !== 2'b00) $display("failed on checking RTYPE command EXEC1 state on output PCSource    ");
  391.     if (PCWriteCond !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output PCWriteCond ");
  392.     if (PCWrite     !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output PCWrite     ");
  393.     if (lorD        !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output lorD        ");
  394.     if (MemRead     !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output MemRead     ");
  395.     if (MemWrite    !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output MemWrite    ");
  396.     if (MemtoReg    !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output MemtoReg    ");
  397.     if (IRWrite     !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output IRWrite     ");
  398.     if (ALUSrcA     !== 1    ) $display("failed on checking RTYPE command EXEC1 state on output ALUSrcA     ");
  399.     if (RegWrite    !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output RegWrite    ");
  400.     if (RegDst      !== 0    ) $display("failed on checking RTYPE command EXEC1 state on output RegDst      ");
  401.  
  402.   #2;
  403.   $display("Check execute2 state");
  404.     if (ALUOp       !== 2'b10) $display("failed on checking RTYPE command EXEC2 state on output ALUOp       ");
  405.     if (ALUSrcB     !== 2'b00) $display("failed on checking RTYPE command EXEC2 state on output ALUSrcB     ");
  406.     if (PCSource    !== 2'b00) $display("failed on checking RTYPE command EXEC2 state on output PCSource    ");
  407.     if (PCWriteCond !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output PCWriteCond ");
  408.     if (PCWrite     !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output PCWrite     ");
  409.     if (lorD        !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output lorD        ");
  410.     if (MemRead     !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output MemRead     ");
  411.     if (MemWrite    !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output MemWrite    ");
  412.     if (MemtoReg    !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output MemtoReg    ");
  413.     if (IRWrite     !== 0    ) $display("failed on checking RTYPE command EXEC2 state on output IRWrite     ");
  414.     if (ALUSrcA     !== 1    ) $display("failed on checking RTYPE command EXEC2 state on output ALUSrcA     ");
  415.     if (RegWrite    !== 1    ) $display("failed on checking RTYPE command EXEC2 state on output RegWrite    ");
  416.     if (RegDst      !== 1    ) $display("failed on checking RTYPE command EXEC2 state on output RegDst      ");
  417.   $display("Finished RTYPE command simulation!");
  418.   $display(" ");
  419.   $display("Done!");
  420. end
  421.  
  422. always begin
  423.    #1 Clk = !Clk;
  424. end
  425.  
  426. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement