OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_36/] [or1ksim/] [cuc/] [verilog.c] - Diff between revs 997 and 1001

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 997 Rev 1001
Line 531... Line 531...
    GEN ("\n/* Memory stores */\n");
    GEN ("\n/* Memory stores */\n");
    GEN ("always @(");
    GEN ("always @(");
    for (i = 0; i < f->nmsched; i++)
    for (i = 0; i < f->nmsched; i++)
      if (f->mtype[i] & MT_STORE) {
      if (f->mtype[i] & MT_STORE) {
        char t[30];
        char t[30];
        GEN ("%s%s", cur_store++ ? ", " : "", print_op_v (f, t, f->msched[i], 0));
        GEN ("%s%s", cur_store++ ? " or " : "", print_op_v (f, t, f->msched[i], 0));
      }
      }
 
 
    cur_store = 0;
    cur_store = 0;
    GEN (")\nbegin\n");
    GEN (")\nbegin\n");
    for (i = 0; i < f->nmsched; i++)
    for (i = 0; i < f->nmsched; i++) if (f->mtype[i] & MT_STORE) {
      if (f->mtype[i] & MT_STORE) {
 
        char t[30];
        char t[30];
        GEN ("  %sif (s_stb[%i]) swb_dat_o = %s;\n", i ? "else " : "", cur_store++,
      GEN ("  %sif (s_stb[%i]) swb_dat_o = %s;\n", cur_store == 0 ? "" : "else ", cur_store,
                        print_op_v (f, t, f->msched[i], 0));
                        print_op_v (f, t, f->msched[i], 0));
 
      cur_store++;
        //PRINTF ("msched[%i] = %x (mtype %x) %x\n", i, f->msched[i], f->mtype[i], f->INSN(f->msched[i]).op[0]);
        //PRINTF ("msched[%i] = %x (mtype %x) %x\n", i, f->msched[i], f->mtype[i], f->INSN(f->msched[i]).op[0]);
      }
      }
 
    GEN ("  else swb_dat_o = 32'hx;\n");
    GEN ("end\n");
    GEN ("end\n");
  }
  }
 
 
  /* Generate load and store state machine */
  /* Generate load and store state machine */
  for (j = 0; j < 2; j++) {
  for (j = 0; j < 2; j++) {
Line 562... Line 563...
     || j == 1 && nstores
     || j == 1 && nstores
     || j == 2 && ncalls) {
     || j == 2 && ncalls) {
      int cur = 0;
      int cur = 0;
      char t[30];
      char t[30];
      GEN ("\n/* %s state machine */\n", s);
      GEN ("\n/* %s state machine */\n", s);
 
      GEN ("always @(posedge clk or posedge rst)\n");
 
      GEN ("  if (rst) %c_stb <= #Tp %i'h0;\n", c, j == 0 ? nloads : j == 1 ? nstores : ncalls);
 
      GEN ("  else begin\n");
 
      for (i = 0; i < f->nmsched; i++)
 
        if (j == 0 && f->mtype[i] & MT_LOAD
 
         || j == 1 && f->mtype[i] & MT_STORE
 
         || j == 2 && f->mtype[i] & MT_CALL) {
 
        dep_list *dep = f->INSN(f->msched[i]).dep;
 
        assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
 
        GEN ("    if (");
 
        print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
 
        GEN (") begin\n");
 
        print_turn_off_dep (fo, f, dep);
 
        GEN ("      %c_stb[%i] <= #Tp 1'b1;\n", c, cur++);
 
        GEN ("    end\n");
 
      }
 
      GEN ("    if (%c_end[%i]) %c_stb <= #Tp %i'h0;\n", c, cur - 1, c, cur);
 
      GEN ("  end\n");
 
 
 
      GEN ("\n/* %s state generator machine */\n", s);
      GEN ("always @(");
      GEN ("always @(");
      for (i = 0; i < f->nmsched; i++) {
      for (i = 0; i < f->nmsched; i++) {
         print_op_v (f, t, f->msched[i], 1); break;
        print_op_v (f, t, f->msched[i], 1);
         GEN (" or ");
        GEN ("%s or ", t);
         GEN ("t%x_%x", REF_BB(f->INSN(f->msched[i]).op[1]), REF_I(f->INSN(f->msched[i]).op[1]));
 
         GEN (" or ");
 
      }
      }
      print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
      GEN ("bb_start_r");
      GEN (" or %c_end)\n", c);
      if (nloads) GEN (" or l_end");
 
      if (nstores) GEN (" or s_end");
 
      GEN (")\n");
      GEN ("begin\n");
      GEN ("begin\n");
      cucdebug (1, "%s\n", s);
      cucdebug (1, "%s\n", s);
      for (i = 0; i < f->nmsched; i++)
      for (i = 0; i < f->nmsched; i++)
        if (j == 0 && f->mtype[i] & MT_LOAD
        if (j == 0 && f->mtype[i] & MT_LOAD
         || j == 1 && f->mtype[i] & MT_STORE
         || j == 1 && f->mtype[i] & MT_STORE
Line 583... Line 604...
        cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
        cucdebug (1, "msched[%i] = %x (mtype %x)\n", i, f->msched[i], f->mtype[i]);
        assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
        assert (f->INSN(f->msched[i]).opt[1] & (OPT_REF | OPT_REGISTER));
        GEN ("  if (");
        GEN ("  if (");
        print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
        print_deps (fo, f, REF_BB(f->msched[i]), f->INSN(f->msched[i]).dep, 1);
        GEN (") begin\n");
        GEN (") begin\n");
        print_turn_off_dep (fo, f, dep);
        GEN ("    %cwb_cycstb_o = 1'b1;\n", c);
        GEN ("    %c_stb[%i] <= #Tp 1'b1;\n", c, cur++);
        GEN ("    %cwb_sel_o[3:0] = 4'b", c);
        GEN ("    %cwb_cycstb_o <= #Tp 1'b1;\n", c);
 
        GEN ("    %cwb_sel_o[3:0] <= #Tp 4'b", c);
 
        switch (f->mtype[i] & MT_WIDTH) {
        switch (f->mtype[i] & MT_WIDTH) {
          case 1: GEN ("0001 << (%s & 32'h3);\n",
          case 1: GEN ("0001 << (%s & 32'h3);\n",
                                  print_op_v (f, t, f->msched[i], 1)); break;
                                  print_op_v (f, t, f->msched[i], 1)); break;
          case 2: GEN ("0011 << ((%s & 32'h1) << 1);\n",
          case 2: GEN ("0011 << ((%s & 32'h1) << 1);\n",
                                  print_op_v (f, t, f->msched[i], 1)); break;
                                  print_op_v (f, t, f->msched[i], 1)); break;
          case 4: GEN ("1111;\n"); break;
          case 4: GEN ("1111;\n"); break;
          default: assert (0);
          default: assert (0);
        }
        }
        GEN ("    %cwb_linbrst_o <= #Tp 1'b%i;\n", c,
        GEN ("    %cwb_linbrst_o = 1'b%i;\n", c,
                      (f->mtype[i] & MT_BURST) && !(f->mtype[i] & MT_BURSTE) ? 1 : 0);
                      (f->mtype[i] & MT_BURST) && !(f->mtype[i] & MT_BURSTE) ? 1 : 0);
        GEN ("    %cwb_adr_o <= #Tp t%x_%x & ~32'h3;\n", c,
        GEN ("    %cwb_adr_o = t%x_%x & ~32'h3;\n", c,
                      REF_BB(f->INSN(f->msched[i]).op[1]), REF_I(f->INSN(f->msched[i]).op[1]));
                      REF_BB(f->INSN(f->msched[i]).op[1]), REF_I(f->INSN(f->msched[i]).op[1]));
        GEN ("  end\n");
        GEN ("  end else ");
      }
      }
      GEN ("  if (%c_end[%i]) begin\n", c, cur - 1);
      GEN ("  if (%c_end[%i]) begin\n", c, cur - 1);
      GEN ("    %c_stb <= #Tp %i'h0;\n", c, cur);
      GEN ("    %cwb_cycstb_o = 1'b0;\n", c);
      GEN ("    %cwb_cycstb_o <= #Tp 1'b0;\n", c);
      GEN ("    %cwb_sel_o[3:0] = 4'bx;\n", c);
      GEN ("    %cwb_sel_o[3:0] <= #Tp 4'b0000;\n", c);
      GEN ("    %cwb_linbrst_o = 1'b0;\n", c);
      GEN ("    %cwb_linbrst_o <= #Tp 1'b0;\n", c);
      GEN ("    %cwb_adr_o = 32'hx;\n", c);
      GEN ("    %cwb_adr_o <= #Tp 32'h0;\n", c);
      GEN ("  end else begin\n");
 
      GEN ("    %cwb_cycstb_o = 1'b0;\n", c);
 
      GEN ("    %cwb_sel_o[3:0] = 4'bx;\n", c);
 
      GEN ("    %cwb_linbrst_o = 1'b0;\n", c);
 
      GEN ("    %cwb_adr_o = 32'hx;\n", c);
      GEN ("  end\n");
      GEN ("  end\n");
      GEN ("end\n");
      GEN ("end\n");
    }
    }
  }
  }
 
 
Line 852... Line 875...
 
 
    GEN ("\n/* read register access - acknowledge */\n");
    GEN ("\n/* read register access - acknowledge */\n");
    GEN ("assign cuc_ack_o = cuc_stb_i && cuc_we_i && |(i_selected & main_end);\n");
    GEN ("assign cuc_ack_o = cuc_stb_i && cuc_we_i && |(i_selected & main_end);\n");
  }
  }
 
 
 
  /* Store/load Wishbone bridge */
  for (j = 0; j < 2; j++) {
  for (j = 0; j < 2; j++) {
    char t = j ? 's' : 'l';
    char t = j ? 's' : 'l';
    GEN ("\n/* %s Wishbone bridge */\n", j ? "store" : "load");
    GEN ("\n/* %s Wishbone bridge */\n", j ? "store" : "load");
    GEN ("reg [%i:0] %cm_sel;\n", log2 (nrf), t);
    GEN ("reg [%i:0] %cm_sel;\n", log2 (nrf), t);
    GEN ("reg [%i:0] %cm_bid;\n", log2 (nrf), t);
    GEN ("reg [%i:0] %cm_bid;\n", log2 (nrf), t);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.