Loading cocotb/socket_command.py +5 −4 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,7 @@ class SocketCommand(): self.arguments=None self.arguments=None class x393Client(): class x393Client(): def __init__(self, port=7777, host='localhost'): def __init__(self, host='localhost', port=7777): self.PORT = port self.PORT = port self.HOST = host # Symbolic name meaning all available interfaces self.HOST = host # Symbolic name meaning all available interfaces self.cmd= SocketCommand() self.cmd= SocketCommand() Loading @@ -87,11 +87,12 @@ class x393Client(): print("stop->",self.communicate(self.cmd.toJSON())) print("stop->",self.communicate(self.cmd.toJSON())) def write(self, address, data): def write(self, address, data): self.cmd.setWrite([address,data]) self.cmd.setWrite([address,data]) print("write->",self.communicate(self.cmd.toJSON())) rslt = self.communicate(self.cmd.toJSON()) print("write->",rslt) def read(self, address): def read(self, address): self.cmd.setRead(address) self.cmd.setRead(address) print("read->args",self.cmd.getArgs()) # print("read->args",self.cmd.getArgs()) rslt = self.communicate(self.cmd.toJSON()) rslt = self.communicate(self.cmd.toJSON()) print("read->",rslt) #print("read->",rslt) return json.loads(rslt) return json.loads(rslt) cocotb/x393_cocotb_02.sav +91 −9 Original line number Original line Diff line number Diff line [*] [*] [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] Mon Jul 4 03:19:05 2016 [*] Wed Jul 6 17:53:54 2016 [*] [*] [dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20160703211758949.fst" [dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20160706092756207.fst" [dumpfile_mtime] "Mon Jul 4 03:18:33 2016" [dumpfile_mtime] "Wed Jul 6 16:46:27 2016" [dumpfile_size] 639043 [dumpfile_size] 26909872 [savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_02.sav" [savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_02.sav" [timestart] 10924700 [timestart] 0 [size] 1836 1171 [size] 1836 1171 [pos] 1920 0 [pos] 1920 0 *-16.699684 11530000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 *-24.853212 32750000 32750000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 204 [treeopen] x393_dut. [treeopen] x393_dut.simul_axi_master_wdata_i. [sst_width] 357 [signals_width] 238 [signals_width] 238 [sst_expanded] 1 [sst_expanded] 1 [sst_vpaned_height] 344 [sst_vpaned_height] 484 @821 @820 x393_dut.TEST_TITLE[639:0] x393_dut.TEST_TITLE[639:0] @c00200 -maxi0 @28 @28 x393_dut.dutm0_aclk x393_dut.dutm0_aclk @22 @22 Loading Loading @@ -86,6 +90,8 @@ x393_dut.dutm0_wid_w[11:0] x393_dut.dutm0_wlast x393_dut.dutm0_wlast x393_dut.dutm0_wlast_w x393_dut.dutm0_wlast_w x393_dut.dutm0_wready x393_dut.dutm0_wready @200 - @22 @22 x393_dut.dutm0_wstb[3:0] x393_dut.dutm0_wstb[3:0] x393_dut.dutm0_wstb_w[3:0] x393_dut.dutm0_wstb_w[3:0] Loading @@ -95,5 +101,81 @@ x393_dut.dutm0_wvalid_w @22 @22 x393_dut.dutm0_xtra_blag[3:0] x393_dut.dutm0_xtra_blag[3:0] x393_dut.dutm0_xtra_rdlag[3:0] x393_dut.dutm0_xtra_rdlag[3:0] @1401200 -maxi0 @800200 -SENSOR1 @28 x393_dut.simul_sensor12bits_i.MCLK @22 x393_dut.simul_sensor12bits_i.D[11:0] @28 x393_dut.simul_sensor12bits_i.HACT x393_dut.simul_sensor12bits_i.MRST @29 x393_dut.simul_sensor12bits_i.ARST @28 x393_dut.simul_sensor12bits_i.NMRST x393_dut.simul_sensor12bits_i.stopped x393_dut.simul_sensor12bits_i.DCLK @200 - @1000200 -SENSOR1 @800200 -axi_master_wdata @28 x393_dut.simul_axi_master_wdata_i.clk x393_dut.simul_axi_master_wdata_i.ready x393_dut.simul_axi_master_wdata_i.reset x393_dut.simul_axi_master_wdata_i.set_cmd @22 x393_dut.simul_axi_master_wdata_i.wdata[31:0] x393_dut.simul_axi_master_wdata_i.wdata_in[31:0] x393_dut.simul_axi_master_wdata_i.wdata_out[31:0] x393_dut.simul_axi_master_wdata_i.wid[11:0] x393_dut.simul_axi_master_wdata_i.wid_in[11:0] x393_dut.simul_axi_master_wdata_i.wid_out[11:0] @28 x393_dut.simul_axi_master_wdata_i.wlast x393_dut.simul_axi_master_wdata_i.wlast_in x393_dut.simul_axi_master_wdata_i.wlast_out x393_dut.simul_axi_master_wdata_i.wready @22 x393_dut.simul_axi_master_wdata_i.wstrb[3:0] x393_dut.simul_axi_master_wdata_i.wstrb_in[3:0] x393_dut.simul_axi_master_wdata_i.wstrb_out[3:0] @28 x393_dut.simul_axi_master_wdata_i.wvalid x393_dut.simul_axi_master_wdata_i.wvalid_out @200 - @800200 -simul_axi_fifo @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.clk @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.data_in[48:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.data_out[48:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.in_address x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.in_count @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.input_ready @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.latency_delay[3:0] @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.latency_delay_r[2:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.load @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_address x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_count @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_inc x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.ready x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.reset x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.valid @1000200 -simul_axi_fifo -axi_master_wdata [pattern_trace] 1 [pattern_trace] 1 [pattern_trace] 0 [pattern_trace] 0 cocotb/x393_cocotb_server.py +77 −26 Original line number Original line Diff line number Diff line Loading @@ -38,15 +38,30 @@ import logging class X393_cocotb_server(object): class X393_cocotb_server(object): writeIDMask = (1 <<12) -1 writeIDMask = (1 <<12) -1 readIDMask = (1 <<12) -1 readIDMask = (1 <<12) -1 def __init__(self, dut, port, host): # , debug=False): started=False def __init__(self, dut, port, host, mempath="memfile", autoflush=True): # , debug=False): debug = os.getenv('COCOTB_DEBUG') # None/1 debug = os.getenv('COCOTB_DEBUG') # None/1 self.cmd= SocketCommand() self.cmd= SocketCommand() self.dut = dut self.dut = dut #initialize MAXIGP0 interface (main control/status registers, TODO: add MAXIGP1 for SATA) self.maxigp0 = MAXIGPMaster(entity=dut, name="dutm0", clock=dut.dutm0_aclk, rdlag=0, blag=0) self.maxigp0 = MAXIGPMaster(entity=dut, name="dutm0", clock=dut.dutm0_aclk, rdlag=0, blag=0) self.writeID=0 self.writeID=0 self.readID=0 self.readID=0 #initialize Zynq register access, has methods write_reg(a,d) and read_reg(a) self.ps_sbus = PSBus(entity=dut, name="ps_sbus", clock=dut.ps_sbus_clk) #Bus masters (communicated over mempath file #Membridge to FPGA self.saxihp0r = SAXIRdSim(entity=dut, name="saxihp0", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8) #Membridge from FPGA self.saxihp0w = SAXIWrSim(entity=dut, name="saxihp0", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8, autoflush = autoflush, blatency=5) #Compressors from FPGA self.saxihp1w = SAXIWrSim(entity=dut, name="saxihp1", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8, autoflush = autoflush, blatency=5) #histograms from FPGA self.saxigp0 = SAXIWrSim(entity=dut, name="saxigp0", clock=dut.saxigp0, mempath = mempath, memhigh=0x40000000, data_bytes=4, autoflush = autoflush, blatency=5) level = logging.DEBUG if debug else logging.WARNING level = logging.DEBUG if debug else logging.WARNING self.maxigp0.log.setLevel(level) self.maxigp0.log.setLevel(level) Loading @@ -54,6 +69,7 @@ class X393_cocotb_server(object): self.PORT = port self.PORT = port self.HOST = host # Symbolic name meaning all available interfaces self.HOST = host # Symbolic name meaning all available interfaces self.socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket_conn.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Otherwise restarting program will need 2 minutes try: try: self.socket_conn.bind((self.HOST, self.PORT)) self.socket_conn.bind((self.HOST, self.PORT)) self.dut._log.debug('Socket bind complete, HOST=%s, PORT=%d'%(self.HOST,self.PORT)) self.dut._log.debug('Socket bind complete, HOST=%s, PORT=%d'%(self.HOST,self.PORT)) Loading @@ -62,6 +78,9 @@ class X393_cocotb_server(object): except socket.error as msg: except socket.error as msg: self.logErrorTerminate('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1])) self.logErrorTerminate('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1])) def logErrorTerminate(self, msg): def logErrorTerminate(self, msg): self.dut._log.error(msg) self.dut._log.error(msg) cocotb.regression.tear_down() cocotb.regression.tear_down() Loading @@ -75,20 +94,22 @@ class X393_cocotb_server(object): self.dut._log.debug ("Connected with %s"%(soc_addr[0] + ':' + str(soc_addr[1]))) self.dut._log.debug ("Connected with %s"%(soc_addr[0] + ':' + str(soc_addr[1]))) #Sending message to connected client #Sending message to connected client line = self.soc_conn.recv(4096) # or make it unlimited? line = self.soc_conn.recv(4096) # or make it unlimited? self.dut._log.info("Received from socket: %s"%(line)) self.dut._log.debug("Received from socket: %s"%(line)) except: except: self.logErrorTerminate("Socket seems to have died :-(") self.logErrorTerminate("Socket seems to have died :-(") self.dut._log.info("1.Received from socket: %s"%(line)) self.dut._log.debug("1.Received from socket: %s"%(line)) yield self.executeCommand(line) yield self.executeCommand(line) self.dut._log.debug("3.Received from socket: %s"%(line)) self.dut._log.debug("3.Received from socket: %s"%(line)) @cocotb.coroutine @cocotb.coroutine def executeCommand(self,line): def executeCommand(self,line): self.dut._log.info("1.executeCommand: %s"%(line)) self.dut._log.debug("1.executeCommand: %s"%(line)) if not line: if not line: raise ReturnValue(None) raise ReturnValue(None) self.dut._log.info("2.executeCommand: %s"%(line)) self.dut._log.debug("2.executeCommand: %s"%(line)) self.cmd.fromJSON(line) self.cmd.fromJSON(line) #TODO: add interrupt related commands (including wait IRQ with timeout if self.cmd.getStart(): if self.cmd.getStart(): self.dut._log.info('Received START, waiting reset to be over') self.dut._log.info('Received START, waiting reset to be over') yield Timer(10000) yield Timer(10000) Loading @@ -98,12 +119,18 @@ class X393_cocotb_server(object): while self.dut.reset_out.value: while self.dut.reset_out.value: yield Timer(10000) yield Timer(10000) # Launch all bus masters (no need to join ever, preserving just in case self.self.saxihp0r_thread = cocotb.fork(saxihp0r.saxi_rd_run) self.self.saxihp0w_thread = cocotb.fork(saxihp0w.saxi_wr_run) self.self.saxihp1w_thread = cocotb.fork(saxihp1w.saxi_wr_run) self.self.saxihp2w_thread = cocotb.fork(saxihp2w.saxi_wr_run) self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.dut._log.debug('Sent 0 to the socket') self.dut._log.debug('Sent 0 to the socket') started=True elif self.cmd.getStop(): elif self.cmd.getStop(): self.dut._log.debug('Received STOP, closing...') self.dut._log.info('Received STOP, closing...') self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.close() self.soc_conn.close() yield Timer(10000) # small pause for the wave output yield Timer(10000) # small pause for the wave output Loading @@ -111,11 +138,15 @@ class X393_cocotb_server(object): self.socket_conn.shutdown(socket.SHUT_RDWR) self.socket_conn.shutdown(socket.SHUT_RDWR) self.socket_conn.close() self.socket_conn.close() cocotb.regression.tear_down() cocotb.regression.tear_down() started=False raise TestSuccess('Terminating as received STOP command') raise TestSuccess('Terminating as received STOP command') #For now write - one at a time, TODO: a) consolidate, b) decode address (some will be just a disk file) #For now write - one at a time, TODO: a) consolidate, b) decode address (some will be just a disk file) elif self.cmd.getWrite(): elif self.cmd.getWrite(): ad = self.cmd.getWrite() ad = self.cmd.getWrite() self.dut._log.info('Received WRITE, 0x%0x: %s'%(ad[0],str(ad[1]))) self.dut._log.info('Received WRITE, 0x%0x: %s'%(ad[0],str(ad[1]))) if ad[0] < 0x40000000: pass elif(ad[0] >= 0x40000000) and (ad[0] < 0x80000000): rslt = yield self.maxigp0.axi_write(address = ad[0], rslt = yield self.maxigp0.axi_write(address = ad[0], value = ad[1], value = ad[1], byte_enable = None, byte_enable = None, Loading @@ -126,10 +157,19 @@ class X393_cocotb_server(object): data_latency = 0) data_latency = 0) self.dut._log.info('maxigp0.axi_write yielded %s'%(str(rslt))) self.dut._log.info('maxigp0.axi_write yielded %s'%(str(rslt))) self.writeID = (self.writeID+1) & self.writeIDMask self.writeID = (self.writeID+1) & self.writeIDMask elif ad[0] >= 0xc0000000: self.ps_sbus.write_reg(ad[0],ad[1][0]) rslt = 0 else: self.dut._log.info('Write address 0x%08x is outside of maxgp0, not yet supported'%(ad[0])) rslt = 0 self.soc_conn.send(self.cmd.toJSON(rslt)+"\n") self.soc_conn.send(self.cmd.toJSON(rslt)+"\n") self.dut._log.debug('Sent rslt to the socket') self.dut._log.debug('Sent rslt to the socket') elif self.cmd.getRead(): elif self.cmd.getRead(): a = self.cmd.getRead() a = self.cmd.getRead() if a < 0x40000000: pass if(a >= 0x40000000) and (a < 0x80000000): dval = yield self.maxigp0.axi_read(address = a, dval = yield self.maxigp0.axi_read(address = a, id = self.readID, id = self.readID, dlen = 1, dlen = 1, Loading @@ -138,9 +178,20 @@ class X393_cocotb_server(object): data_latency = 0 ) data_latency = 0 ) self.dut._log.info("axi_read returned => " +str(dval)) self.dut._log.info("axi_read returned => " +str(dval)) self.readID = (self.readID+1) & self.readIDMask self.readID = (self.readID+1) & self.readIDMask elif ad[0] >= 0xc0000000: dval = yield self.ps_sbus.read_reg(ad[0]) else: self.dut._log.info('Read address 0x%08x is outside of maxgp0, not yet supported'%(a)) dval = [0] self.soc_conn.send(self.cmd.toJSON(dval)+"\n") self.soc_conn.send(self.cmd.toJSON(dval)+"\n") self.dut._log.debug('Sent dval to the socket') self.dut._log.debug('Sent dval to the socket') def flush_all(self): self.self.saxihp0w.flush() self.self.saxihp1w.flush() self.self.saxihp2w.flush() def convert_string(txt): def convert_string(txt): number=0 number=0 for c in txt: for c in txt: Loading @@ -154,7 +205,7 @@ def run_test(dut, port=7777): while True: while True: try: try: rslt= yield tb.receiveCommandFromSocket() rslt= yield tb.receiveCommandFromSocket() dut._log.info("rslt = %s"%(str(rslt))) dut._log.debug("rslt = %s"%(str(rslt))) except ReturnValue as rv: except ReturnValue as rv: line = rv.retval; line = rv.retval; dut._log.info("rv = %s"%(str(rv))) dut._log.info("rv = %s"%(str(rv))) Loading Loading
cocotb/socket_command.py +5 −4 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,7 @@ class SocketCommand(): self.arguments=None self.arguments=None class x393Client(): class x393Client(): def __init__(self, port=7777, host='localhost'): def __init__(self, host='localhost', port=7777): self.PORT = port self.PORT = port self.HOST = host # Symbolic name meaning all available interfaces self.HOST = host # Symbolic name meaning all available interfaces self.cmd= SocketCommand() self.cmd= SocketCommand() Loading @@ -87,11 +87,12 @@ class x393Client(): print("stop->",self.communicate(self.cmd.toJSON())) print("stop->",self.communicate(self.cmd.toJSON())) def write(self, address, data): def write(self, address, data): self.cmd.setWrite([address,data]) self.cmd.setWrite([address,data]) print("write->",self.communicate(self.cmd.toJSON())) rslt = self.communicate(self.cmd.toJSON()) print("write->",rslt) def read(self, address): def read(self, address): self.cmd.setRead(address) self.cmd.setRead(address) print("read->args",self.cmd.getArgs()) # print("read->args",self.cmd.getArgs()) rslt = self.communicate(self.cmd.toJSON()) rslt = self.communicate(self.cmd.toJSON()) print("read->",rslt) #print("read->",rslt) return json.loads(rslt) return json.loads(rslt)
cocotb/x393_cocotb_02.sav +91 −9 Original line number Original line Diff line number Diff line [*] [*] [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] Mon Jul 4 03:19:05 2016 [*] Wed Jul 6 17:53:54 2016 [*] [*] [dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20160703211758949.fst" [dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20160706092756207.fst" [dumpfile_mtime] "Mon Jul 4 03:18:33 2016" [dumpfile_mtime] "Wed Jul 6 16:46:27 2016" [dumpfile_size] 639043 [dumpfile_size] 26909872 [savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_02.sav" [savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_02.sav" [timestart] 10924700 [timestart] 0 [size] 1836 1171 [size] 1836 1171 [pos] 1920 0 [pos] 1920 0 *-16.699684 11530000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 *-24.853212 32750000 32750000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 204 [treeopen] x393_dut. [treeopen] x393_dut.simul_axi_master_wdata_i. [sst_width] 357 [signals_width] 238 [signals_width] 238 [sst_expanded] 1 [sst_expanded] 1 [sst_vpaned_height] 344 [sst_vpaned_height] 484 @821 @820 x393_dut.TEST_TITLE[639:0] x393_dut.TEST_TITLE[639:0] @c00200 -maxi0 @28 @28 x393_dut.dutm0_aclk x393_dut.dutm0_aclk @22 @22 Loading Loading @@ -86,6 +90,8 @@ x393_dut.dutm0_wid_w[11:0] x393_dut.dutm0_wlast x393_dut.dutm0_wlast x393_dut.dutm0_wlast_w x393_dut.dutm0_wlast_w x393_dut.dutm0_wready x393_dut.dutm0_wready @200 - @22 @22 x393_dut.dutm0_wstb[3:0] x393_dut.dutm0_wstb[3:0] x393_dut.dutm0_wstb_w[3:0] x393_dut.dutm0_wstb_w[3:0] Loading @@ -95,5 +101,81 @@ x393_dut.dutm0_wvalid_w @22 @22 x393_dut.dutm0_xtra_blag[3:0] x393_dut.dutm0_xtra_blag[3:0] x393_dut.dutm0_xtra_rdlag[3:0] x393_dut.dutm0_xtra_rdlag[3:0] @1401200 -maxi0 @800200 -SENSOR1 @28 x393_dut.simul_sensor12bits_i.MCLK @22 x393_dut.simul_sensor12bits_i.D[11:0] @28 x393_dut.simul_sensor12bits_i.HACT x393_dut.simul_sensor12bits_i.MRST @29 x393_dut.simul_sensor12bits_i.ARST @28 x393_dut.simul_sensor12bits_i.NMRST x393_dut.simul_sensor12bits_i.stopped x393_dut.simul_sensor12bits_i.DCLK @200 - @1000200 -SENSOR1 @800200 -axi_master_wdata @28 x393_dut.simul_axi_master_wdata_i.clk x393_dut.simul_axi_master_wdata_i.ready x393_dut.simul_axi_master_wdata_i.reset x393_dut.simul_axi_master_wdata_i.set_cmd @22 x393_dut.simul_axi_master_wdata_i.wdata[31:0] x393_dut.simul_axi_master_wdata_i.wdata_in[31:0] x393_dut.simul_axi_master_wdata_i.wdata_out[31:0] x393_dut.simul_axi_master_wdata_i.wid[11:0] x393_dut.simul_axi_master_wdata_i.wid_in[11:0] x393_dut.simul_axi_master_wdata_i.wid_out[11:0] @28 x393_dut.simul_axi_master_wdata_i.wlast x393_dut.simul_axi_master_wdata_i.wlast_in x393_dut.simul_axi_master_wdata_i.wlast_out x393_dut.simul_axi_master_wdata_i.wready @22 x393_dut.simul_axi_master_wdata_i.wstrb[3:0] x393_dut.simul_axi_master_wdata_i.wstrb_in[3:0] x393_dut.simul_axi_master_wdata_i.wstrb_out[3:0] @28 x393_dut.simul_axi_master_wdata_i.wvalid x393_dut.simul_axi_master_wdata_i.wvalid_out @200 - @800200 -simul_axi_fifo @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.clk @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.data_in[48:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.data_out[48:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.in_address x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.in_count @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.input_ready @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.latency_delay[3:0] @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.latency_delay_r[2:0] x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.load @8022 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_address x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_count @8028 x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.out_inc x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.ready x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.reset x393_dut.simul_axi_master_wdata_i.simul_axi_fifo_i.valid @1000200 -simul_axi_fifo -axi_master_wdata [pattern_trace] 1 [pattern_trace] 1 [pattern_trace] 0 [pattern_trace] 0
cocotb/x393_cocotb_server.py +77 −26 Original line number Original line Diff line number Diff line Loading @@ -38,15 +38,30 @@ import logging class X393_cocotb_server(object): class X393_cocotb_server(object): writeIDMask = (1 <<12) -1 writeIDMask = (1 <<12) -1 readIDMask = (1 <<12) -1 readIDMask = (1 <<12) -1 def __init__(self, dut, port, host): # , debug=False): started=False def __init__(self, dut, port, host, mempath="memfile", autoflush=True): # , debug=False): debug = os.getenv('COCOTB_DEBUG') # None/1 debug = os.getenv('COCOTB_DEBUG') # None/1 self.cmd= SocketCommand() self.cmd= SocketCommand() self.dut = dut self.dut = dut #initialize MAXIGP0 interface (main control/status registers, TODO: add MAXIGP1 for SATA) self.maxigp0 = MAXIGPMaster(entity=dut, name="dutm0", clock=dut.dutm0_aclk, rdlag=0, blag=0) self.maxigp0 = MAXIGPMaster(entity=dut, name="dutm0", clock=dut.dutm0_aclk, rdlag=0, blag=0) self.writeID=0 self.writeID=0 self.readID=0 self.readID=0 #initialize Zynq register access, has methods write_reg(a,d) and read_reg(a) self.ps_sbus = PSBus(entity=dut, name="ps_sbus", clock=dut.ps_sbus_clk) #Bus masters (communicated over mempath file #Membridge to FPGA self.saxihp0r = SAXIRdSim(entity=dut, name="saxihp0", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8) #Membridge from FPGA self.saxihp0w = SAXIWrSim(entity=dut, name="saxihp0", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8, autoflush = autoflush, blatency=5) #Compressors from FPGA self.saxihp1w = SAXIWrSim(entity=dut, name="saxihp1", clock=dut.axi_hclk, mempath = mempath, memhigh=0x40000000, data_bytes=8, autoflush = autoflush, blatency=5) #histograms from FPGA self.saxigp0 = SAXIWrSim(entity=dut, name="saxigp0", clock=dut.saxigp0, mempath = mempath, memhigh=0x40000000, data_bytes=4, autoflush = autoflush, blatency=5) level = logging.DEBUG if debug else logging.WARNING level = logging.DEBUG if debug else logging.WARNING self.maxigp0.log.setLevel(level) self.maxigp0.log.setLevel(level) Loading @@ -54,6 +69,7 @@ class X393_cocotb_server(object): self.PORT = port self.PORT = port self.HOST = host # Symbolic name meaning all available interfaces self.HOST = host # Symbolic name meaning all available interfaces self.socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket_conn.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Otherwise restarting program will need 2 minutes try: try: self.socket_conn.bind((self.HOST, self.PORT)) self.socket_conn.bind((self.HOST, self.PORT)) self.dut._log.debug('Socket bind complete, HOST=%s, PORT=%d'%(self.HOST,self.PORT)) self.dut._log.debug('Socket bind complete, HOST=%s, PORT=%d'%(self.HOST,self.PORT)) Loading @@ -62,6 +78,9 @@ class X393_cocotb_server(object): except socket.error as msg: except socket.error as msg: self.logErrorTerminate('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1])) self.logErrorTerminate('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1])) def logErrorTerminate(self, msg): def logErrorTerminate(self, msg): self.dut._log.error(msg) self.dut._log.error(msg) cocotb.regression.tear_down() cocotb.regression.tear_down() Loading @@ -75,20 +94,22 @@ class X393_cocotb_server(object): self.dut._log.debug ("Connected with %s"%(soc_addr[0] + ':' + str(soc_addr[1]))) self.dut._log.debug ("Connected with %s"%(soc_addr[0] + ':' + str(soc_addr[1]))) #Sending message to connected client #Sending message to connected client line = self.soc_conn.recv(4096) # or make it unlimited? line = self.soc_conn.recv(4096) # or make it unlimited? self.dut._log.info("Received from socket: %s"%(line)) self.dut._log.debug("Received from socket: %s"%(line)) except: except: self.logErrorTerminate("Socket seems to have died :-(") self.logErrorTerminate("Socket seems to have died :-(") self.dut._log.info("1.Received from socket: %s"%(line)) self.dut._log.debug("1.Received from socket: %s"%(line)) yield self.executeCommand(line) yield self.executeCommand(line) self.dut._log.debug("3.Received from socket: %s"%(line)) self.dut._log.debug("3.Received from socket: %s"%(line)) @cocotb.coroutine @cocotb.coroutine def executeCommand(self,line): def executeCommand(self,line): self.dut._log.info("1.executeCommand: %s"%(line)) self.dut._log.debug("1.executeCommand: %s"%(line)) if not line: if not line: raise ReturnValue(None) raise ReturnValue(None) self.dut._log.info("2.executeCommand: %s"%(line)) self.dut._log.debug("2.executeCommand: %s"%(line)) self.cmd.fromJSON(line) self.cmd.fromJSON(line) #TODO: add interrupt related commands (including wait IRQ with timeout if self.cmd.getStart(): if self.cmd.getStart(): self.dut._log.info('Received START, waiting reset to be over') self.dut._log.info('Received START, waiting reset to be over') yield Timer(10000) yield Timer(10000) Loading @@ -98,12 +119,18 @@ class X393_cocotb_server(object): while self.dut.reset_out.value: while self.dut.reset_out.value: yield Timer(10000) yield Timer(10000) # Launch all bus masters (no need to join ever, preserving just in case self.self.saxihp0r_thread = cocotb.fork(saxihp0r.saxi_rd_run) self.self.saxihp0w_thread = cocotb.fork(saxihp0w.saxi_wr_run) self.self.saxihp1w_thread = cocotb.fork(saxihp1w.saxi_wr_run) self.self.saxihp2w_thread = cocotb.fork(saxihp2w.saxi_wr_run) self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.dut._log.debug('Sent 0 to the socket') self.dut._log.debug('Sent 0 to the socket') started=True elif self.cmd.getStop(): elif self.cmd.getStop(): self.dut._log.debug('Received STOP, closing...') self.dut._log.info('Received STOP, closing...') self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.send(self.cmd.toJSON(0)+"\n") self.soc_conn.close() self.soc_conn.close() yield Timer(10000) # small pause for the wave output yield Timer(10000) # small pause for the wave output Loading @@ -111,11 +138,15 @@ class X393_cocotb_server(object): self.socket_conn.shutdown(socket.SHUT_RDWR) self.socket_conn.shutdown(socket.SHUT_RDWR) self.socket_conn.close() self.socket_conn.close() cocotb.regression.tear_down() cocotb.regression.tear_down() started=False raise TestSuccess('Terminating as received STOP command') raise TestSuccess('Terminating as received STOP command') #For now write - one at a time, TODO: a) consolidate, b) decode address (some will be just a disk file) #For now write - one at a time, TODO: a) consolidate, b) decode address (some will be just a disk file) elif self.cmd.getWrite(): elif self.cmd.getWrite(): ad = self.cmd.getWrite() ad = self.cmd.getWrite() self.dut._log.info('Received WRITE, 0x%0x: %s'%(ad[0],str(ad[1]))) self.dut._log.info('Received WRITE, 0x%0x: %s'%(ad[0],str(ad[1]))) if ad[0] < 0x40000000: pass elif(ad[0] >= 0x40000000) and (ad[0] < 0x80000000): rslt = yield self.maxigp0.axi_write(address = ad[0], rslt = yield self.maxigp0.axi_write(address = ad[0], value = ad[1], value = ad[1], byte_enable = None, byte_enable = None, Loading @@ -126,10 +157,19 @@ class X393_cocotb_server(object): data_latency = 0) data_latency = 0) self.dut._log.info('maxigp0.axi_write yielded %s'%(str(rslt))) self.dut._log.info('maxigp0.axi_write yielded %s'%(str(rslt))) self.writeID = (self.writeID+1) & self.writeIDMask self.writeID = (self.writeID+1) & self.writeIDMask elif ad[0] >= 0xc0000000: self.ps_sbus.write_reg(ad[0],ad[1][0]) rslt = 0 else: self.dut._log.info('Write address 0x%08x is outside of maxgp0, not yet supported'%(ad[0])) rslt = 0 self.soc_conn.send(self.cmd.toJSON(rslt)+"\n") self.soc_conn.send(self.cmd.toJSON(rslt)+"\n") self.dut._log.debug('Sent rslt to the socket') self.dut._log.debug('Sent rslt to the socket') elif self.cmd.getRead(): elif self.cmd.getRead(): a = self.cmd.getRead() a = self.cmd.getRead() if a < 0x40000000: pass if(a >= 0x40000000) and (a < 0x80000000): dval = yield self.maxigp0.axi_read(address = a, dval = yield self.maxigp0.axi_read(address = a, id = self.readID, id = self.readID, dlen = 1, dlen = 1, Loading @@ -138,9 +178,20 @@ class X393_cocotb_server(object): data_latency = 0 ) data_latency = 0 ) self.dut._log.info("axi_read returned => " +str(dval)) self.dut._log.info("axi_read returned => " +str(dval)) self.readID = (self.readID+1) & self.readIDMask self.readID = (self.readID+1) & self.readIDMask elif ad[0] >= 0xc0000000: dval = yield self.ps_sbus.read_reg(ad[0]) else: self.dut._log.info('Read address 0x%08x is outside of maxgp0, not yet supported'%(a)) dval = [0] self.soc_conn.send(self.cmd.toJSON(dval)+"\n") self.soc_conn.send(self.cmd.toJSON(dval)+"\n") self.dut._log.debug('Sent dval to the socket') self.dut._log.debug('Sent dval to the socket') def flush_all(self): self.self.saxihp0w.flush() self.self.saxihp1w.flush() self.self.saxihp2w.flush() def convert_string(txt): def convert_string(txt): number=0 number=0 for c in txt: for c in txt: Loading @@ -154,7 +205,7 @@ def run_test(dut, port=7777): while True: while True: try: try: rslt= yield tb.receiveCommandFromSocket() rslt= yield tb.receiveCommandFromSocket() dut._log.info("rslt = %s"%(str(rslt))) dut._log.debug("rslt = %s"%(str(rslt))) except ReturnValue as rv: except ReturnValue as rv: line = rv.retval; line = rv.retval; dut._log.info("rv = %s"%(str(rv))) dut._log.info("rv = %s"%(str(rv))) Loading