Skip to content

Instantly share code, notes, and snippets.

@epall
Created November 30, 2009 20:26
Show Gist options
  • Save epall/245717 to your computer and use it in GitHub Desktop.
Save epall/245717 to your computer and use it in GitHub Desktop.
# This is my fantasy for what I should be able to do with RubyGate.
# The basic VHDL translation is taken care of at the lowest level, and
# then I can build a "computer" DSL on top of it in pure Ruby. The
# generated VHDL might not be the fastest, most effiecient, or clearest,
# but it's really just an assembly language.
computer do |c|
c.instruction "add" do |x, y|
x+y
end
c.instruction "subtract" do |x, y|
x-y
end
c.instruction "move" do |addr1, addr2|
memory[addr2] = memory[addr1]
end
c.instruction "jump" do |addr|
next_instruction = addr
end
c.instruction "jeq", "Jump if equal" do |x, y, addr|
if x == y
next_instruction = addr
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment