| /* | |
| Copyright 2024 Google LLC | |
| Copyright (C) 2019-2022 Antmicro | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| package DMAController | |
| import chisel3._ | |
| import chisel3.util._ | |
| import DMAController.Bus._ | |
| import DMAController.CSR.CSR | |
| import DMAController.Frontend._ | |
| import DMAController.Worker.{InterruptBundle, WorkerCSRWrapper, SyncBundle} | |
| import DMAController.DMAConfig._ | |
| import _root_.circt.stage.{ChiselStage,FirtoolOption} | |
| import chisel3.stage.ChiselGeneratorAnnotation | |
| import scala.annotation.nowarn | |
| class DMATop extends Module { | |
| val io = IO(new Bundle{ | |
| val control = new TLULDevice(DMAConfig.addrWidth, DMAConfig.readDataWidth) | |
| val read = new TLULHost(DMAConfig.addrWidth, DMAConfig.readDataWidth) | |
| val write = new TLULHost(DMAConfig.addrWidth, DMAConfig.readDataWidth) | |
| val irq = new InterruptBundle | |
| val sync = new SyncBundle | |
| }) | |
| val csrFrontend = Module(new TLULCSR(DMAConfig.addrWidth, DMAConfig.readDataWidth)) | |
| val readerFrontend = Module(new TLULReader(DMAConfig.addrWidth, DMAConfig.readDataWidth)) | |
| val writerFrontend = Module(new TLULWriter(DMAConfig.addrWidth, DMAConfig.readDataWidth)) | |
| val csr = Module(new CSR(DMAConfig.addrWidth)) | |
| val ctl = Module(new WorkerCSRWrapper(DMAConfig.addrWidth, DMAConfig.readDataWidth, DMAConfig.writeDataWidth, | |
| DMAConfig.readMaxBurst, DMAConfig.writeMaxBurst, DMAConfig.reader4KBarrier, DMAConfig.writer4KBarrier)) | |
| val queue = Queue(readerFrontend.io.dataIO, DMAConfig.fifoDepth) | |
| queue <> writerFrontend.io.dataIO | |
| csrFrontend.io.ctl <> io.control | |
| csr.io.bus <> csrFrontend.io.bus | |
| ctl.io.csr <> csr.io.csr | |
| readerFrontend.io.xfer <> ctl.io.xferRead | |
| writerFrontend.io.xfer <> ctl.io.xferWrite | |
| io.read <> readerFrontend.io.bus | |
| io.write <> writerFrontend.io.bus | |
| io.irq <> ctl.io.irq | |
| io.sync <> ctl.io.sync | |
| assert(DMAConfig.readDataWidth == DMAConfig.writeDataWidth) | |
| } | |
| @nowarn | |
| object EmitDMA extends App{ | |
| (new ChiselStage).execute( | |
| Array("--target", "systemverilog") ++ args, | |
| Seq(ChiselGeneratorAnnotation(() => new DMATop)) ++ Seq(FirtoolOption("-enable-layers=Verification")) | |
| ) | |
| } |