This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
memory-port-io.scala
63 lines (57 loc) · 2.17 KB
/
memory-port-io.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Contains the memory port IOs for use in port/cache implementations
package dinocpu.memory
import chisel3._
/**
* A generic ready/valid interface for MemPort modules, whose IOs extend this.
*
* This interface corresponds with the pipeline <=> port interface between the
* pipelined CPU and the memory port.
*
* Input: address, the address of a piece of data in memory.
* Input: valid, true when the address specified is valid
* Output: good, true when memory is responding with a piece of data (used to un-stall the pipeline)
*
*/
class MemPortIO extends Bundle {
// Pipeline <=> Port
val address = Input(UInt(32.W))
val valid = Input(Bool())
val good = Output(Bool())
}
/**
* The *interface* of the IMemPort module.
*
* Pipeline <=> Port:
* Input: address, the address of an instruction in memory
* Input: valid, true when the address specified is valid
* Output: instruction, the requested instruction
* Output: good, true when memory is responding with a piece of data
* Output: ready, true when the memory is ready to accept another request (used to un-stall the pipeline)
*/
class IMemPortIO extends MemPortIO {
val instruction = Output(UInt(32.W))
val ready = Output(Bool())
}
/**
* The *interface* of the DMemPort module.
*
* Pipeline <=> Port:
* Input: address, the address of a piece of data in memory.
* Input: writedata, valid interface for the data to write to the address
* Input: valid, true when the address (and writedata during a write) specified is valid
* Input: memread, true if we are reading from memory
* Input: memwrite, true if we are writing to memory
* Input: maskmode, mode to mask the result. 0 means byte, 1 means halfword, 2 means word
* Input: sext, true if we should sign extend the result
* Output: readdata, the data read and sign extended
* Output: good, true when memory is responding with a piece of data
*/
class DMemPortIO extends MemPortIO {
// Pipeline <=> Port
val writedata = Input(UInt(32.W))
val memread = Input(Bool())
val memwrite = Input(Bool())
val maskmode = Input(UInt(2.W))
val sext = Input(Bool())
val readdata = Output(UInt(32.W))
}