kyaso / py-v Goto Github PK
View Code? Open in Web Editor NEWA cycle-accurate RISC-V CPU simulator + RTL modeling library in pure Python.
License: MIT License
A cycle-accurate RISC-V CPU simulator + RTL modeling library in pure Python.
License: MIT License
To model delayed events, such as a DRAM access, it would be nice if we could post events into the future.
Line 51 in 40178d3
For the different test programs, note down "cycles/second" (with and without logging), what host CPU, which version etc.
Instead of printing all ports/wires, allow the user to specify which ports to log. E.g. using a text file. The simulator would then only print the ports matching the strings given in the text/config file.
Scenario: Assume there is a module A
, which contains another module B
. A
, inside its process()
method, takes B
's output (by directly reading B
's output port), computes something with it, and writes something to its own output.
Regardless of how B
's input ports are wired up (they could be either connected directly to one of A
's inputs or, they could be written to during A
's processing), A
will always be processed before B
.
Now, when B
's output changes, who is notified? Only input ports can notify their parent module.
Similar to Verilog/VHDL, when we want to use some output of an inner module within the outer module, we should connect that output to some wire. That way, whenever the inner module's output changes, the change is also captured by the wire, thus adding the outer module to the simulation queue.
There is no real need to read an output port anyways, so we could just throw an exception when an output port is read.
The designer shouldn't have to deal with adding functions to the simulation queue.
E.g. see todo in Memory._tick()
.
(This issue is not referring to invalid memory accesses caused by running programs)
When during the current cycle some module's process function gets executed with unstable port values, and one of these unstable ports is used as a memory address (or any other list for that matter), we might have an invalid access exception (in Python).
However, as the port is unstable, we have to assume that it eventually will stabilize, and then the process method is executed again with valid inputs. While we are processing with unstable values, we need to relax access checks. Catching the exception and maybe issuing a warning instead might be a solution.
Currently, we have two choices for default values of Ports:
None
Both options have issues. When a module gets added to the simulation queue, but at least one input port still has a None
value, computation might fail. On the other hand, a numeric default value could coincide with the reset value of a connected register. Thus at the very beginning of the sim, when the reset is asserted, the port will not see any change. However, it is not guaranteed that the output ports of the corresponding module have valid values, so forced processing in the first cycle is mandatory.
Introduce a flag attribute in the Port
class that indicates whether the port is written for the first time or not. When the port is written for the first time, the _propagate()
method is called irrespective of the new value. From the next write on, the normal behavior applies, i.e., only propagate when the value has changed.
Add some basic exception handling as required by the RISC-V spec.
The following exceptions should be covered in the future:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.