diff options
Diffstat (limited to '')
| -rw-r--r-- | hdl/mem.sv | 26 |
1 files changed, 9 insertions, 17 deletions
| @@ -18,32 +18,24 @@ parameter ADDR_BITS; | |||
| 18 | parameter DATA_BITS; | 18 | parameter DATA_BITS; |
| 19 | parameter INIT_FILE; | 19 | parameter INIT_FILE; |
| 20 | 20 | ||
| 21 | `output(ready) | ||
| 22 | `input(valid) | ||
| 23 | `input(write) | ||
| 24 | `input(address) | ||
| 25 | `input(write_data) | ||
| 26 | `output(read_valid) | ||
| 27 | `output(read_data) | ||
| 28 | |||
| 29 | bit [DATA_BITS-1:0] storage [0:(1<<ADDR_BITS)-1]; | 21 | bit [DATA_BITS-1:0] storage [0:(1<<ADDR_BITS)-1]; |
| 30 | initial $readmemh(INIT_FILE, storage); | 22 | initial $readmemh(INIT_FILE, storage); |
| 31 | 23 | ||
| 32 | always_ff @(posedge clk) begin | 24 | always_ff @(posedge clk) begin |
| 33 | if (reset) begin | 25 | if (reset) begin |
| 34 | ready_ = 0; | 26 | ready = 0; |
| 35 | read_valid_ = 0; | 27 | read_valid = 0; |
| 36 | end else begin | 28 | end else begin |
| 37 | read_valid_ = 0; | 29 | read_valid = 0; |
| 38 | if (ready_ && valid_) begin | 30 | if (ready && `lag(valid)) begin |
| 39 | if (write_) begin | 31 | if (`lag(write)) begin |
| 40 | storage[address_] = write_data_; | 32 | storage[`lag(address)] = `lag(write_data); |
| 41 | end else begin | 33 | end else begin |
| 42 | read_valid_ = 1; | 34 | read_valid = 1; |
| 43 | read_data_ = storage[address_]; | 35 | read_data = storage[`lag(address)]; |
| 44 | end | 36 | end |
| 45 | end | 37 | end |
| 46 | ready_ = 1; | 38 | ready = 1; |
| 47 | end | 39 | end |
| 48 | end | 40 | end |
| 49 | 41 | ||
