Start implementing debugPlugin test infrastructures

This commit is contained in:
Charles Papon 2017-05-21 23:50:40 +02:00
parent 9995c5109d
commit 5cda2632df
4 changed files with 126 additions and 68 deletions

View File

@ -36,7 +36,7 @@ case class DebugExtensionIo() extends Bundle with IMasterSlave{
} }
} }
class DebugPlugin() extends Plugin[VexRiscv] { class DebugPlugin(debugClockDomain : ClockDomain) extends Plugin[VexRiscv] {
var io : DebugExtensionIo = null var io : DebugExtensionIo = null
@ -46,7 +46,7 @@ class DebugPlugin() extends Plugin[VexRiscv] {
import Riscv._ import Riscv._
import pipeline.config._ import pipeline.config._
io = slave(DebugExtensionIo()) io = slave(DebugExtensionIo()).setName("debug")
val decoderService = pipeline.service(classOf[DecoderService]) val decoderService = pipeline.service(classOf[DecoderService])
@ -64,6 +64,7 @@ class DebugPlugin() extends Plugin[VexRiscv] {
import pipeline._ import pipeline._
import pipeline.config._ import pipeline.config._
debugClockDomain {pipeline plug new Area{
val busReadDataReg = Reg(Bits(32 bit)) val busReadDataReg = Reg(Bits(32 bit))
when(writeBack.arbitration.isValid) { when(writeBack.arbitration.isValid) {
busReadDataReg := writeBack.output(REGFILE_WRITE_DATA) busReadDataReg := writeBack.output(REGFILE_WRITE_DATA)
@ -75,7 +76,6 @@ class DebugPlugin() extends Plugin[VexRiscv] {
val firstCycle = RegNext(False) setWhen (io.bus.cmd.ready) val firstCycle = RegNext(False) setWhen (io.bus.cmd.ready)
val resetIt = RegInit(False) val resetIt = RegInit(False)
val haltIt = RegInit(False) val haltIt = RegInit(False)
val flushIt = RegNext(False)
val stepIt = RegInit(False) val stepIt = RegInit(False)
val isPipActive = RegNext(List(fetch, decode, execute, memory, writeBack).map(_.arbitration.isValid).orR) val isPipActive = RegNext(List(fetch, decode, execute, memory, writeBack).map(_.arbitration.isValid).orR)
@ -86,7 +86,6 @@ class DebugPlugin() extends Plugin[VexRiscv] {
switch(io.bus.cmd.address(2 downto 2)) { switch(io.bus.cmd.address(2 downto 2)) {
is(0) { is(0) {
when(io.bus.cmd.wr) { when(io.bus.cmd.wr) {
flushIt := io.bus.cmd.data(2)
stepIt := io.bus.cmd.data(4) stepIt := io.bus.cmd.data(4)
resetIt setWhen (io.bus.cmd.data(16)) clearWhen (io.bus.cmd.data(24)) resetIt setWhen (io.bus.cmd.data(16)) clearWhen (io.bus.cmd.data(24))
haltIt setWhen (io.bus.cmd.data(17)) clearWhen (io.bus.cmd.data(25)) haltIt setWhen (io.bus.cmd.data(17)) clearWhen (io.bus.cmd.data(25))
@ -142,5 +141,6 @@ class DebugPlugin() extends Plugin[VexRiscv] {
when(haltIt || stepIt) { when(haltIt || stepIt) {
service(classOf[InterruptionInhibitor]).inhibateInterrupts() service(classOf[InterruptionInhibitor]).inhibateInterrupts()
} }
}}
} }
} }

View File

@ -183,7 +183,7 @@ object TopLevel {
new MulPlugin, new MulPlugin,
new DivPlugin, new DivPlugin,
new CsrPlugin(csrConfigAll), new CsrPlugin(csrConfigAll),
// new DebugPlugin(), new DebugPlugin(ClockDomain.current.clone(reset = Bool().setName("debugReset"))),
new BranchPlugin( new BranchPlugin(
earlyBranch = false, earlyBranch = false,
catchAddressMisaligned = true, catchAddressMisaligned = true,

View File

@ -137,6 +137,7 @@ double sc_time_stamp(){
class SimElement{ class SimElement{
public: public:
virtual void onReset(){} virtual void onReset(){}
virtual void postReset(){}
virtual void preCycle(){} virtual void preCycle(){}
virtual void postCycle(){} virtual void postCycle(){}
}; };
@ -292,9 +293,10 @@ public:
top->clk = 0; top->clk = 0;
top->reset = 0; top->reset = 0;
for(SimElement* simElement : simElements) simElement->onReset();
top->eval(); currentTime = 3; top->eval(); currentTime = 3;
for(SimElement* simElement : simElements) simElement->onReset();
top->reset = 1; top->reset = 1;
top->eval(); top->eval();
#ifdef CSR #ifdef CSR
@ -303,6 +305,8 @@ public:
#endif #endif
dump(0); dump(0);
top->reset = 0; top->reset = 0;
for(SimElement* simElement : simElements) simElement->postReset();
top->eval(); currentTime = 2; top->eval(); currentTime = 2;
@ -578,6 +582,52 @@ public:
#endif #endif
#ifdef DEBUG_PLUGIN
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
class DebugPlugin : public SimElement{
public:
Workspace *ws;
VVexRiscv* top;
DebugPlugin(Workspace* ws){
this->ws = ws;
this->top = ws->top;
top->debugReset = 0;
}
virtual void onReset(){
top->debug_bus_cmd_valid = 0;
top->debugReset = 1;
}
virtual void postReset(){
top->debugReset = 0;
}
virtual void preCycle(){
}
virtual void postCycle(){
top->reset = top->debug_resetOut;
/*input debug_bus_cmd_valid,
output debug_bus_cmd_ready,
input debug_bus_cmd_payload_wr,
input [7:0] debug_bus_cmd_payload_address,
input [31:0] debug_bus_cmd_payload_data,
output reg [31:0] debug_bus_rsp_data,
output reg debug_resetOut,*/
}
};
#endif
void Workspace::fillSimELements(){ void Workspace::fillSimELements(){
#ifdef IBUS_SIMPLE #ifdef IBUS_SIMPLE
@ -592,6 +642,9 @@ void Workspace::fillSimELements(){
#ifdef DBUS_CACHED #ifdef DBUS_CACHED
simElements.push_back(new DBusCached(this)); simElements.push_back(new DBusCached(this));
#endif #endif
#ifdef DEBUG_PLUGIN
simElements.push_back(new DebugPlugin(this));
#endif
} }

View File

@ -4,6 +4,7 @@ TRACE=no
TRACE_START=0 TRACE_START=0
CSR=yes CSR=yes
MMU=yes MMU=yes
DEBUG_PLUGIN=yes
DHRYSTONE=yes DHRYSTONE=yes
FREE_RTOS=no FREE_RTOS=no
REDO=10 REDO=10
@ -39,6 +40,10 @@ ifeq ($(MMU),yes)
ADDCFLAGS += -CFLAGS -DMMU ADDCFLAGS += -CFLAGS -DMMU
endif endif
ifeq ($(DEBUG_PLUGIN),yes)
ADDCFLAGS += -CFLAGS -DDEBUG_PLUGIN
endif
ifeq ($(REF),yes) ifeq ($(REF),yes)
ADDCFLAGS += -CFLAGS -DREF ADDCFLAGS += -CFLAGS -DREF
endif endif