Commit bb50682f authored by Khoi Lam's avatar Khoi Lam 💬
Browse files

done mux, working on alu and regfile

parent b34b8ff7
def alu(op1, op2, alu_fun):
# filename: mux.py
def make_mux2(*args):
# returns a function with arguments args
return lambda i: (args)[i]()
if __name__=="__main__":
# mux here is a variable that contains a function with argument i
mux = make_mux2(lambda: 1, lambda: 2, lambda:3, lambda:4, lambda:5)
for i in range(5):
print(f"mux({i}) == {mux(i)}") # mux function is called here and i is passed in as parameter
'''
Implementation of a physical register file that you can read from and write to
'''
from pydigital.riscv_isa import regNumToName
class RegFile():
def __init__(self):
self.registers = [0] * 32
def __str__(self):
return str(self.registers)
## TODO: complete read and write and __str__
def read(self, rs):
'''
rs: adress to read from (int)
'''
pass
def write(self, wa, wd, en):
'''
wa: address to write to
wd: content to write to an address
en: boolean value: 1 = write
'''
pass
if __name__ == "__main__":
myRegFile = RegFile()
print(myRegFile)
#print(myRegFile.read(4))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment