Friday, 12 December 2014

Function of IRON BOX

module ironbox(swt,sup,clk,out);
  input [2:0]swt;
  input sup,clk;
  output reg out;
  reg [4:0]count;
  reg [2:0]preswt;
  initial
  begin
    preswt=swt;
    count=5'b00000;
  end
  always@(posedge clk)
  begin
    if (sup)
      begin
        if(preswt!=swt)
          begin
            preswt=swt;
            count=5'b00000;
          end
        else
          case(swt)
            3'b000 : out=0;
            3'b001 : begin
              if(count<=5'b00010)
                out=1;
              else if(count==5'b00101)
                begin
                  count=5'b00000;
                  out=0;
                end
              else
                out=0;
              end
            3'b010 : begin
              if(count<=5'b00100)
                out=1;
              else if(count==5'b00111)
                begin
                  out=0;
                  count=5'b00000;
                end
              else
                out=0;
              end
              3'b011 : begin
                if(count<=5'b01000)
                  out=1;
                else if(count==5'b01011)
                  begin
                    count=5'b00100;
                    out=0;
                  end
                else
                  out=0;
                end
                3'b100 : begin
                  if(count<=5'b01100)
                    out=1;
                  else if(count==5'b10001)
                    begin
                      count=5'b00111;
                      out=0;
                    end
                  else
                    out=0;
                  end
                  default : out=0;
                endcase
               count=count+1;
              end
            else
              begin
                count=5'b00000;
                out=0;
              end
            end
          endmodule

No comments:

Post a Comment