Synchronous Static RAM

  1. Introduction

    Memory is a basic element in any system whether the memory is volatile or non-volatile. In this example, a volatile memory unit is designed in the form of a Synchronous Static RAM. Static Random-Access Memory (SRAM) is a type of semiconductor memory that uses bi-stable latching circuitry to store each bit. The term Static differentiates it from Dynamic RAM (DRAM) which must be periodically refreshed. SRAM retains data, but it is still volatile as data is lost when the power to the memory unit is cut off.

  2. Verilog Module

    Figure 1 presents the Verilog module of the Synchronous SRAM. This Synchronous SRAM can store eight 8-bit values. The Synchronous SRAM module consists of a 8-bit data input line, dataIn and a 8-bit data output line, dataOut. The module uses an 8-bit address line, Addr to locate the position of data-byte within the memory array. With an 8-bit address line a 256-unit deep SRAM can be addressed, but in this example, an 8-unit deep SRAM is designed for simplicity. The module is clocked using the 1-bit input clock line Clk. The module also has a 1-bit chip select line, CS.

    The 1-bit RD line is used to signal a data read operation on the Synchronous SRAM and the 1-bit WE line is used to signal a data write operation on the Synchronous SRAM. Both the RD and WE lines are active high.

    Figure 1. Verilog module of Synchronous SRAM

  3. Verilog Code for Synchronous SRAM (syncRAM.v)



    1. module syncRAM( dataIn,
    2. dataOut,
    3. Addr,
    4. CS,
    5. WE,
    6. RD,
    7. Clk
    8. );
    9. // parameters for the width
    10. parameter ADR = 8;
    11. parameter DAT = 8;
    12. parameter DPTH = 8;
    13. //ports
    14. input [DAT-1:0] dataIn;
    15. output reg [DAT-1:0] dataOut;
    16. input [ADR-1:0] Addr;
    17. input CS,
    18. WE,
    19. RD,
    20. Clk;
    21. //internal variables
    22. reg [DAT-1:0] SRAM [DPTH-1:0];
    23. always @ (posedge Clk)
    24. begin
    25. if (CS == 1'b1) begin
    26. if (WE == 1'b1 && RD == 1'b0) begin
    27. SRAM [Addr] = dataIn;
    28. end
    29. else if (RD == 1'b1 && WE == 1'b0) begin
    30. dataOut = SRAM [Addr];
    31. end
    32. else;
    33. end
    34. else;
    35. end
    36. endmodule
    Figure 2. Verilog Code for Synchronous SRAM

  4. Verilog Test Bench for Synchronous SRAM (syncRAM_tb.v)


    1. `timescale 1ns / 1ps
    2. module syncRAM_tb;
    3. // Inputs
    4. reg [7:0] dataIn;
    5. reg [7:0] Addr;
    6. reg CS;
    7. reg WE;
    8. reg RD;
    9. reg Clk;
    10. // Outputs
    11. wire [7:0] dataOut;
    12. // Instantiate the Unit Under Test (UUT)
    13. syncRAM uut (
    14. .dataIn(dataIn),
    15. .dataOut(dataOut),
    16. .Addr(Addr),
    17. .CS(CS),
    18. .WE(WE),
    19. .RD(RD),
    20. .Clk(Clk)
    21. );
    22. initial begin
    23. // Initialize Inputs
    24. dataIn = 8'h0;
    25. Addr = 8'h0;
    26. CS = 1'b0;
    27. WE = 1'b0;
    28. RD = 1'b0;
    29. Clk = 1'b0;
    30. // Wait 100 ns for global reset to finish
    31. #100;
    32. // Add stimulus here
    33. dataIn = 8'h0;
    34. Addr = 8'h0;
    35. CS = 1'b1;
    36. WE = 1'b1;
    37. RD = 1'b0;
    38. #20;
    39. dataIn = 8'h0;
    40. Addr = 8'h0;
    41. #20;
    42. dataIn = 8'h1;
    43. Addr = 8'h1;
    44. #20;
    45. dataIn = 8'h10;
    46. Addr = 8'h2;
    47. #20;
    48. dataIn = 8'h6;
    49. Addr = 8'h3;
    50. #20;
    51. dataIn = 8'h12;
    52. Addr = 8'h4;
    53. #40;
    54. Addr = 8'h0;
    55. WE = 1'b0;
    56. RD = 1'b1;
    57. #20;
    58. Addr = 8'h1;
    59. #20;
    60. Addr = 8'h2;
    61. #20;
    62. Addr = 8'h3;
    63. #20;
    64. Addr = 8'h4;
    65. end
    66. always #10 Clk = ~Clk;
    67. endmodule
    Figure 3. Verilog Test-bench for Synchronous SRAM

  5. Timing Diagram

    Figure 4. Timing diagram of Synchronous SRAM with four data