dpddl040h.vmd 4.14 KB

/**************************************************************/
/*    Verilog module of datapath cell dpddl040h              */
/*    Designed by  Chunling Liu    Compass    July 17, 92   */
/*    Modified by  Linda J. Xu     Compass    Nov. 23,  92   */
/*    Changed  by  Matt Rohm       SGI        May  27, 1994   */
/*    (changed to intra-assignment delays)                    */
/*                                                            */
/*    The following is the port description                   */
/*    Data ports                                              */
/*        IN    : the input port                               */
/*        A    : the tap output port                           */
/*        B    : the tap output port                           */
/*        C    : the tap output port                           */
/*        D    : the tap output port                           */
/*        OUT    : the output port                              */
/*    Control ports                                           */
/*        INST_CP    : the clock signal                       */
/*        CDN        : the activ-low clear signal             */
/*    Parameters                                              */
/*        WORDSIZE  : the word size of the datapath cell      */
/*        Number_Of_Delays   : the col size of the datapath cell */
/*        TapLocationA      : the tap A position*/
/*        TapLocationB      : the tap B position*/
/*        TapLocationC      : the tap C position*/
/*        TapLocationD      : the tap D position*/
/*        DELAY     : the delay time from input to output     */
/*                                                            */
/*    When the clock signal changes from unknown to 1 or      */
/*        from 0 to unknown while the clear signal is high,   */
/*        the output will be unknown.                         */
/**************************************************************/
module dpddl040h(IN, A, B, C, D, OUT, INST_CP, CDN);

  parameter WORDSIZE = 8, Number_of_delays = 5,
            TapLocationA = 1, TapLocationB = 2,
            TapLocationC = 3, TapLocationD = 4,
            DELAY = 10, BF = 1;
  input  [WORDSIZE-1:0] IN;
  output [WORDSIZE-1:0] A;
  output [WORDSIZE-1:0] B, C, D;
  output [WORDSIZE-1:0] OUT;
  input  INST_CP, CDN;

  reg    [WORDSIZE-1:0] A;
  reg    [WORDSIZE-1:0] B, C, D;
  reg    [WORDSIZE-1:0] OUT;
  reg    [WORDSIZE-1:0] rgf[Number_of_delays-1:0];
  reg    flag;


  initial OUT = {WORDSIZE{1'bx}};
  initial flag = 1'b0;

  function [WORDSIZE-1:0] dff;
  input  [WORDSIZE-1:0] d;
  integer i;

    begin
      if (!CDN)
        for (i = 0; i< Number_of_delays; i=i+1)
           begin
              rgf[i] = {WORDSIZE{1'b0}};
           end
      else if (CDN)
        begin
          for (i = Number_of_delays-1; i>= 1; i=i-1)
            begin
              rgf[i] = rgf[i-1];
            end
          rgf[0] = d;
        end
      dff = rgf[Number_of_delays-1];
    end
  endfunction

  always @CDN
    if (!CDN)
      begin
        assign OUT = {WORDSIZE{1'b0}};
        assign A = {WORDSIZE{1'b0}};
        assign B = {WORDSIZE{1'b0}};
        assign C = {WORDSIZE{1'b0}};
        assign D = {WORDSIZE{1'b0}};
      end
    else if (CDN)
      begin
        deassign OUT;
        deassign A;
        deassign B;
        deassign C;
        deassign D;
      end
    else
      begin
        assign OUT = {WORDSIZE{1'b x}};
        assign A = {WORDSIZE{1'b x}};
        assign B = {WORDSIZE{1'b x}};
        assign C = {WORDSIZE{1'b x}};
        assign D = {WORDSIZE{1'b x}};
      end

  always @ ( posedge INST_CP )
    if ((INST_CP === 1'b1) && (flag === 1'b0))
      begin
        OUT = #DELAY dff(IN);
        A = #DELAY rgf[TapLocationA-1];
        B = #DELAY rgf[TapLocationB-1];
        C = #DELAY rgf[TapLocationC-1];
        D = #DELAY rgf[TapLocationD-1];
      end
    else
      begin
        OUT = {WORDSIZE{1'b x}};
        A = {WORDSIZE{1'b x}};
        B = {WORDSIZE{1'b x}};
        C = {WORDSIZE{1'b x}};
        D = {WORDSIZE{1'b x}};
        flag = 1'b1;
      end

  always @ (negedge INST_CP)
    if (INST_CP === 1'b0)
      flag = 1'b0;
    else
      flag = 1'b1;

endmodule