OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [mor1kx-5.0/] [rtl/] [verilog/] [mor1kx_store_buffer.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
/******************************************************************************
2
 This Source Code Form is subject to the terms of the
3
 Open Hardware Description License, v. 1.0. If a copy
4
 of the OHDL was not distributed with this file, You
5
 can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt
6
 
7
 Description: Store buffer
8
 Currently a simple single clock FIFO, but with the ambition to
9
 have combining and reordering capabilities in the future.
10
 
11
 Copyright (C) 2013 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
12
 
13
 ******************************************************************************/
14
`include "mor1kx-defines.v"
15
 
16
module mor1kx_store_buffer
17
  #(
18
    parameter DEPTH_WIDTH = 4,
19
    parameter OPTION_OPERAND_WIDTH = 32
20
    )
21
   (
22
    input                               clk,
23
    input                               rst,
24
 
25
    input [OPTION_OPERAND_WIDTH-1:0]     pc_i,
26
    input [OPTION_OPERAND_WIDTH-1:0]     adr_i,
27
    input [OPTION_OPERAND_WIDTH-1:0]     dat_i,
28
    input [OPTION_OPERAND_WIDTH/8-1:0]   bsel_i,
29
    input                               atomic_i,
30
    input                               write_i,
31
 
32
    output [OPTION_OPERAND_WIDTH-1:0]    pc_o,
33
    output [OPTION_OPERAND_WIDTH-1:0]    adr_o,
34
    output [OPTION_OPERAND_WIDTH-1:0]    dat_o,
35
    output [OPTION_OPERAND_WIDTH/8-1:0] bsel_o,
36
    output                              atomic_o,
37
    input                               read_i,
38
 
39
    output                              full_o,
40
    output                              empty_o
41
    );
42
 
43
   // The fifo stores address + data + byte sel + pc + atomic
44
   localparam FIFO_DATA_WIDTH = OPTION_OPERAND_WIDTH*3 +
45
                                OPTION_OPERAND_WIDTH/8 + 1;
46
 
47
   wire [FIFO_DATA_WIDTH-1:0]            fifo_dout;
48
   wire [FIFO_DATA_WIDTH-1:0]            fifo_din;
49
 
50
   reg [DEPTH_WIDTH:0]                  write_pointer;
51
   reg [DEPTH_WIDTH:0]                  read_pointer;
52
 
53
   assign fifo_din = {adr_i, dat_i, bsel_i, pc_i, atomic_i};
54
   assign {adr_o, dat_o, bsel_o, pc_o, atomic_o} = fifo_dout;
55
 
56
   assign full_o = (write_pointer[DEPTH_WIDTH] != read_pointer[DEPTH_WIDTH]) &&
57
                   (write_pointer[DEPTH_WIDTH-1:0] == read_pointer[DEPTH_WIDTH-1:0]);
58
   assign empty_o = write_pointer == read_pointer;
59
 
60
   always @(posedge clk `OR_ASYNC_RST)
61
     if (rst)
62
       write_pointer <= 0;
63
     else if (write_i)
64
       write_pointer <= write_pointer + 1'd1;
65
 
66
   always @(posedge clk `OR_ASYNC_RST)
67
     if (rst)
68
       read_pointer <= 0;
69
     else if (read_i)
70
       read_pointer <= read_pointer + 1'd1;
71
 
72
   mor1kx_simple_dpram_sclk
73
     #(
74
       .ADDR_WIDTH(DEPTH_WIDTH),
75
       .DATA_WIDTH(FIFO_DATA_WIDTH),
76
       .ENABLE_BYPASS(1)
77
       )
78
   fifo_ram
79
     (
80
      .clk                      (clk),
81
      .dout                     (fifo_dout),
82
      .raddr                    (read_pointer[DEPTH_WIDTH-1:0]),
83
      .re                       (read_i),
84
      .waddr                    (write_pointer[DEPTH_WIDTH-1:0]),
85
      .we                       (write_i),
86
      .din                      (fifo_din)
87
      );
88
 
89
endmodule

powered by: WebSVN 2.1.0

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