Sha256: f1b86bf85ba839c9c39a8295d72fcb56b46ab89e8bfa39c99af7be4df79bde82

Contents?: true

Size: 866 Bytes

Versions: 6

Compression:

Stored size: 866 Bytes

Contents

# This file is a behavioral specification for the design under test.

# lowest upper bound of counter's value
LIMIT = 2 ** Counter.Size.intVal

# maximum allowed value for a counter
MAX = LIMIT - 1

context "A resetted counter's value" do
  setup do
    Counter.reset!
  end

  specify "should be zero" do
    Counter.count.intVal.should == 0
  end

  specify "should increment by one count upon each rising clock edge" do
    LIMIT.times do |i|
      Counter.count.intVal.should == i
      simulate # increment the counter
    end
  end
end

context "A counter with the maximum value" do
  setup do
    Counter.reset!

    # increment the counter to maximum value
    MAX.times {simulate}
    Counter.count.intVal.should == MAX
  end

  specify "should overflow upon increment" do
    simulate # increment the counter
    Counter.count.intVal.should == 0
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-vpi-14.0.0 samp/counter/counter_rspec_spec.rb
ruby-vpi-15.0.2 samp/counter/counter_rspec_spec.rb
ruby-vpi-15.0.0 samp/counter/counter_rspec_spec.rb
ruby-vpi-15.0.1 samp/counter/counter_rspec_spec.rb
ruby-vpi-16.0.1 samp/counter/counter_rspec_spec.rb
ruby-vpi-16.0.0 samp/counter/counter_rspec_spec.rb