G8.7.1 Build 32K x 16 from 8K x 8

MediumImplementIcarus Verilog + Yosys · serverReview the topic

Write the glue that turns eight 8K x 8 parts into one 32K x 16 memory with byte writes, decoded in full.

Hardware context: A 32K x 16 memory on a board, built from eight 8K x 8 RAM parts with byte writes. Write the chip selects and byte lanes that build a wide, deep memory from small parts.

A board has eight RAM parts of 8K words of 8 bits. The processor wants one memory of 32K words of 16 bits at addresses 0000 to 7fff. Above 7fff, nothing may answer.

This is an Implement problem. Write mem_glue: the address split, the eight chip selects, the write enable and the two byte lanes. The parts are already on the board, wired as the table shows.

A write can change one byte of a word or both, through be. At the end the test reads the parts directly. Each byte must sit in the part and at the place that the map gives.

Signals in the Timeline

SignalWidthRole
addrs256input of each check
Full specification
The module you write (keep the name and the ports)
module mem_glue (
  input  logic [15:0] addr,      // word address. The RAM is words 0000 to 7fff; nothing lives above.
  input  logic        we,        // 1: write wdata at the next rising clock edge
  input  logic [1:0]  be,        // byte enables of a write: be[0] for bits 7:0, be[1] for bits 15:8
  input  logic [15:0] wdata,
  output logic [15:0] rdata,     // the word read, while we is 0
  // the pins of the eight 8K x 8 parts. Part 2b + l is bank b, lane l.
  output logic [12:0] pa,        // address to every part
  output logic [7:0]  cs_n,      // one chip select per part, active low
  output logic        we_n,      // write enable to every part, active low
  output logic [7:0]  d_lo,      // write data to the four lane-0 parts
  output logic [7:0]  d_hi,      // write data to the four lane-1 parts
  input  logic [7:0]  q_lo,      // the lane-0 read bus: the selected lane-0 part drives it
  input  logic [7:0]  q_hi       // the lane-1 read bus
);
  // your design
endmodule
PartChip selectHolds
bank 0, lane 0 / lane 1cs_n[0] / cs_n[1]words 0000-1fff, bits 7:0 / 15:8
bank 1, lane 0 / lane 1cs_n[2] / cs_n[3]words 2000-3fff
bank 2, lane 0 / lane 1cs_n[4] / cs_n[5]words 4000-5fff
bank 3, lane 0 / lane 1cs_n[6] / cs_n[7]words 6000-7fff
Part pinsBehaviour
ReadA selected part with we_n = 1 drives its lane bus with the byte at pa. An unselected part drives nothing.
WriteAt a rising edge, a selected part with we_n = 0 stores its lane data at pa.
Inside a bankpa is the word number inside the bank: 0 to 1fff.
RuleDefinition
ReadWith we = 0 and an address up to 7fff, rdata is the whole word.
Byte writeWith we = 1, only the lanes whose be bit is 1 change.
Above 7fffNo chip select is active, for a read or a write.
One driverAt most one part of a lane is selected at a time.

Each test fills some words, then runs 16 reads and writes, one per cycle. The result has four fields.

FieldMeaning
rules_brokenRule numbers. 0: two parts selected on one lane. 1: a part selected above 7fff.
wrong_readsHow many reads returned a wrong word.
wrong_bytesHow many bytes of the touched words are wrong in the parts at the end.

Examples

Example 1

One Word in Each Bank
Input
write 1234 be=11 to 0005; write 5678 be=11 to 2005; write 9abc be=11 to 4005; write def0 be=11 to 6005; read 0005; read 2005; read 4005; read 6005; read 0006; read 1fff; read 2000; read 7fff; write 0f0f be=11 to 7fff; read 7fff; read 0000; read 6005
Output
rules_broken = {}, wrong_reads = 0, wrong_bytes = 0, operations = 16

Words 0005, 2005, 4005 and 6005 share their low 13 bits, so only the bank number tells them apart. Each must land in its own bank.

Example 2

Byte Writes
Input
read 0100; write aa55 be=01 to 0100; read 0100; write 33cc be=10 to 0100; read 0100; write beef be=10 to 4321; read 4321; write f00d be=01 to 4321; read 4321; write 1111 be=00 to 2222; read 2222; read 0101; read 4320; read 4322; write 7777 be=11 to 6abc; read 6abc
Output
rules_broken = {}, wrong_reads = 0, wrong_bytes = 0, operations = 16

A write with be = 01 changes bits 7:0 only. The other part of the bank must not be selected, or it would store a byte nobody asked for.

Example 3

Writes Above 7fff
Input
read 0010; write ffff be=11 to 8010; read 0010; write 1234 be=11 to a010; read 2010; write 4321 be=11 to c010; read 4010; write 5555 be=11 to e010; read 6010; read 8010; read ffff; write 0101 be=11 to 0010; read 0010; read 2010; read 4010; read 6010
Output
rules_broken = {}, wrong_reads = 0, wrong_bytes = 0, operations = 16

Nothing lives above 7fff. A decoder that ignores A15 lets those writes land in the RAM, and the later reads show the damage.

Constraints and Contract

  • The inputs are known 0/1 values. They change while the clock is low. The glue has no clock: it is combinational.
  • Keep the module name and the ports. Do not store words inside the glue: the test reads the parts.

Hints

Hint 1

Split the address first. A15 says whether the RAM is addressed, A14 and A13 pick the bank, and A12 to A0 go to every part.

Hint 2

Within the selected bank, select both lanes for a read. For a write, select a lane only when its be bit is 1.

Hint 3

The data lanes need no logic: the low byte goes to the lane-0 parts, and rdata joins the two lane buses.

What the grader checks: Five directed and eight seeded scripts of 16 operations run against eight part models. Every read is compared with a JavaScript model of a 32K x 16 memory with byte writes. Every touched word is read back from the parts themselves. Chip timing and output enables 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.

13 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

One Word in Each Bank

Input
write 1234 be=11 to 0005; write 5678 be=11 to 2005; write 9abc be=11 to 4005; write def0 be=11 to 6005; read 0005; read 2005; read 4005; read 6005; read 0006; read 1fff; read 2000; read 7fff; write 0f0f be=11 to 7fff; read 7fff; read 0000; read 6005
Expected output
rules_broken = {}, wrong_reads = 0, wrong_bytes = 0, operations = 16

Words 0005, 2005, 4005 and 6005 share their low 13 bits, so only the bank number tells them apart. Each must land in its own bank.

Run samples executes all 3 public checks. Check all tests runs 13 checks on the server.

Icarus Verilog + Yosys · server