This repository contains a cycle-accurate behavioral model of the Cypress CY62138EV30 (2-Mbit, 256K x 8, 45ns Static RAM) and a fully parameterized, dynamic SRAM controller designed to drive it.
- Accurate Architecture: 256K words × 8 bits (18-bit address bus).
- Timing Accuracy: Models all 45ns speed-grade delays (
tAA,tACE,tDOE,tPWE, etc.). - Write Termination Logic: Correctly implements Datasheet Note 17 (write terminates on the first rising edge of
WE_norCE_n). - Bus Contention Protection: Safely handles overlapping
OE_nandWE_nassertions. - Power States: Models Active, Standby, and Data Retention modes based on the
VCCenable signal.
- Parameterized Clock Frequency: Accepts
CLK_FREQ_MHZto adapt to any system clock. - Dynamic Wait-State Calculation: Automatically calculates the required FSM wait states at compile-time to guarantee the SRAM's 45ns
tWC/tRCtiming constraints are never violated, regardless of the clock speed. - Glitch-Free Outputs: All SRAM control signals (
ce_n,oe_n,we_n) are strictly registered. - Safe Tri-State Handling: Guarantees data hold time (
tHD) by keeping the data bus driven until the FSM safely returns to theIDLEstate.
.
├── rtl/
│ ├── CY62138EV30.v # Behavioral model of the SRAM
│ └── sram_controller.v # Dynamic SRAM controller RTL
└── targets/
└── sim/
├── filelist.f # Icarus Verilog filelist
├── Makefile # Simulation build script
├── tb_sram_model.v # Testbench for the SRAM model (Async)
└── tb_sram_controller.v # Testbench for the Controller + SRAM (Sync)
- Icarus Verilog (
iverilog,vvp) - GTKWave (for viewing waveforms)
make
The simulation environment uses a multi-level Makefile system. Navigate to the root directory and run:
# Clean previous simulation artifacts
make clean
# Run the desired simulation level
make sim LEVEL=<0, 1, or 2>LEVEL=0: Compiles theCY62138EV30model only (useful for syntax/lint checking).LEVEL=1: Runstb_sram_model.v. Tests the asynchronous SRAM behavioral model in isolation (power-up, read/write, standby, boundary addresses).LEVEL=2: Runstb_sram_controller.v. Instantiates both the controller and the SRAM model. Tests the synchronous controller's FSM, dynamic wait states, and registered outputs at 50 MHz.
The testbenches are configured to output FST (Fast Signal Trace) waveforms, which are significantly smaller and faster than VCD.
After running a simulation, view the waveforms with:
gtkwave targets/sim/sim.fstThis implementation is based on the Cypress CY62138EV30 MoBL® 2-Mbit Static RAM Datasheet.