grantslape / cs3339-mips32 Goto Github PK
View Code? Open in Web Editor NEW5 stage, pipelined MIPS32 processor in myHDL and Verilog
License: GNU General Public License v3.0
5 stage, pipelined MIPS32 processor in myHDL and Verilog
License: GNU General Public License v3.0
Typically in the MIPS architecture instruction memory and data memory come from the same general main memory. For the purposes of this pipeline however, the instruction memory and data memory buffers are separate.
This creates an issue with how we access instructions. We increment the PC by 4
each cycle in the pc_adder
, but the next sequential instruction differs in address by 1
.
I believe the fix here will be to take actual_index = incoming_instruction_address % 4
inside the instruction memory itself, since that module is what differs from the typical architecture.
This will involve updates to the following:
inst_mem.py
inst_mem.v
inst_mem_tb.v
test_inst_mem.py
The build fails unit test TestInstMemPython seemingly randomly. This is difficult to reproduce, which seems to be caused by the PRNG not being seeded in a consistent manner.
======================================================================
ERROR: testInstMemDynamicPython (test.test_inst_mem.TestInstructionMemory)
Testing regular operation Python
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/test/test_inst_mem.py", line 45, in testInstMemDynamicPython
Simulation(stim, self.dut).run(quiet=1)
File "/usr/local/lib/python3.6/site-packages/myhdl/_Simulation.py", line 152, in run
waiter.next(waiters, actives, exc)
File "/usr/local/lib/python3.6/site-packages/myhdl/_Waiter.py", line 172, in next
clause = next(self.generator)
File "/usr/local/lib/python3.6/site-packages/myhdl/_always_comb.py", line 83, in genfunc
func()
File "/app/src/python/inst_mem.py", line 25, in logic
inst_out.next = raw_mem[inst_reg//4]
IndexError: list index out of range```
Currently our processor is limited to 1M (2 ^ 20) instructions via a static array size. Our project requirements need us to support an arbitrarily long simulation, with numbers in the several million being thrown around.
Given these parameters, eventually we are going to reach the last instruction in our array, and we need to ensure that we do not step out of bounds and cause the simulation to fail.
We can get around this by always generating an unconditional jump to the beginning as the last instruction. in assembly this instruction would be j 0x0
This will work as follows:
0
to 28 bits of 0
.0000
0x00000000
which when we floor divide by 4 gives us the index of the first instruction in memory, 0.We're going to have to add a pathway for the 32 bit PC+4 address to route into the Reg WB pathway, and set the register to write back to as $ra to support the jal Lbl
style instructions. We can achieve this by activating writeback reg signals and adding the value of this immediate to zero, or otherwise dropping it into the Reg WB pathway after the ALU output.
Here's where we can hash out the main driver structure. We had some good conversations in class, and here is where we can turn those ideas into a functioning implementation. Given the time we have left, I think that we should start minimal with just the necessary checks and then build up other assertions that would be nice to have.
I'm envisioning a script that will run on the command line, and will use the instruction generator and config file to generate instructions. If the config file is malformed, default values will be used.
We don't want to end execution if there is a mismatch in the finished product. We should probably print it out and/or log it to a file for analysis. This may benefit us as we inevitably run into issues building the driver.
Some good resources from the myHDL docs, obviously ignore the @block
decorators: http://docs.myhdl.org/en/stable/manual/structure.html
duration
keyword argument of Simulation.run()
Is the example.txt file needed for anything? if not this is just a note that we should probably remove it soon.
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.