Sha256: c9c58714bfeea2bcd73ddcaca6fa737d3021914b0638186a387995d3cfd64ef8
Contents?: true
Size: 823 Bytes
Versions: 1
Compression:
Stored size: 823 Bytes
Contents
# Simulates the design under test for one clock cycle. def DUT.cycle! clk.t! advance_time clk.f! advance_time end # Brings the design under test into a blank state. def DUT.reset! reset.t! 5.times { cycle! } reset.f! end OPERATIONS = (DUT.OP_NOP.intVal .. DUT.OP_MULT.intVal).to_a # Represents an ALU operation. class Operation attr_accessor :type, :tag, :arg1, :arg2, :result def initialize(type, tag, arg1 = 0, arg2 = 0) raise ArgumentError unless OPERATIONS.include? type @type = type @tag = tag @arg1 = arg1 @arg2 = arg2 end # Computes the result of this operation. def compute case @type when DUT.OP_ADD.intVal @arg1 + @arg2 when DUT.OP_SUB.intVal @arg1 - @arg2 when DUT.OP_MULT.intVal @arg1 * @arg2 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-vpi-20.0.0 | examples/pipelined_alu/hw5_unit_design.rb |