11package wildcat .pipeline
22
33import chisel3 ._
4- import chisel .lib .uart ._
54import chisel3 .util .RegEnable
65
76import wildcat .Util
@@ -12,7 +11,7 @@ import memory.{InstructionROM, OpenRAMMem, ScratchPadMem}
1211/*
1312 * This file is part of the RISC-V processor Wildcat.
1413 *
15- * This is the top-level for a three stage pipeline.
14+ * This is one top-level for the Wildcat pipeline.
1615 *
1716 * Author: Martin Schoeberl (martin@jopdesign.com)
1817 *
@@ -27,14 +26,15 @@ class WildcatTop(file: String, dmemNrByte: Int = 4096, testFPGA: Boolean = true)
2726
2827 val (memory, start) = Util .getCode(file)
2928
30- // Here switch between different designs
29+ // Switch between different pipes
3130 val cpu = Module (new ThreeCats ())
3231 // val cpu = Module(new WildFour())
3332 // val cpu = Module(new StandardFive())
3433
3534 val imem = if (testFPGA) Module (new InstructionROM (memory)) else Module (new OpenRAMMem ())
3635 cpu.io.imem <> imem.cpuPort
37- // for read multiplexing
36+
37+ // Address register for read multiplexing
3838 val memAddressReg = RegEnable (cpu.io.dmem.address, 0 .U , cpu.io.dmem.rd)
3939
4040 val csMem = cpu.io.dmem.address(31 , 28 ) === 0 .U
@@ -50,13 +50,7 @@ class WildcatTop(file: String, dmemNrByte: Int = 4096, testFPGA: Boolean = true)
5050 val ioDecodeAddress = cpu.io.dmem.address(19 ,16 )
5151 val ioDecodeAddressReg = memAddressReg(19 , 16 )
5252
53- val ledDevice = Module (new LedDevice (16 ))
54- val csLed = csIO && ioDecodeAddress === 1 .U
55- val muxLed = csIOReg && ioDecodeAddressReg === 1 .U
56- ledDevice.cpuPort <> cpu.io.dmem
57- ledDevice.cpuPort.rd := csLed && cpu.io.dmem.rd
58- ledDevice.cpuPort.wr := csLed && cpu.io.dmem.wr
59-
53+ // Everyone needs a UART
6054 val uartDevice = Module (new UartDevice (100000000 , 115200 ))
6155 io.tx := uartDevice.io.txd
6256 uartDevice.io.rxd := io.rx
@@ -67,17 +61,25 @@ class WildcatTop(file: String, dmemNrByte: Int = 4096, testFPGA: Boolean = true)
6761 uartDevice.cpuPort.rd := csUart && cpu.io.dmem.rd
6862 uartDevice.cpuPort.wr := csUart && cpu.io.dmem.wr
6963
70- // read mux
64+ // We also love to have an LED to blink
65+ val ledDevice = Module (new LedDevice (16 ))
66+ io.led := 1 .U ## 0 .U (7 .W ) ## RegNext (ledDevice.io.leds)
67+
68+ val csLed = csIO && ioDecodeAddress === 1 .U
69+ val muxLed = csIOReg && ioDecodeAddressReg === 1 .U
70+ ledDevice.cpuPort <> cpu.io.dmem
71+ ledDevice.cpuPort.rd := csLed && cpu.io.dmem.rd
72+ ledDevice.cpuPort.wr := csLed && cpu.io.dmem.wr
73+
74+ // read mux for memory and IO devices
7175 cpu.io.dmem.rdData := dmem.cpuPort.rdData
7276 when (muxUart) {
7377 cpu.io.dmem.rdData := uartDevice.cpuPort.rdData
7478 } .elsewhen(muxLed) {
7579 cpu.io.dmem.rdData := RegNext (ledDevice.io.leds)
7680 }
77- // or all ack signals together
81+ // or reduce all ack signals
7882 cpu.io.dmem.ack := dmem.cpuPort.ack || uartDevice.cpuPort.ack || ledDevice.cpuPort.ack
79-
80- io.led := 1 .U ## 0 .U (7 .W ) ## RegNext (ledDevice.io.leds)
8183}
8284
8385object WildcatTop extends App {
0 commit comments