Build the controller that reads and writes an asynchronous SRAM, with every pin change in the legal order.
Hardware context: A controller between a clocked data logger and an asynchronous SRAM chip with shared data pins. Build the state machine that walks an asynchronous SRAM through legal read and write cycles.
A data logger keeps its samples in an asynchronous SRAM chip. The chip has no clock. It only has address pins, shared data pins, a write enable and an output enable. The logger has a clock and a simple request port.
This is an Implement problem. Write sram_ctl, the state machine between the two. It takes one read or write request at a time and walks the pins through the cycle that the chip needs.
A write must keep the address and the data still around the write pulse. A read must wait for the access time before it stores the data pins. The chip and your controller must never drive the data pins together.
The test connects your module to a model of the chip. The model checks the time of every pin change. It also compares each word you read, and the content of the memory at the end.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
ops | 84 | input of each check |
Full specification
module sram_ctl (
input logic clk,
input logic rst, // synchronous, active high
input logic req, // 1 for one cycle while ready is 1: start one access
input logic rw, // with req: 1 = write wdata to word addr, 0 = read word addr
input logic [4:0] addr,
input logic [7:0] wdata,
output logic ready, // 1: idle, a request is taken at the next rising edge
output logic [7:0] rdata, // the word of the last read, kept until the next read ends
// the SRAM pins
output logic [4:0] a, // address
output logic [7:0] dq_out, // the value this controller puts on the data pins
output logic dq_drive, // 1: this controller drives the data pins
input logic [7:0] dq_in, // the value on the data pins
output logic we_n, // write enable, active low
output logic oe_n // output enable, active low: the SRAM drives the data pins
);
// your design
endmodule
| Rule of the chip | Limit |
|---|---|
| Address before the write pulse | The address is stable for 5 ns before we_n falls. |
| Write pulse | we_n stays low for 20 ns or more. |
| Data before the end of the pulse | The data pins are driven and stable for 15 ns before we_n rises. |
| Hold | The address and the data pins do not change in the moment we_n rises. |
| One driver | Never dq_drive = 1 with oe_n = 0, and never we_n = 0 with oe_n = 0. |
| Access time | With oe_n = 0, the word is on dq_in 15 ns after the address and oe_n are stable. Before that it is unknown. |
The clock period is 10 ns, and your outputs change at a rising edge. So each limit becomes a number of whole cycles. Work out that number for each row before you draw the states.
| Port rule | Definition |
|---|---|
| Request | req is 1 for one cycle while ready is 1. rw, addr and wdata are valid in that cycle only. |
| ready | 1 while the controller is idle. It must be 1 again within 7 cycles of the request. |
| rdata | After a read, the word that was read. It must be valid when ready returns and stay until the next read ends. |
| Idle | Whenever ready is 1: we_n = 1 and oe_n = 1, so the SRAM does not drive the shared pins. |
| Reset | At a rising edge with rst = 1 the controller goes idle: we_n = 1, oe_n = 1, dq_drive = 0. |
Each test fills the memory with known words, resets your controller and sends six requests, one every eight cycles. The result has four fields.
| Field | Meaning |
|---|---|
| rules_broken | Rule numbers. 0: address before the pulse. 1: pulse length. 2: data before the end. 3: hold. 4: two drivers. 5: oe_n low while idle. 6: rdata not held. |
| late | The requests after which ready was not 1 again in time. |
| wrong_reads | The read requests that returned a wrong word. |
| wrong_words | How many memory words differ from the expected content at the end. |
Examples
Example 1
Three Writes, Then Read Them Back- Input
write a5 to word 3, write 3c to word 9, write 7e to word 20, read word 3, read word 9, read word 20
- Output
rules_broken = {}, late = {}, wrong_reads = {}, wrong_words = 0, accesses = 6
Three write cycles store a5, 3c and 7e. Three read cycles must return the same words. No rule is broken, no request is late, and the 29 other words of the memory are untouched.
Example 2
Read Words That the Test Put in the Memory- Input
read word 0, read word 1, read word 31, read word 16, read word 7, read word 8
- Output
rules_broken = {}, late = {}, wrong_reads = {}, wrong_words = 0, accesses = 6
The test fills the memory before it starts. Word k holds the low byte of 37 times k plus 11. A controller that answers from its own storage cannot know these words.
Example 3
A Write Between Two Reads- Input
read word 12, write 44 to word 12, read word 12, write 45 to word 12, read word 12, read word 13
- Output
rules_broken = {}, late = {}, wrong_reads = {}, wrong_words = 0, accesses = 6
Word 12 is read, written and read again. The second read must show the new word. A read that is taken before the access time shows an unknown value.
Constraints and Contract
- Requests arrive only while ready is 1 and are known 0/1 values. Inputs change while the clock is low.
- Keep the module name and the ports. The controller holds no copy of the memory.
Hints
Hint 1
Start with the write. List what must be true before the pulse, during it and after it. Give each of the three parts its own state.
Hint 2
Change the address and the data only when you take the request. A state that only waits cannot break a setup or hold rule.
Hint 3
The pulse needs two clock cycles, so use two pulse states. A read needs two cycles with the output enable on. Store dq_in at the edge that ends the second one. Drive the data pins in every write state and in no read state.
What the grader checks: Eight directed and eight seeded scripts of six accesses run against a model of the chip. The model checks five timing rules on every pin change. Each read is compared with a memory model written in JavaScript, and so is the whole memory at the end. Back-to-back requests, chip select and real pin delays are outside this problem.
The submitted design must synthesize with 0 latches and no combinational loop. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.
16 checks on Icarus Verilog + Yosys · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 steps and the final capstone