Created
May 3, 2016 11:12
-
-
Save mkatsimpris/268255ad3f47e66d1a6b0ded52cbd072 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
from myhdl import * | |
@block | |
def RAM(dout, din, raddr,waddr, we, clk,addr_width=8, data_width=24): | |
""" Ram model """ | |
mem = [Signal(intbv(0)[data_width:]) for i in range(int(2**addr_width))] | |
read_addr=Signal(intbv(0)[addr_width:]) | |
@always_comb | |
def out(): | |
dout.next=mem[read_addr] | |
@always(clk.posedge) | |
def write(): | |
read_addr.next=raddr | |
if we: | |
mem[waddr].next = din | |
return instances() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment