【发布时间】:2022-11-15 06:21:54
【问题描述】:
在这里,我想在 cocotb 上创建一个 csv 文件,但以下代码适用于 Google Colab,它运行良好。
import cocotb
from cocotb.triggers import Timer
import random
import pyuvm
import pandas as pd
from pandas import Series, DataFrame
import os
from google.colab import drive
drive.mount('/content/drive')
os.chdir('/content/drive/My Drive/Colab Notebooks')
Now i have generated random numbers and then append them in a list, also generated random op_code.
@cocotb.test()
async def CODE_AA(dut):
listA = []
listB = []
listC = []
ALU_CONTROL = ['00', '01', '10', '11'] #['0', '1', '2', '3']
for i in range(10):
A = random.randint(0, 1000)
listA.append(A)
await Timer(20, units = "ns")
print(A)
B = random.randint(0, 1000)
listB.append(B)
await Timer(20, units = "ns")
print(B)
#C = random.randint(0, 3)
listC.append(random.choice(ALU_CONTROL))
print(listC)
DICT= {'A': listA, 'B': listB, 'C': listC}
dfA = pd.DataFrame.from_dict(DICT)
dfA_Transposed = dfA.T
print(dfA)
dfA.to_csv('basic_py.csv')
DICT = {'A': listA, 'B': listB, 'C': listC}
dfA = pd.DataFrame.from_dict(DICT)
print(dfA)
我现在想使用 cocotb 在 Ubuntu 服务器上制作 CSV 文件,这段代码在 Google Colab 上运行完美。请指导我解决这个问题
【问题讨论】:
标签: python python-3.x csv ubuntu