Old 11-14-2008   #1 (permalink)
GUN
Advanced Member
 
GUN's Avatar
 

Join Date: Jan 2008
Location: california
Posts: 252
GUN is on a distinguished road
Send a message via Yahoo to GUN
Default Ram 1k

while im trying to get better at lua coding, i made a 1k ram with 1024 write/readable addresses

Code:
GateActions["ram1k"] = {
    group = "Memory",
    name = "RAM(1kb)",
    inputs = { "Clk", "AddrRead", "AddrWrite", "Data", "Reset" },
    output = function(gate, Clk, AddrRead, AddrWrite, Data, Reset )
    if (Reset > 0) then
            gate.LatchStore = {}
    end

        AddrRead = math.floor(tonumber(AddrRead))
        AddrWrite = math.floor(tonumber(AddrWrite))
        if (Clk > 0) then
            if (AddrWrite < 1024) then
                    gate.LatchStore[AddrWrite] = Data
            end
        end
        return gate.LatchStore[AddrRead] or 0
    end,
    reset = function(gate)
        gate.LatchStore = {}
    end,
    label = function(Out, Clk, AddrRead, AddrWrite, Data, Reset )
        return "WriteAddr:"..AddrWrite.."  Data:"..Data.."  Clock:"..Clk.."  Reset:"..Reset..
            "\nReadAddr:"..AddrRead.." = "..Out
    end,
    ReadCell = function(dummy,gate,Address)
    if (Address < 0) || (Address > 1024) then
        return 0
    else
        return gate.LatchStore[Address] or 0
    end
    end,
    WriteCell = function(dummy,gate,Address,value)
    if (Address < 0) || (Address >     1024) then
        return false
    else
        gate.LatchStore[Address] = value
        return true
    end
    end
}
and i also added a wire able Reset to the increment/decrement counter


Code:
GateActions["increment/decrement"] = {
    group = "Arithmetic",
    name = "Increment/Decrement",
    inputs = { "A", "Increment", "Decrement", "Reset" },
    output = function(gate, A, Increment, Decrement, Reset)
        local increment = ( Increment > 0 )
        local decrement = ( Decrement > 0 )
        local reset = ( Reset > 0 )
        
        if ( gate.PrevValue ~=  increment ) then
            gate.PrevValue = increment
            if ( increment ) then
                gate.Memory = (gate.Memory or 0) + A
            end
        end
        
        if ( gate.PrevValue ~=  decrement ) then
            gate.PrevValue = decrement
            if ( decrement ) then
                gate.Memory = (gate.Memory or 0) - A
            end
        end
        
        if ( reset ) then
            gate.Memory = 0    
        end
        
        return gate.Memory
    end,
    label = function(Out, A)
        return "(" .. A .. " +/- LastNum) = " .. Out
    end
}
add to the svn if possible please
__________________
GUN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 11-14-2008   #2 (permalink)
COMPLETE BLOODY BASTARD

 
AzraelUK's Avatar
 

Join Date: Aug 2007
Location: Camelot, it is a silly place.
Posts: 583
AzraelUK is on a distinguished road
Send a message via MSN to AzraelUK
Default Re: Ram 1k

I might make a RAM tool that allows you to have a custom amount of values.
__________________
A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
—Antoine De Saint-Exupery
AzraelUK is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-14-2008   #3 (permalink)
GUN
Advanced Member
 
GUN's Avatar
 

Join Date: Jan 2008
Location: california
Posts: 252
GUN is on a distinguished road
Send a message via Yahoo to GUN
Default Re: Ram 1k

Quote:
Originally Posted by AzraelUK View Post
I might make a RAM tool that allows you to have a custom amount of values.
hm.. that actually doesn't sound bad at all
__________________
GUN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-14-2008   #4 (permalink)
Advanced Member
 
Borsty's Avatar
 

Join Date: Apr 2007
Posts: 102
Borsty is on a distinguished road
Default Re: Ram 1k

Quote:
Originally Posted by AzraelUK View Post
I might make a RAM tool that allows you to have a custom amount of values.
I already added that to the uwsvn, called it "Dynamic memory". It even allows to save the values stored in it when duplicating.
__________________
«You're thinking with wires»
Borsty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-14-2008   #5 (permalink)
Wire Guru

 
Black Phoenix's Avatar
 

Join Date: Feb 2007
Location: Kyiv, Ukraine
Posts: 2,203
Black Phoenix will become famous soon enough
Send a message via ICQ to Black Phoenix Send a message via MSN to Black Phoenix Send a message via Yahoo to Black Phoenix
Default Re: Ram 1k

There's 128KB RAM in SVN already, so is 4KB ram (64x64 store)
__________________
I'm a wire-crazy person with a tail.

Take a daily journey into my brain

D2K5

Black Phoenix is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-14-2008   #6 (permalink)
GUN
Advanced Member
 
GUN's Avatar
 

Join Date: Jan 2008
Location: california
Posts: 252
GUN is on a distinguished road
Send a message via Yahoo to GUN
Default Re: Ram 1k

Quote:
Originally Posted by Borsty View Post
I already added that to the uwsvn, called it "Dynamic memory". It even allows to save the values stored in it when duplicating.
how did you get the values to be able to duplicate?
__________________
GUN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 11:58 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.

Page top