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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ram_wb/] [ram_wb_b3.v] - Diff between revs 439 and 462

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

Rev 439 Rev 462
Line 33... Line 33...
   parameter bytes_per_dw = (dw/8);
   parameter bytes_per_dw = (dw/8);
   parameter adr_width_for_num_word_bytes = 2; //(log2(bytes_per_dw))
   parameter adr_width_for_num_word_bytes = 2; //(log2(bytes_per_dw))
   parameter mem_words = (mem_size_bytes/bytes_per_dw);
   parameter mem_words = (mem_size_bytes/bytes_per_dw);
 
 
   // synthesis attribute ram_style of mem is block
   // synthesis attribute ram_style of mem is block
   reg [dw-1:0]  mem [ 0 : mem_words-1 ] /* synthesis ram_style = no_rw_check */;
   reg [dw-1:0]  mem [ 0 : mem_words-1 ]   /* verilator public */ /* synthesis ram_style = no_rw_check */;
 
 
   // Register to address internal memory array
   // Register to address internal memory array
   reg [(mem_adr_width-adr_width_for_num_word_bytes)-1:0] adr;
   reg [(mem_adr_width-adr_width_for_num_word_bytes)-1:0] adr;
 
 
   wire [31:0]                      wr_data;
   wire [31:0]                      wr_data;
Line 113... Line 113...
     else if (using_burst_adr)
     else if (using_burst_adr)
       adr <= burst_adr_counter;
       adr <= burst_adr_counter;
     else if (wb_cyc_i & wb_stb_i)
     else if (wb_cyc_i & wb_stb_i)
       adr <= wb_adr_i[mem_adr_width-1:2];
       adr <= wb_adr_i[mem_adr_width-1:2];
 
 
 
   /* Memory initialisation.
 
    If not Verilator model, always do load, otherwise only load when called
 
    from SystemC testbench.
 
    */
 
 
   parameter memory_file = "sram.vmem";
   parameter memory_file = "sram.vmem";
 
 
 
`ifdef verilator
 
 
 
   task do_readmemh;
 
      // verilator public
 
      $readmemh(memory_file, mem);
 
   endtask // do_readmemh
 
 
 
`else
 
 
   initial
   initial
     begin
     begin
        $readmemh(memory_file, mem);
        $readmemh(memory_file, mem);
     end
     end
 
 
 
`endif // !`ifdef verilator
 
 
   assign wb_rty_o = 0;
   assign wb_rty_o = 0;
 
 
   // mux for data to ram, RMW on part sel != 4'hf
   // mux for data to ram, RMW on part sel != 4'hf
   assign wr_data[31:24] = wb_sel_i[3] ? wb_dat_i[31:24] : wb_dat_o[31:24];
   assign wr_data[31:24] = wb_sel_i[3] ? wb_dat_i[31:24] : wb_dat_o[31:24];
   assign wr_data[23:16] = wb_sel_i[2] ? wb_dat_i[23:16] : wb_dat_o[23:16];
   assign wr_data[23:16] = wb_sel_i[2] ? wb_dat_i[23:16] : wb_dat_o[23:16];
Line 197... Line 213...
   assign addr_err  = wb_cyc_i & wb_stb_i & (|wb_adr_i[aw-1-8:mem_adr_width]);
   assign addr_err  = wb_cyc_i & wb_stb_i & (|wb_adr_i[aw-1-8:mem_adr_width]);
 
 
   // OR in other errors here...
   // OR in other errors here...
   assign wb_err_o = wb_ack_o & (burst_access_wrong_wb_adr | addr_err);
   assign wb_err_o = wb_ack_o & (burst_access_wrong_wb_adr | addr_err);
 
 
`ifdef verilator
 
 
 
   task do_readmemh;
 
      // verilator public
 
      $readmemh(memory_file, mem);
 
   endtask // do_readmemh
 
 
 
`else
 
 
 
   initial
 
     begin
 
        $readmemh(memory_file, mem);
 
     end
 
 
 
`endif // !`ifdef verilator
 
 
 
 
 
 
 
   //
   //
   // Access functions
   // Access functions
   //
   //
 
 
   // Function to access RAM (for use by Verilator).
   // Function to access RAM (for use by Verilator).
   function [31:0] get_mem;
   function [31:0] get_mem32;
      // verilator public
      // verilator public
      input [aw-1:0]             addr;
      input [aw-1:0]             addr;
      get_mem = mem[addr[mem_adr_width-1:adr_width_for_num_word_bytes]];
      get_mem32 = mem[addr];
   endfunction // get_mem
   endfunction // get_mem32   
 
 
   // Function to access RAM (for use by Verilator).
   // Function to access RAM (for use by Verilator).
   function [7:0] get_byte;
   function [7:0] get_mem8;
      // verilator public
      // verilator public
      input [aw-1:0]             addr;
      input [aw-1:0]             addr;
      reg [31:0]                 temp_word;
      reg [31:0]                 temp_word;
      begin
      begin
         temp_word = mem[addr[mem_adr_width-1:adr_width_for_num_word_bytes]];
         temp_word = mem[{addr[aw-1:2],2'd0}];
         // Big endian mapping.
         // Big endian mapping.
         get_byte = (addr[1:0]==2'b00) ? temp_word[31:24] :
         get_mem8 = (addr[1:0]==2'b00) ? temp_word[31:24] :
                    (addr[1:0]==2'b01) ? temp_word[23:16] :
                    (addr[1:0]==2'b01) ? temp_word[23:16] :
                    (addr[1:0]==2'b10) ? temp_word[15:8] : temp_word[7:0];
                    (addr[1:0]==2'b10) ? temp_word[15:8] : temp_word[7:0];
         end
         end
   endfunction // get_mem
   endfunction // get_mem8   
 
 
   // Function to write RAM (for use by Verilator).
   // Function to write RAM (for use by Verilator).
   function set_mem;
   function set_mem32;
      // verilator public
      // verilator public
      input [aw-1:0]             addr;
      input [aw-1:0]             addr;
      input [dw-1:0]             data;
      input [dw-1:0]             data;
      mem[addr[mem_adr_width-1:adr_width_for_num_word_bytes]] = data;
      mem[addr] = data;
   endfunction // set_mem
   endfunction // set_mem32   
 
 
endmodule // ram_wb_b3
endmodule // ram_wb_b3
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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