1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
This commit is contained in:
jand 2003-05-08 18:44:11 +00:00
parent 964877c93b
commit c9b8f150db
7 changed files with 14 additions and 31 deletions

View File

@ -226,7 +226,7 @@ static PLI_INT32 to_myhdl_readonly_callback(p_cb_data cb_data)
vpiHandle net_iter, net_handle;
vpiHandle reg_iter, reg_handle;
s_cb_data cb_data_s;
s_vpi_time verilog_time;
s_vpi_time verilog_time_s;
s_vpi_value value_s;
s_vpi_time time_s;
char buf[MAXLINE];
@ -245,11 +245,13 @@ static PLI_INT32 to_myhdl_readonly_callback(p_cb_data cb_data)
assert(n > 0);
}
net_iter = vpi_iterate(vpiArgument, to_myhdl_systf_handle);
buf[0] = '\0';
verilog_time.type = vpiSimTime;
vpi_get_time(systf_handle, &verilog_time);
sprintf(buf, "%xd%08x ", verilog_time.high, verilog_time.low);
verilog_time_s.type = vpiSimTime;
vpi_get_time(NULL, &verilog_time_s);
verilog_time = timestruct_to_time(&verilog_time_s);
assert(verilog_time == pli_time * 1000 + delta);
sprintf(buf, "%llu ", pli_time);
net_iter = vpi_iterate(vpiArgument, to_myhdl_systf_handle);
value_s.format = vpiHexStrVal;
while ((net_handle = vpi_scan(net_iter)) != NULL) {
vpi_get_value(net_handle, &value_s);

View File

@ -30,8 +30,6 @@ sys.path.append("../../test")
import test_bin2gray, test_inc
modules = (test_bin2gray, test_inc)
modules = (test_bin2gray, )
modules = (test_inc, )
import unittest

View File

@ -16,11 +16,6 @@ def nextLn(Ln):
Ln1.reverse()
return Ln0 + Ln1
## def bin2gray(B, G, width):
## while 1:
## yield B
## G.next = B[0]
class TestOriginalGrayCode(TestCase):
def testOriginalGrayCode(self):
@ -72,7 +67,7 @@ class TestGrayCodeProperties(TestCase):
dut = bin2gray(B, G, width)
check = test(B, G, G_Z, width)
sim = Simulation(dut, check)
sim.run(quiet=0)
sim.run(quiet=1)
def testUniqueCodeWords(self):

View File

@ -34,7 +34,7 @@ class TestInc(TestCase):
reset.next = ACTIVE_LOW
yield negedge(clock)
reset.next = INACTIVE_HIGH
for i in range(20):
for i in range(1000):
enable.next = min(1, randrange(5))
yield negedge(clock)
raise StopSimulation
@ -48,7 +48,7 @@ class TestInc(TestCase):
if enable:
expect = (expect + 1) % n
yield delay(1)
print "%d count %s expect %s" % (now(), count, expect)
# print "%d count %s expect %s" % (now(), count, expect)
self.assertEqual(count, expect)
Simulation(clockGen(), stimulus(), INC_1, check()).run(quiet=1)

View File

@ -10,9 +10,7 @@ module inc(count, enable, clock, reset);
initial
count = 0;
always @(posedge clock or negedge reset) begin
// $display("Always triggered: count %d", count);
if (reset == 0) begin
count <= 0;
end
@ -20,14 +18,11 @@ module inc(count, enable, clock, reset);
if (enable) begin
count <= (count + 1) % n;
end
// $display("count %d", count);
end
end // always @ (posedge clock or negedge reset)
always @ (count) begin
$display("%d count %d", $time, count);
end
// always @ (count) begin
// $display("%d count %d", $time, count);
// end
endmodule // inc

View File

@ -136,11 +136,9 @@ class Cosimulation(object):
break
else:
raise Error, "Unexpected cosim input"
# os.waitpid(child_pid, 0)
def _get(self):
s = os.read(self._rt, _MAXLINE)
# print "Reading " + s
if not s:
raise SimulationEndError
e = s.split()
@ -157,23 +155,18 @@ class Cosimulation(object):
buf = repr(time)
if buf[-1] == 'L':
buf = buf[:-1] # strip trailing L
if self._isActive:
self._isActive -= 1
if self._hasChange:
self._hasChange = 0
for s in self._fromSigs:
buf += " "
buf += hex(s)[2:]
# print "Writing " + buf
os.write(self._wf, buf)
def _waiter(self):
sigs = tuple(self._fromSigs)
while 1:
yield sigs
# print sigs
self._hasChange = 1
self._isActive = 1
def __del__(self):
""" Clear flag when this object destroyed - to suite unittest. """

View File

@ -218,7 +218,7 @@ class CosimulationTest(TestCase):
os.read(rf, MAXLINE)
os.write(wt, "DUMMY")
s = os.read(rf, MAXLINE)
vals = [long(e, 16) for e in s.split()[2:]]
vals = [long(e, 16) for e in s.split()[1:]]
self.assertEqual(vals, fromVals)
def testToSignalVals(self):